|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.progeeks.util.xml.XmlReader
public class XmlReader
Provides base support for reading XML files into objects as defined by subclass implementations. This class acts as an adatper between the SAX HandlerBase class and slightly more subclass friendly version. This class is designed to work with JAXP 1.0, ie: SAX1... I don't want to break compatability yet so using a newer version of JAXP will work, but will generate deprecation warnings.
This base class implementation also provides a simple kind of tag handler support that allows subclasses to simple register the appropriate handler objects for reading certain tag types.
Nested Class Summary | |
---|---|
protected class |
XmlReader.XmlHandler
HandlerBase implementation that interacts with the outer class. |
Constructor Summary | |
---|---|
XmlReader()
|
Method Summary | |
---|---|
protected void |
addTagText(java.lang.String name,
java.lang.String newText,
java.lang.StringBuffer accumulatedText,
java.lang.Object object)
Called when new text is parsed within a tag body. |
protected XmlException |
createXmlException(java.lang.String message)
Creates a properly "located" XmlException using the getLocation() method. |
protected XmlException |
createXmlException(java.lang.String message,
java.lang.Throwable cause)
Creates a properly "located" XmlException using the getLocation() method. |
protected void |
endTag(java.lang.String name,
java.lang.String text,
java.lang.Object object)
Called when the end of a tag is reached. |
static java.util.Map |
getAttributesAsMap(org.xml.sax.Attributes atts)
Converts the specified Attributes object to a Map. |
protected java.lang.Object |
getCurrentObject()
Returns the last object that was created during a startTag() method. |
protected org.xml.sax.Locator |
getDocumentLocator()
Returns a locator object that can be used to determine information about the current file position. |
protected boolean |
getIgnoreTagCase()
Returns the tag name case sensitivity policy for looking up tag handlers. |
protected java.lang.String |
getLocation()
Returns the current location as a formatted string. |
protected java.lang.Object |
getPreviousObject()
Returns the object that was created two calls startTag() ago. |
protected java.lang.Object |
getRootObject()
Returns the root object on the stack. |
protected int |
getStackSize()
Returns the current tag object stack size. |
protected TagReader |
getTagReader(java.lang.String tagName)
|
java.lang.Object |
readObject(java.io.Reader in)
Implemented by subclasses to provide read support. |
protected void |
readXml(org.w3c.dom.Document document)
Called by subclasses to read XML in from the supplied document. |
protected void |
readXml(org.w3c.dom.Document document,
javax.xml.transform.Transformer transformer)
Called by subclasses to read XML in from the supplied document after applying the given transformation. |
protected void |
readXml(java.io.Reader in)
Called by the subclass implementation to load data from the specified reader. |
protected void |
registerHandler(java.lang.String tagName,
TagReader tagReader)
Registers the specified handler object to handle tags of the specified tag name. |
protected void |
replaceCurrentObject(java.lang.Object object)
Replaces the last object that was create during a startTag(). |
protected void |
reset()
Resets the internal data structures before reading another object. |
protected org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
|
protected void |
setDefaultHandler(TagReader defaultHandler)
Sets a default handler that will be used when a better handler cannot be found. |
protected void |
setIgnoreTagCase(boolean bool)
Sets the tag name case sensitivity policy for looking up tag handlers. |
protected java.lang.Object |
startTag(java.lang.String name,
org.xml.sax.Attributes atts)
Called at the beginning of a new tag. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlReader()
Method Detail |
---|
public java.lang.Object readObject(java.io.Reader in) throws java.io.IOException
java.io.IOException
protected void reset()
protected void setIgnoreTagCase(boolean bool)
protected boolean getIgnoreTagCase()
protected void setDefaultHandler(TagReader defaultHandler)
protected void registerHandler(java.lang.String tagName, TagReader tagReader)
protected TagReader getTagReader(java.lang.String tagName)
protected java.lang.Object startTag(java.lang.String name, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void addTagText(java.lang.String name, java.lang.String newText, java.lang.StringBuffer accumulatedText, java.lang.Object object) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void endTag(java.lang.String name, java.lang.String text, java.lang.Object object) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected org.xml.sax.Locator getDocumentLocator()
protected java.lang.Object getCurrentObject()
protected void replaceCurrentObject(java.lang.Object object)
protected java.lang.Object getPreviousObject()
protected int getStackSize()
protected java.lang.Object getRootObject()
protected java.lang.String getLocation()
protected XmlException createXmlException(java.lang.String message)
protected XmlException createXmlException(java.lang.String message, java.lang.Throwable cause)
public static java.util.Map getAttributesAsMap(org.xml.sax.Attributes atts)
protected void readXml(java.io.Reader in) throws java.io.IOException, XmlException
java.io.IOException
XmlException
protected void readXml(org.w3c.dom.Document document) throws XmlException
XmlException
protected void readXml(org.w3c.dom.Document document, javax.xml.transform.Transformer transformer) throws XmlException
XmlException
protected org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
org.xml.sax.SAXException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |