Class XmlSourceSaxHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.apache.torque.generator.source.stream.XmlSourceSaxHandler
-
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
public class XmlSourceSaxHandler extends DefaultHandler
A SAX Handler for creating a source element tree from xml.
-
-
Constructor Summary
Constructors Constructor Description XmlSourceSaxHandler(EntityReferences entityReferences)
Constructor.
-
Method Summary
Modifier and Type Method Description void
characters(char[] ch, int start, int length)
void
endElement(String uri, String localName, String qName)
void
error(SAXParseException exception)
void
fatalError(SAXParseException exception)
SourceElement
getRoot()
Returns the root element of the tree.void
ignorableWhitespace(char[] ch, int start, int length)
InputSource
resolveEntity(String publicId, String systemId)
EntityResolver implementation.void
startElement(String uri, String localName, String qName, Attributes attributes)
void
warning(SAXParseException exception)
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
-
-
-
-
Constructor Detail
-
XmlSourceSaxHandler
public XmlSourceSaxHandler(EntityReferences entityReferences)
Constructor.- Parameters:
entityReferences
- the known entity references, not null.
-
-
Method Detail
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
endElement
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length) throws SAXException
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classDefaultHandler
- Throws:
SAXException
-
resolveEntity
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
EntityResolver implementation. Called by the XML parser- Specified by:
resolveEntity
in interfaceEntityResolver
- Overrides:
resolveEntity
in classDefaultHandler
- Parameters:
publicId
- The public identifier of the external entity.systemId
- The system identifier of the external entity.- Returns:
- an InputSource for the entity, or null if the URI is not known.
- Throws:
SAXException
IOException
- See Also:
ConfigurationEntityResolver.resolveEntity(String, String)
-
getRoot
public SourceElement getRoot()
Returns the root element of the tree.- Returns:
- the root element (may be null if no elements were in the xml) or null if the xml was not yet parsed.
-
error
public void error(SAXParseException exception) throws SAXParseException
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
- Throws:
SAXParseException
-
fatalError
public void fatalError(SAXParseException exception) throws SAXParseException
- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
- Throws:
SAXParseException
-
warning
public void warning(SAXParseException exception) throws SAXParseException
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
- Throws:
SAXParseException
-
-