|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
org.pf.pax.BaseXMLTagInterpreter
public abstract class BaseXMLTagInterpreter
This is a basic implemantation of a tag interpreter that is compliant
to the interface XMLTagInterpreter.
It extends a HandlerBase which is a "fake" implementation of a ContentHandler.
In the concept of PAX there normally is one XMLTagInterpreter for each tag
that can be found in an XML stream.
A controller ( see XMLTagInterpreterController ) activates the
corresponding interpreter for each new start tag found by the SAX-parser.
This class implements already all of the methods necessary to interact with
the controller and the parser. But it is still an abstract class.
Subclasses must define the following four methods:
| Constructor Summary | |
|---|---|
BaseXMLTagInterpreter()
Initializes any new instance. |
|
| Method Summary | |
|---|---|
void |
characterData(java.lang.String data)
This method is called whenever character data is received from the parser. |
void |
characters(char[] ch,
int start,
int length)
Is called for PCDATA between a start and end tag. |
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
Is called from the parser for an end tag. |
abstract java.lang.Object |
getResult()
Returns the result object, created by this interpreter from the XML data . |
abstract java.lang.String |
getTagName()
Returns the name of the tag, the interpreter is responsible for. |
void |
invalidSubTagError(java.lang.String tagName)
This is a convenience method for throwing an exception, when a an invalid sub tag is detected. |
void |
requiredAttributeError(java.lang.String attrName)
This is a convenience method for throwing an exception, when a a required attribute of a tag is missing. |
abstract void |
restart(java.lang.String subTagName,
java.lang.Object subResult)
Restarts the receiver after interpretation of a sub tag. |
void |
setController(XMLTagInterpreterController controller)
Sets the controller, the interpreter has to return control to, when finished. |
abstract void |
start(java.lang.String elementName,
org.xml.sax.Attributes attributes)
Starts the work of the receiver the first time. |
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes)
A new sub tag was found. |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.xml.sax.ContentHandler |
|---|
endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping |
| Constructor Detail |
|---|
public BaseXMLTagInterpreter()
| Method Detail |
|---|
public abstract java.lang.String getTagName()
getTagName in interface XMLTagInterpreter
public abstract void start(java.lang.String elementName,
org.xml.sax.Attributes attributes)
throws org.xml.sax.SAXException
start in interface XMLTagInterpreterelementName - The name of the found element. Must be the same as this.getTagName().attributes - The attributes defined in the start tag.
org.xml.sax.SAXException - If the element name is wrong or any attribute is invalid.XMLTagInterpreter.getTagName()
public abstract void restart(java.lang.String subTagName,
java.lang.Object subResult)
throws org.xml.sax.SAXException
restart in interface XMLTagInterpretersubTagName - The name of the sub tag that was completedsubResult - The resulting object build from the sub tag.
org.xml.sax.SAXException - If the subtag is not allowed here.public abstract java.lang.Object getResult()
public void characterData(java.lang.String data)
data - The data received from the parser.ContentHandler.characters(char[],int,int)public void setController(XMLTagInterpreterController controller)
setController in interface XMLTagInterpretercontroller - The controller of the XML interpretation process.
public void startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes)
throws org.xml.sax.SAXException
startElement in interface org.xml.sax.ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionrestart(String,Object),
ContentHandler.startElement(String,String,String,Attributes)
public void endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
throws org.xml.sax.SAXException
This method calls finalizeResult() and then returns controll to the overall tag interpreter controller.
endElement in interface org.xml.sax.ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandleruri - The URI of the tag's namespace or null if no namespace definedlocalName - The name of the end tag without any namespace prefix.qName - The qualified name (might contain the namespace prefix)
org.xml.sax.SAXExceptionContentHandler.endElement(String,String,String)
public void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
characters in interface org.xml.sax.ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptioncharacterData(String)
public void invalidSubTagError(java.lang.String tagName)
throws org.xml.sax.SAXException
restart(String,Object).
tagName - The name of the invalid sub tag.
org.xml.sax.SAXException - Is always thrown by this method !
public void requiredAttributeError(java.lang.String attrName)
throws org.xml.sax.SAXException
start(String,Attributes).
attrName - The name of the required attribute.
org.xml.sax.SAXException - Is always thrown by this method !
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||