Javolution 6.0.0 java
|
Public Member Functions | |
XMLReaderImpl () | |
void | parse (InputStream in) throws IOException, SAXException |
void | parse (InputStream in, String encoding) throws IOException, SAXException |
void | parse (Reader reader) throws IOException, SAXException |
void | parse (InputSource input) throws IOException, SAXException |
void | parse (String systemId) throws IOException, SAXException |
void | setContentHandler (ContentHandler handler) |
ContentHandler | getContentHandler () |
void | setErrorHandler (ErrorHandler handler) |
ErrorHandler | getErrorHandler () |
boolean | getFeature (String name) throws SAXNotRecognizedException, SAXNotSupportedException |
void | setFeature (String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException |
Object | getProperty (String name) throws SAXNotRecognizedException, SAXNotSupportedException |
void | setProperty (String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException |
void | setEntityResolver (EntityResolver resolver) |
EntityResolver | getEntityResolver () |
void | setDTDHandler (DTDHandler handler) |
DTDHandler | getDTDHandler () |
void | reset () |
Private Member Functions | |
void | parseAll () throws XMLStreamException, SAXException |
Private Attributes | |
ContentHandler | _contentHandler |
ErrorHandler | _errorHandler |
final XMLStreamReaderImpl | _xmlReader = new XMLStreamReaderImpl() |
EntityResolver | _entityResolver |
DTDHandler | _dtdHandler |
Static Private Attributes | |
static DefaultHandler | DEFAULT_HANDLER = new DefaultHandler() |
static final CharArray | NO_CHAR = new CharArray("") |
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 is implemented as a SAX2 wrapper around
XMLStreamReaderImpl and share the same characteristics.
Note: This parser is a SAX2-like parser with the java.lang.String
type replaced by CharArray/CharSequence in the ContentHandler, Attributes interfaces and DefaultHandler base class. If a standard SAX2 or JAXP parser is required, you may consider using the wrapping class SAX2ReaderImpl. Fast but not as fast as java.lang.String
instances are dynamically allocated while parsing.
Definition at line 48 of file XMLReaderImpl.java.
javolution.xml.sax.XMLReaderImpl.XMLReaderImpl | ( | ) |
Default constructor.
Definition at line 73 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl.DEFAULT_HANDLER, javolution.xml.sax.XMLReaderImpl.setContentHandler(), and javolution.xml.sax.XMLReaderImpl.setErrorHandler().
ContentHandler javolution.xml.sax.XMLReaderImpl.getContentHandler | ( | ) |
Return the current content handler.
Implements javolution.xml.sax.XMLReader.
Definition at line 195 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._contentHandler, and javolution.xml.sax.XMLReaderImpl.DEFAULT_HANDLER.
DTDHandler javolution.xml.sax.XMLReaderImpl.getDTDHandler | ( | ) |
Return the current DTD handler.
Implements javolution.xml.sax.XMLReader.
Definition at line 266 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._dtdHandler.
Referenced by javolution.xml.sax.SAX2ReaderImpl.getDTDHandler().
EntityResolver javolution.xml.sax.XMLReaderImpl.getEntityResolver | ( | ) |
Return the current entity resolver.
Implements javolution.xml.sax.XMLReader.
Definition at line 256 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._entityResolver.
Referenced by javolution.xml.sax.SAX2ReaderImpl.getEntityResolver().
ErrorHandler javolution.xml.sax.XMLReaderImpl.getErrorHandler | ( | ) |
Return the current error handler.
Implements javolution.xml.sax.XMLReader.
Definition at line 209 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._errorHandler, and javolution.xml.sax.XMLReaderImpl.DEFAULT_HANDLER.
Referenced by javolution.xml.sax.SAX2ReaderImpl.getErrorHandler().
boolean javolution.xml.sax.XMLReaderImpl.getFeature | ( | String | name | ) | throws SAXNotRecognizedException, SAXNotSupportedException |
Look up the value of a feature flag.
The feature name is any fully-qualified URI. It is possible for an XMLReader to recognize a feature name but temporarily be unable to return its value. Some feature values may be available only in specific contexts, such as before, during, or after a parse. Also, some feature values may not be programmatically accessible. (In the case of an adapter for SAX1 org.xml.sax.Parser, there is no implementation-independent way to expose whether the underlying parser is performing validation, expanding external entities, and so forth.)
All XMLReaders are required to recognize the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes feature names.
Typical usage is something like this:
XMLReader r = new MySAXDriver();
// try to activate validation try { r.setFeature("http://xml.org/sax/features/validation", true); } catch (SAXException e) { System.err.println("Cannot activate validation."); }
// register event handlers r.setContentHandler(new MyContentHandler()); r.setErrorHandler(new MyErrorHandler());
// parse the first document try { r.parse("http://www.foo.com/mydoc.xml"); } catch (IOException e) { System.err.println("I/O exception reading XML document"); } catch (SAXException e) { System.err.println("XML exception reading document."); }
Implementors are free (and encouraged) to invent their own features, using names built on their own URIs.
name | The feature name, which is a fully-qualified URI. |
org.xml.sax.SAXNotRecognizedException | If the feature value can't be assigned or retrieved. |
org.xml.sax.SAXNotSupportedException | When the XMLReader recognizes the feature name but cannot determine its value at this time. |
Implements javolution.xml.sax.XMLReader.
Definition at line 214 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.SAX2ReaderImpl.getFeature().
Object javolution.xml.sax.XMLReaderImpl.getProperty | ( | String | name | ) | throws SAXNotRecognizedException, SAXNotSupportedException |
Look up the value of a property.
The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but temporarily be unable to return its value. Some property values may be available only in specific contexts, such as before, during, or after a parse.
XMLReaders are not required to recognize any specific property names, though an initial core set is documented for SAX2.
Implementors are free (and encouraged) to invent their own properties, using names built on their own URIs.
name | The property name, which is a fully-qualified URI. |
org.xml.sax.SAXNotRecognizedException | If the property value can't be assigned or retrieved. |
org.xml.sax.SAXNotSupportedException | When the XMLReader recognizes the property name but cannot determine its value at this time. |
Implements javolution.xml.sax.XMLReader.
Definition at line 238 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.SAX2ReaderImpl.getProperty().
void javolution.xml.sax.XMLReaderImpl.parse | ( | InputSource | input | ) | throws IOException, SAXException |
Parse an XML document.
The application can use this method to instruct the XML reader to begin parsing an XML document from any valid input source (a character stream, a byte stream, or a URI).
Applications may not invoke this method while a parse is in progress (they should create a new XMLReader instead for each nested XML document). Once a parse is complete, an application may reuse the same XMLReader object, possibly with a different input source. Configuration of the XMLReader object (such as handler bindings and values established for feature flags and properties) is unchanged by completion of a parse, unless the definition of that aspect of the configuration explicitly specifies other behavior. (For example, feature flags or properties exposing characteristics of the document being parsed.)
During the parse, the XMLReader will provide information about the XML document through the registered event handlers.
This method is synchronous: it will not return until parsing has ended. If a client application wants to terminate parsing early, it should throw an exception.
input | The input source for the top-level of the XML document. |
org.xml.sax.SAXException | Any SAX exception, possibly wrapping another exception. |
j2me.io.IOException | An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. |
Implements javolution.xml.sax.XMLReader.
Definition at line 154 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl.parse().
void javolution.xml.sax.XMLReaderImpl.parse | ( | InputStream | in | ) | throws IOException, SAXException |
Parses an XML document from the specified input stream (encoding retrieved from input source and the XML prolog if any).
in | the input stream with unknown encoding. |
org.xml.sax.SAXException | any SAX exception, possibly wrapping another exception. |
IOException | an IO exception from the parser, possibly from a byte stream or character stream supplied by the application. |
Definition at line 90 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._xmlReader, javolution.xml.stream.XMLStreamException.getNestedException(), javolution.xml.sax.XMLReaderImpl.parseAll(), javolution.xml.internal.stream.XMLStreamReaderImpl.reset(), and javolution.xml.internal.stream.XMLStreamReaderImpl.setInput().
Referenced by javolution.xml.sax.SAX2ReaderImpl.parse(), and javolution.xml.sax.XMLReaderImpl.parse().
void javolution.xml.sax.XMLReaderImpl.parse | ( | InputStream | in, |
String | encoding | ||
) | throws IOException, SAXException |
Parses an XML document from the specified input stream and encoding.
in | the input stream. |
encoding | the input stream encoding. |
org.xml.sax.SAXException | any SAX exception, possibly wrapping another exception. |
IOException | an IO exception from the parser, possibly from a byte stream or character stream supplied by the application. |
Definition at line 114 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._xmlReader, javolution.xml.stream.XMLStreamException.getNestedException(), javolution.xml.sax.XMLReaderImpl.parseAll(), javolution.xml.internal.stream.XMLStreamReaderImpl.reset(), and javolution.xml.internal.stream.XMLStreamReaderImpl.setInput().
void javolution.xml.sax.XMLReaderImpl.parse | ( | Reader | reader | ) | throws IOException, SAXException |
Parses an XML document using the specified reader.
reader | the document reader. |
SAXException | any SAX exception, possibly wrapping another exception. |
IOException | an IO exception from the parser, possibly from a byte stream or character stream supplied by the application. |
Definition at line 140 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._xmlReader, javolution.xml.stream.XMLStreamException.getNestedException(), javolution.xml.sax.XMLReaderImpl.parseAll(), javolution.xml.internal.stream.XMLStreamReaderImpl.reset(), and javolution.xml.internal.stream.XMLStreamReaderImpl.setInput().
void javolution.xml.sax.XMLReaderImpl.parse | ( | String | systemId | ) | throws IOException, SAXException |
Parse an XML document from a system identifier (URI).
This method is a shortcut for the common case of reading a document from a system identifier. It is the exact equivalent of the following:
parse(new InputSource(systemId));
If the system identifier is a URL, it must be fully resolved by the application before it is passed to the parser.
systemId | The system identifier (URI). |
org.xml.sax.SAXException | Any SAX exception, possibly wrapping another exception. |
j2me.io.IOException | An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. |
Implements javolution.xml.sax.XMLReader.
Definition at line 169 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl.parse().
|
private |
Parses the whole document using the real-time pull parser.
SAXException | any SAX exception, possibly wrapping another exception. |
IOException | an IO exception from the parser, possibly from a byte stream or character stream supplied by the application. |
Definition at line 285 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._contentHandler, javolution.xml.sax.XMLReaderImpl._xmlReader, javolution.text.CharArray.array(), javolution.xml.stream.XMLStreamConstants.CDATA, javolution.xml.stream.XMLStreamConstants.CHARACTERS, javolution.xml.sax.ContentHandler.characters(), javolution.xml.internal.stream.XMLStreamReaderImpl.close(), javolution.xml.stream.XMLStreamConstants.COMMENT, javolution.xml.stream.XMLStreamConstants.END_DOCUMENT, javolution.xml.stream.XMLStreamConstants.END_ELEMENT, javolution.xml.sax.ContentHandler.endElement(), javolution.xml.sax.ContentHandler.endPrefixMapping(), javolution.xml.internal.stream.XMLStreamReaderImpl.getAttributes(), javolution.xml.internal.stream.XMLStreamReaderImpl.getEventType(), javolution.xml.internal.stream.XMLStreamReaderImpl.getLocalName(), javolution.xml.internal.stream.XMLStreamReaderImpl.getNamespaceCount(), javolution.xml.internal.stream.XMLStreamReaderImpl.getNamespacePrefix(), javolution.xml.internal.stream.XMLStreamReaderImpl.getNamespaceURI(), javolution.xml.internal.stream.XMLStreamReaderImpl.getPIData(), javolution.xml.internal.stream.XMLStreamReaderImpl.getPITarget(), javolution.xml.internal.stream.XMLStreamReaderImpl.getQName(), javolution.xml.internal.stream.XMLStreamReaderImpl.getText(), javolution.xml.sax.ContentHandler.ignorableWhitespace(), javolution.text.CharArray.length(), javolution.xml.internal.stream.XMLStreamReaderImpl.next(), javolution.xml.sax.XMLReaderImpl.NO_CHAR, javolution.text.CharArray.offset(), javolution.xml.stream.XMLStreamConstants.PROCESSING_INSTRUCTION, javolution.xml.sax.ContentHandler.processingInstruction(), javolution.xml.stream.XMLStreamConstants.SPACE, javolution.xml.stream.XMLStreamConstants.START_DOCUMENT, javolution.xml.stream.XMLStreamConstants.START_ELEMENT, javolution.xml.sax.ContentHandler.startDocument(), javolution.xml.sax.ContentHandler.startElement(), and javolution.xml.sax.ContentHandler.startPrefixMapping().
Referenced by javolution.xml.sax.XMLReaderImpl.parse().
void javolution.xml.sax.XMLReaderImpl.reset | ( | ) |
Definition at line 271 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._xmlReader, javolution.xml.sax.XMLReaderImpl.DEFAULT_HANDLER, javolution.xml.internal.stream.XMLStreamReaderImpl.reset(), javolution.xml.sax.XMLReaderImpl.setContentHandler(), and javolution.xml.sax.XMLReaderImpl.setErrorHandler().
Referenced by javolution.xml.sax.SAX2ReaderImpl.parse(), and javolution.xml.sax.SAX2ReaderImpl.reset().
void javolution.xml.sax.XMLReaderImpl.setContentHandler | ( | ContentHandler | handler | ) |
Allow an application to register a 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.
handler | The content handler. |
Implements javolution.xml.sax.XMLReader.
Definition at line 186 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._contentHandler.
Referenced by javolution.xml.sax.XMLReaderImpl.reset(), javolution.xml.sax.SAX2ReaderImpl.setContentHandler(), and javolution.xml.sax.XMLReaderImpl.XMLReaderImpl().
void javolution.xml.sax.XMLReaderImpl.setDTDHandler | ( | DTDHandler | handler | ) |
Allow an application to register a DTD event handler.
If the application does not register a DTD handler, all DTD 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.
handler | The DTD handler. |
Implements javolution.xml.sax.XMLReader.
Definition at line 260 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._dtdHandler.
Referenced by javolution.xml.sax.SAX2ReaderImpl.setDTDHandler().
void javolution.xml.sax.XMLReaderImpl.setEntityResolver | ( | EntityResolver | resolver | ) |
Allow an application to register an entity resolver.
If the application does not register an entity resolver, the XMLReader will perform its own default resolution.
Applications may register a new or different resolver in the middle of a parse, and the SAX parser must begin using the new resolver immediately.
resolver | The entity resolver. |
Implements javolution.xml.sax.XMLReader.
Definition at line 250 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._entityResolver.
Referenced by javolution.xml.sax.SAX2ReaderImpl.setEntityResolver().
void javolution.xml.sax.XMLReaderImpl.setErrorHandler | ( | ErrorHandler | handler | ) |
Allow 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.
handler | The error handler. |
Implements javolution.xml.sax.XMLReader.
Definition at line 200 of file XMLReaderImpl.java.
References javolution.xml.sax.XMLReaderImpl._errorHandler.
Referenced by javolution.xml.sax.XMLReaderImpl.reset(), javolution.xml.sax.SAX2ReaderImpl.setErrorHandler(), and javolution.xml.sax.XMLReaderImpl.XMLReaderImpl().
void javolution.xml.sax.XMLReaderImpl.setFeature | ( | String | name, |
boolean | value | ||
) | throws SAXNotRecognizedException, SAXNotSupportedException |
Set the value of a feature flag.
The feature name is any fully-qualified URI. It is possible for an XMLReader to expose a feature value but to be unable to change the current value. Some feature values may be immutable or mutable only in specific contexts, such as before, during, or after a parse.
All XMLReaders are required to support setting http://xml.org/sax/features/namespaces to true and http://xml.org/sax/features/namespace-prefixes to false.
name | The feature name, which is a fully-qualified URI. |
value | The requested value of the feature (true or false). |
org.xml.sax.SAXNotRecognizedException | If the feature value can't be assigned or retrieved. |
org.xml.sax.SAXNotSupportedException | When the XMLReader recognizes the feature name but cannot set the requested value. |
Implements javolution.xml.sax.XMLReader.
Definition at line 227 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.SAX2ReaderImpl.setFeature().
void javolution.xml.sax.XMLReaderImpl.setProperty | ( | String | name, |
Object | value | ||
) | throws SAXNotRecognizedException, SAXNotSupportedException |
Set the value of a property.
The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but to be unable to change the current value. Some property values may be immutable or mutable only in specific contexts, such as before, during, or after a parse.
XMLReaders are not required to recognize setting any specific property names, though a core set is defined by SAX2.
This method is also the standard mechanism for setting extended handlers.
name | The property name, which is a fully-qualified URI. |
value | The requested value for the property. |
org.xml.sax.SAXNotRecognizedException | If the property value can't be assigned or retrieved. |
org.xml.sax.SAXNotSupportedException | When the XMLReader recognizes the property name but cannot set the requested value. |
Implements javolution.xml.sax.XMLReader.
Definition at line 244 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.SAX2ReaderImpl.setProperty().
|
private |
Holds the content handler.
Definition at line 58 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.XMLReaderImpl.getContentHandler(), javolution.xml.sax.XMLReaderImpl.parseAll(), and javolution.xml.sax.XMLReaderImpl.setContentHandler().
|
private |
Definition at line 264 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.XMLReaderImpl.getDTDHandler(), and javolution.xml.sax.XMLReaderImpl.setDTDHandler().
|
private |
Definition at line 254 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.XMLReaderImpl.getEntityResolver(), and javolution.xml.sax.XMLReaderImpl.setEntityResolver().
|
private |
Holds the error handler.
Definition at line 63 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.XMLReaderImpl.getErrorHandler(), and javolution.xml.sax.XMLReaderImpl.setErrorHandler().
|
private |
Holds reusable StAX reader.
Definition at line 68 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.XMLReaderImpl.parse(), javolution.xml.sax.XMLReaderImpl.parseAll(), and javolution.xml.sax.XMLReaderImpl.reset().
|
staticprivate |
Holds the default handler instance.
Definition at line 53 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.XMLReaderImpl.getContentHandler(), javolution.xml.sax.XMLReaderImpl.getErrorHandler(), javolution.xml.sax.XMLReaderImpl.reset(), and javolution.xml.sax.XMLReaderImpl.XMLReaderImpl().
Definition at line 362 of file XMLReaderImpl.java.
Referenced by javolution.xml.sax.XMLReaderImpl.parseAll().