Class XmlSaxParserImpl
- java.lang.Object
-
- javolution37.javolution.xml.sax.XmlSaxParserImpl
-
- All Implemented Interfaces:
- Reusable
public class XmlSaxParserImpl extends java.lang.Object implements Reusable
This class provides a real-time SAX2-like XML parser; this parser is extremely fast and does not create temporary objects (no garbage generated and no GC interruption).
The parser input source can be either a
Reader, anInputStreamor even aByteBuffer(e.g.MappedByteBuffer).The parser is implemented as a SAX2 wrapper around the real-time
XmlPullParserImpland share the same characteristics.Note: This parser is a SAX2-like parser with the
java.lang.Stringtype replaced by the more genericjava.lang.CharSequencein theContentHandler,Attributesinterfaces andDefaultHandlerbase class. If a standard SAX2 or JAXP parser is required, you may consider using the wrapping classXMLReaderImpl. Fast but not as fast asjava.lang.Stringinstances are dynamically allocated while parsing.
-
-
Constructor Summary
Constructors Constructor and Description XmlSaxParserImpl()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description ContentHandlergetContentHandler()Returns the current real-time content handler.org.xml.sax.DTDHandlergetDTDHandler()Returns the current DTD handler.org.xml.sax.EntityResolvergetEntityResolver()Returns the current entity resolver.org.xml.sax.ErrorHandlergetErrorHandler()Returns the current error handler.booleangetFeature(java.lang.String name)Looks up the value of a feature.java.lang.ObjectgetProperty(java.lang.String name)Looks up the value of a property.voidparse(java.nio.ByteBuffer byteBuffer)Parses an XML document from the specifiedByteBuffer(UTF-8 encoding).voidparse(java.io.InputStream in)Parses an XML document from the specified input stream (UTF-8 encoding).voidparse(java.io.Reader reader)Parses an XML document using the specified reader.voidreset()Resets the internal state of this object to its default values.voidsetContentHandler(ContentHandler handler)Allows an application to register a real-time content event handler.voidsetDTDHandler(org.xml.sax.DTDHandler handler)Allows an application to register a DTD handler (ignored by this parser).voidsetEntityResolver(org.xml.sax.EntityResolver resolver)Allows an application to register an entity resolver (ignored by this parser).voidsetErrorHandler(org.xml.sax.ErrorHandler handler)Allows an application to register an error event handler.voidsetFeature(java.lang.String name, boolean value)Sets the state of a feature.voidsetProperty(java.lang.String name, java.lang.Object value)Sets the value of a property.
-
-
-
Method Detail
-
setContentHandler
public void setContentHandler(ContentHandler handler)
Allows an application to register a real-time content event handler.If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored.
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Parameters:
handler- the real-time content handler.- Throws:
java.lang.NullPointerException- if the handler argument is null.- See Also:
getContentHandler()
-
getContentHandler
public ContentHandler getContentHandler()
Returns the current real-time content handler.- Returns:
- the current real-time content handler, or
nullif none has been registered. - See Also:
setContentHandler(javolution37.javolution.xml.sax.ContentHandler)
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler handler)
Allows an application to register an error event handler.If the application does not register an error handler, all error events reported by the SAX parser will be silently ignored; however, normal processing may not continue. It is highly recommended that all SAX applications implement an error handler to avoid unexpected bugs.
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
- Parameters:
handler- the error handler.- Throws:
java.lang.NullPointerException- if the handler argument is null.- See Also:
getErrorHandler()
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
Returns the current error handler.- Returns:
- the current error handler, or
nullif none has been registered. - See Also:
setErrorHandler(org.xml.sax.ErrorHandler)
-
parse
public void parse(java.io.InputStream in) throws java.io.IOException, org.xml.sax.SAXExceptionParses an XML document from the specified input stream (UTF-8 encoding).- Parameters:
in- the input stream with UTF-8 encoding.- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception.java.io.IOException- an IO exception from the parser, possibly from a byte stream or character stream supplied by the application.- See Also:
Utf8StreamReader
-
parse
public void parse(java.nio.ByteBuffer byteBuffer) throws java.io.IOException, org.xml.sax.SAXExceptionParses an XML document from the specifiedByteBuffer(UTF-8 encoding).- Parameters:
byteBuffer- the byte buffer with UTF-8 encoding.- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception.java.io.IOException- an IO exception from the parser, possibly from a byte stream or character stream supplied by the application.- See Also:
Utf8ByteBufferReader
-
parse
public void parse(java.io.Reader reader) throws java.io.IOException, org.xml.sax.SAXExceptionParses an XML document using the specified reader.- Parameters:
reader- the document reader.- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception.java.io.IOException- an IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
-
getFeature
public boolean getFeature(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionLooks up the value of a feature.Recognizes
http://xml.org/sax/features/namespacesand thehttp://xml.org/sax/features/namespace-prefixesfeature names.- Parameters:
name- the feature name, which is a fully-qualified URI.- Returns:
- the current state of the feature (true or false).
- Throws:
org.xml.sax.SAXNotRecognizedException- when the XMLReader does not recognize the feature name.org.xml.sax.SAXNotSupportedException- when the XMLReader recognizes the feature name but cannot determine its value at this time.- See Also:
setFeature(java.lang.String, boolean)
-
setFeature
public void setFeature(java.lang.String name, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSets the state of a feature.Recognizes
http://xml.org/sax/features/namespacesand thehttp://xml.org/sax/features/namespace-prefixesfeature names.- Parameters:
name- the feature name, which is a fully-qualified URI.value- the requested state of the feature (true or false).- Throws:
org.xml.sax.SAXNotRecognizedException- when the XMLReader does not recognize the feature name.org.xml.sax.SAXNotSupportedException- when the XMLReader recognizes the feature name but cannot set the requested value.- See Also:
getFeature(java.lang.String)
-
getProperty
public java.lang.Object getProperty(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionLooks up the value of a property.- Parameters:
name- the property name, which is a fully-qualified URI.- Returns:
- the current value of the property.
- Throws:
org.xml.sax.SAXNotRecognizedException- when the XMLReader does not recognize the property name.org.xml.sax.SAXNotSupportedException- when the XMLReader recognizes the property name but cannot determine its value at this time.- See Also:
setProperty(java.lang.String, java.lang.Object)
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedExceptionSets the value of a property.- Parameters:
name- the property name, which is a fully-qualified URI.value- the requested value for the property.- Throws:
org.xml.sax.SAXNotRecognizedException- when the XMLReader does not recognize the property name.org.xml.sax.SAXNotSupportedException- when the XMLReader recognizes the property name but cannot set the requested value.
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Allows an application to register an entity resolver (ignored by this parser).- Parameters:
resolver- the entity resolver.
-
getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()
Returns the current entity resolver.- Returns:
- the current entity resolver, or
nullif none has been registered. - See Also:
setEntityResolver(org.xml.sax.EntityResolver)
-
setDTDHandler
public void setDTDHandler(org.xml.sax.DTDHandler handler)
Allows an application to register a DTD handler (ignored by this parser).- Parameters:
handler- the DTD handler.
-
getDTDHandler
public org.xml.sax.DTDHandler getDTDHandler()
Returns the current DTD handler.- Returns:
- the current DTD handler, or
nullif none has been registered. - See Also:
setDTDHandler(org.xml.sax.DTDHandler)
-
-
DMelt 3.0 © DataMelt by jWork.ORG