|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.xml.dom.TokenWalker
de.fu_berlin.ties.filter.FilteringTokenWalker
public class FilteringTokenWalker
A token walker that only invokes a provided
TokenProcessor
on the subset of tokens
that are children of an element accepted by a provided
ElementFilter
.
Instances of this class are not thread-safe.
Constructor Summary | |
---|---|
FilteringTokenWalker(TokenProcessor processor,
TokenizerFactory tFactory,
ElementFilter elementFilter,
SkipHandler sHandler)
Creates a new instance. |
Method Summary | |
---|---|
Set |
getAcceptedElements()
Returns the set of elements that have been accepted by the filter in the current document. |
protected ElementFilter |
getFilter()
Returns the element filter used by this instance. |
Set |
getRejectedElements()
Returns the set of elements that have been rejected by the filter in the current document. |
protected boolean |
handleAccept(Element element,
Element filteredElement,
boolean decision)
This method can be overwritten by subclasses to modify decisions of the element filter. |
protected void |
processToken(Element element,
String left,
TokenDetails details,
String right,
ContextMap context)
Processes a token in an XML element by delegating to the configured TokenProcessor . |
String |
toString()
Returns a string representation of this object. |
void |
walk(Document document,
ContextMap context)
Walks through the contents of an XML document, tokenizing the textual contents. |
Methods inherited from class de.fu_berlin.ties.xml.dom.TokenWalker |
---|
processCollectedText, walk |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FilteringTokenWalker(TokenProcessor processor, TokenizerFactory tFactory, ElementFilter elementFilter, SkipHandler sHandler)
processor
- used to process the tokenstFactory
- used to instantiate tokenizerselementFilter
- the element filter to usesHandler
- a handler that is called whenever some tokens are
skipped; may be null
Method Detail |
---|
public Set getAcceptedElements()
public Set getRejectedElements()
protected ElementFilter getFilter()
protected boolean handleAccept(Element element, Element filteredElement, boolean decision) throws ProcessingException
element
- the element to testfilteredElement
- the element that was actually filtered
(element
or a parent), or null
if the decision
had been cached (no filtering took place)decision
- the decision of the element filer
ProcessingException
- if an error occurs while revising the
decisionprotected void processToken(Element element, String left, TokenDetails details, String right, ContextMap context) throws IOException, ProcessingException
TokenProcessor
.
processToken
in class TokenWalker
element
- the element containing the tokenleft
- the textual contents of the element to the left of the
token
(in case of mixed contents, only up to the last
preceding child element, if any)details
- details about the token to processright
- the textual contents of the element to the right of the
token
(in case of mixed contents, only up to the next
following child element, if any)context
- a map of objects that are made available for processing
IOException
- if an I/O error occurs
ProcessingException
- if an error occurs during processingpublic void walk(Document document, ContextMap context) throws IOException, ProcessingException
TokenProcessor
.
walk
in class TokenWalker
document
- the document to walk throughcontext
- a map of objects that are made available for processing;
might be null
if not requred by the token processor
IOException
- might be throws by the token processor
ProcessingException
- might be throws by the token processorpublic String toString()
toString
in class TokenWalker
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |