|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.txt2xml.core.Processor
Base class for agents that match part(s) of a CharSequence and write XML Elements as match(es) are found. Matched CharSequences are passed onto the sub-Processor for further work. When all matches are done, the remainder of the original CharSequence is passed to the nextProcessor.
Processors act as iterators that update their internal state during a round of matching. Processors are not thread-safe.
Namespaces in generated XML are not yet supported.
Subclasses must override
findMatch()
getMatchedText()
getRemainderText()
and optionally resetMatching().
| Field Summary | |
protected java.lang.CharSequence |
chars
The current CharSequence being matched against. |
protected org.xml.sax.ContentHandler |
handler
The current ContentHandler to write XML to. |
protected static org.xml.sax.Attributes |
NULL_ATTRIBUTES
|
protected Processor |
parent
Parent Processor that is using this as a sub-Processor. |
| Constructor Summary | |
Processor()
|
|
| Method Summary | |
protected abstract boolean |
findMatch()
Find next match, updating state appropriately. |
protected void |
generateEndXmlElement()
Write the end element for this Processor. |
protected void |
generateStartXmlElement()
Write this Processor's start element as a simple element with no attributes. |
protected void |
generateXmlElementCharacters()
Write the contents of the element. |
void |
generateXmlFragment(java.lang.CharSequence text,
org.xml.sax.ContentHandler contentHandler)
Match part of the passed CharSequence. |
java.lang.String |
getElement()
|
protected abstract java.lang.CharSequence |
getMatchedText()
Override this! |
Processor |
getNextProcessor()
Gets the nextProcessor. |
protected abstract java.lang.CharSequence |
getRemainderText()
Override this! |
Processor |
getSubProcessor()
|
protected void |
resetMatching()
Called at start of generateXmlFragment(CharSequence, ContentHandler)
to reset the state before starting a round of matching. |
void |
setElement(java.lang.String elementName)
|
void |
setNextProcessor(Processor nextProcessor)
Sets the nextProcessor. |
void |
setSubProcessor(Processor subProcessor)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final org.xml.sax.Attributes NULL_ATTRIBUTES
protected Processor parent
generateXmlFragment(CharSequence, ContentHandler).
protected java.lang.CharSequence chars
generateXmlFragment(CharSequence, ContentHandler).
protected org.xml.sax.ContentHandler handler
generateXmlFragment(CharSequence, ContentHandler).
| Constructor Detail |
public Processor()
| Method Detail |
public void generateXmlFragment(java.lang.CharSequence text,
org.xml.sax.ContentHandler contentHandler)
throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void generateStartXmlElement()
throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void generateEndXmlElement()
throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void generateXmlElementCharacters()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void resetMatching()
generateXmlFragment(CharSequence, ContentHandler)
to reset the state before starting a round of matching. Override to
prepare for a round of matching, eg RegexDelimitedProcessor
resets the regex Matcher here.
protected abstract boolean findMatch()
protected abstract java.lang.CharSequence getMatchedText()
findMatch().protected abstract java.lang.CharSequence getRemainderText()
public Processor getNextProcessor()
public void setNextProcessor(Processor nextProcessor)
nextProcessor - The nextProcessor to setpublic Processor getSubProcessor()
public void setSubProcessor(Processor subProcessor)
subProcessor - the sub-Processor that will process this
Processor's matched text.public java.lang.String getElement()
public void setElement(java.lang.String elementName)
elementName - the name of the element
written by this Processor.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||