Javolution 6.0.0 java
javolution.xml.sax.SAX2ReaderImpl Class Reference
Inheritance diagram for javolution.xml.sax.SAX2ReaderImpl:
[legend]
Collaboration diagram for javolution.xml.sax.SAX2ReaderImpl:
[legend]

Classes

class  Proxy
 
class  Sax2DefaultHandler
 

Public Member Functions

 SAX2ReaderImpl ()
 
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 setContentHandler (ContentHandler handler)
 
ContentHandler getContentHandler ()
 
void setErrorHandler (ErrorHandler handler)
 
ErrorHandler getErrorHandler ()
 
void parse (InputSource input) throws IOException, SAXException
 
void parse (String systemId) throws IOException, SAXException
 
void reset ()
 

Static Private Member Functions

static CharSequence toCharSequence (Object obj)
 

Private Attributes

final XMLReaderImpl _parser = new XMLReaderImpl()
 
final Proxy _proxy = new Proxy()
 

Static Private Attributes

static Sax2DefaultHandler DEFAULT_HANDLER = new Sax2DefaultHandler()
 

Detailed Description

This class provides a SAX2-compliant parser wrapping a javolution.xml.sax.XMLReaderImpl. This parser allocates java.lang.String instances while parsing in accordance with the SAX2 specification. For faster performance (2-5x), the use of the SAX2-like XMLSaxParserImpl or betterXMLStreamReader is recommended.

Author
Jean-Marie Dautelle
Version
4.0, June 16, 2005
See also
SAX – Simple API for XML

Definition at line 43 of file SAX2ReaderImpl.java.

Constructor & Destructor Documentation

◆ SAX2ReaderImpl()

javolution.xml.sax.SAX2ReaderImpl.SAX2ReaderImpl ( )

Default constructor.

Definition at line 63 of file SAX2ReaderImpl.java.

63 {}

Member Function Documentation

◆ getContentHandler()

ContentHandler javolution.xml.sax.SAX2ReaderImpl.getContentHandler ( )

Return the current content handler.

Returns
The current content handler, or null if none has been registered.
See also
setContentHandler

Implements javolution.xml.sax.XMLReader.

Definition at line 120 of file SAX2ReaderImpl.java.

120  {
121  return (_proxy._sax2Handler == DEFAULT_HANDLER) ? null
123  }

References javolution.xml.sax.SAX2ReaderImpl._proxy, javolution.xml.sax.SAX2ReaderImpl.Proxy._sax2Handler, and javolution.xml.sax.SAX2ReaderImpl.DEFAULT_HANDLER.

◆ getDTDHandler()

DTDHandler javolution.xml.sax.SAX2ReaderImpl.getDTDHandler ( )

Return the current DTD handler.

Returns
The current DTD handler, or null if none has been registered.
See also
setDTDHandler

Implements javolution.xml.sax.XMLReader.

Definition at line 105 of file SAX2ReaderImpl.java.

105  {
106  return _parser.getDTDHandler();
107  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.getDTDHandler().

Here is the call graph for this function:

◆ getEntityResolver()

EntityResolver javolution.xml.sax.SAX2ReaderImpl.getEntityResolver ( )

Return the current entity resolver.

Returns
The current entity resolver, or null if none has been registered.
See also
setEntityResolver

Implements javolution.xml.sax.XMLReader.

Definition at line 95 of file SAX2ReaderImpl.java.

95  {
96  return _parser.getEntityResolver();
97  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.getEntityResolver().

Here is the call graph for this function:

◆ getErrorHandler()

ErrorHandler javolution.xml.sax.SAX2ReaderImpl.getErrorHandler ( )

Return the current error handler.

Returns
The current error handler, or null if none has been registered.
See also
setErrorHandler

Implements javolution.xml.sax.XMLReader.

Definition at line 131 of file SAX2ReaderImpl.java.

131  {
132  return _parser.getErrorHandler();
133  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.getErrorHandler().

Here is the call graph for this function:

◆ getFeature()

boolean javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
nameThe feature name, which is a fully-qualified URI.
Returns
The current value of the feature (true or false).
Exceptions
org.xml.sax.SAXNotRecognizedExceptionIf the feature value can't be assigned or retrieved.
org.xml.sax.SAXNotSupportedExceptionWhen the XMLReader recognizes the feature name but cannot determine its value at this time.
See also
setFeature

Implements javolution.xml.sax.XMLReader.

Definition at line 66 of file SAX2ReaderImpl.java.

67  {
68  return _parser.getFeature(name);
69  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.getFeature().

Here is the call graph for this function:

◆ getProperty()

Object javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
nameThe property name, which is a fully-qualified URI.
Returns
The current value of the property.
Exceptions
org.xml.sax.SAXNotRecognizedExceptionIf the property value can't be assigned or retrieved.
org.xml.sax.SAXNotSupportedExceptionWhen the XMLReader recognizes the property name but cannot determine its value at this time.
See also
setProperty

Implements javolution.xml.sax.XMLReader.

Definition at line 78 of file SAX2ReaderImpl.java.

79  {
80  return _parser.getProperty(name);
81  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.getProperty().

Here is the call graph for this function:

◆ parse() [1/2]

void javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
inputThe input source for the top-level of the XML document.
Exceptions
org.xml.sax.SAXExceptionAny SAX exception, possibly wrapping another exception.
j2me.io.IOExceptionAn IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
See also
org.xml.sax.InputSource
setEntityResolver
setDTDHandler
setContentHandler
setErrorHandler

Implements javolution.xml.sax.XMLReader.

Definition at line 136 of file SAX2ReaderImpl.java.

136  {
137  try {
138  _parser.parse(input);
139  } finally {
140  _parser.reset();
141  }
142  }

References javolution.xml.sax.SAX2ReaderImpl._parser, javolution.xml.sax.XMLReaderImpl.parse(), and javolution.xml.sax.XMLReaderImpl.reset().

Here is the call graph for this function:

◆ parse() [2/2]

void javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
systemIdThe system identifier (URI).
Exceptions
org.xml.sax.SAXExceptionAny SAX exception, possibly wrapping another exception.
j2me.io.IOExceptionAn IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
See also
parse(org.xml.sax.InputSource)

Implements javolution.xml.sax.XMLReader.

Definition at line 145 of file SAX2ReaderImpl.java.

145  {
146  try {
147  _parser.parse(systemId);
148  } finally {
149  _parser.reset();
150  }
151  }

References javolution.xml.sax.SAX2ReaderImpl._parser, javolution.xml.sax.XMLReaderImpl.parse(), and javolution.xml.sax.XMLReaderImpl.reset().

Here is the call graph for this function:

◆ reset()

void javolution.xml.sax.SAX2ReaderImpl.reset ( )

Definition at line 154 of file SAX2ReaderImpl.java.

154  {
155  _parser.reset();
156  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.reset().

Here is the call graph for this function:

◆ setContentHandler()

void javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
handlerThe content handler.
See also
getContentHandler

Implements javolution.xml.sax.XMLReader.

Definition at line 110 of file SAX2ReaderImpl.java.

110  {
111  if (handler != null) {
112  _proxy._sax2Handler = handler;
114  } else {
115  throw new NullPointerException();
116  }
117  }

References javolution.xml.sax.SAX2ReaderImpl._parser, javolution.xml.sax.SAX2ReaderImpl._proxy, javolution.xml.sax.SAX2ReaderImpl.Proxy._sax2Handler, and javolution.xml.sax.XMLReaderImpl.setContentHandler().

Here is the call graph for this function:

◆ setDTDHandler()

void javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
handlerThe DTD handler.
See also
getDTDHandler

Implements javolution.xml.sax.XMLReader.

Definition at line 100 of file SAX2ReaderImpl.java.

100  {
101  _parser.setDTDHandler(handler);
102  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.setDTDHandler().

Here is the call graph for this function:

◆ setEntityResolver()

void javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
resolverThe entity resolver.
See also
getEntityResolver

Implements javolution.xml.sax.XMLReader.

Definition at line 90 of file SAX2ReaderImpl.java.

90  {
91  _parser.setEntityResolver(resolver);
92  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.setEntityResolver().

Here is the call graph for this function:

◆ setErrorHandler()

void javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
handlerThe error handler.
See also
getErrorHandler

Implements javolution.xml.sax.XMLReader.

Definition at line 126 of file SAX2ReaderImpl.java.

126  {
127  _parser.setErrorHandler(handler);
128  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.setErrorHandler().

Here is the call graph for this function:

◆ setFeature()

void javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
nameThe feature name, which is a fully-qualified URI.
valueThe requested value of the feature (true or false).
Exceptions
org.xml.sax.SAXNotRecognizedExceptionIf the feature value can't be assigned or retrieved.
org.xml.sax.SAXNotSupportedExceptionWhen the XMLReader recognizes the feature name but cannot set the requested value.
See also
getFeature

Implements javolution.xml.sax.XMLReader.

Definition at line 72 of file SAX2ReaderImpl.java.

73  {
74  _parser.setFeature(name, value);
75  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.setFeature().

Here is the call graph for this function:

◆ setProperty()

void javolution.xml.sax.SAX2ReaderImpl.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.

Parameters
nameThe property name, which is a fully-qualified URI.
valueThe requested value for the property.
Exceptions
org.xml.sax.SAXNotRecognizedExceptionIf the property value can't be assigned or retrieved.
org.xml.sax.SAXNotSupportedExceptionWhen the XMLReader recognizes the property name but cannot set the requested value.

Implements javolution.xml.sax.XMLReader.

Definition at line 84 of file SAX2ReaderImpl.java.

85  {
86  _parser.setProperty(name, value);
87  }

References javolution.xml.sax.SAX2ReaderImpl._parser, and javolution.xml.sax.XMLReaderImpl.setProperty().

Here is the call graph for this function:

◆ toCharSequence()

static CharSequence javolution.xml.sax.SAX2ReaderImpl.toCharSequence ( Object  obj)
staticprivate

Definition at line 381 of file SAX2ReaderImpl.java.

381  {
382  return obj instanceof CharSequence ? (CharSequence) obj : Text
383  .valueOf(obj);
384  }

Referenced by javolution.xml.sax.SAX2ReaderImpl.Proxy.getIndex(), javolution.xml.sax.SAX2ReaderImpl.Proxy.getType(), and javolution.xml.sax.SAX2ReaderImpl.Proxy.getValue().

Here is the caller graph for this function:

Member Data Documentation

◆ _parser

◆ _proxy

final Proxy javolution.xml.sax.SAX2ReaderImpl._proxy = new Proxy()
private

Holds the content handler proxy.

Definition at line 58 of file SAX2ReaderImpl.java.

Referenced by javolution.xml.sax.SAX2ReaderImpl.getContentHandler(), and javolution.xml.sax.SAX2ReaderImpl.setContentHandler().

◆ DEFAULT_HANDLER

Sax2DefaultHandler javolution.xml.sax.SAX2ReaderImpl.DEFAULT_HANDLER = new Sax2DefaultHandler()
staticprivate

Holds the SAX2 default handler instance.

Definition at line 48 of file SAX2ReaderImpl.java.

Referenced by javolution.xml.sax.SAX2ReaderImpl.Proxy.endDocument(), and javolution.xml.sax.SAX2ReaderImpl.getContentHandler().


The documentation for this class was generated from the following file:
javolution.xml.sax.XMLReaderImpl.parse
void parse(InputStream in)
Definition: XMLReaderImpl.java:90
javolution.xml.sax.XMLReaderImpl.setContentHandler
void setContentHandler(ContentHandler handler)
Definition: XMLReaderImpl.java:186
javolution.xml.sax.XMLReaderImpl.getDTDHandler
DTDHandler getDTDHandler()
Definition: XMLReaderImpl.java:266
javolution.xml.sax.XMLReaderImpl.setDTDHandler
void setDTDHandler(DTDHandler handler)
Definition: XMLReaderImpl.java:260
javolution.xml.sax.XMLReaderImpl.getErrorHandler
ErrorHandler getErrorHandler()
Definition: XMLReaderImpl.java:209
javolution.xml.sax.XMLReaderImpl.getProperty
Object getProperty(String name)
Definition: XMLReaderImpl.java:238
javolution.xml.sax.XMLReaderImpl.setEntityResolver
void setEntityResolver(EntityResolver resolver)
Definition: XMLReaderImpl.java:250
javolution.xml.sax.XMLReaderImpl.setFeature
void setFeature(String name, boolean value)
Definition: XMLReaderImpl.java:227
javolution.xml.sax.XMLReaderImpl.setProperty
void setProperty(String name, Object value)
Definition: XMLReaderImpl.java:244
javolution.xml.sax.XMLReaderImpl.getEntityResolver
EntityResolver getEntityResolver()
Definition: XMLReaderImpl.java:256
javolution.xml.sax.SAX2ReaderImpl._parser
final XMLReaderImpl _parser
Definition: SAX2ReaderImpl.java:53
javolution.xml.sax.SAX2ReaderImpl.Proxy._sax2Handler
ContentHandler _sax2Handler
Definition: SAX2ReaderImpl.java:167
javolution.xml.sax.XMLReaderImpl.getFeature
boolean getFeature(String name)
Definition: XMLReaderImpl.java:214
javolution.xml.sax.XMLReaderImpl.reset
void reset()
Definition: XMLReaderImpl.java:271
javolution.xml.sax.SAX2ReaderImpl._proxy
final Proxy _proxy
Definition: SAX2ReaderImpl.java:58
javolution.xml.sax.XMLReaderImpl.setErrorHandler
void setErrorHandler(ErrorHandler handler)
Definition: XMLReaderImpl.java:200
javolution.xml.sax.SAX2ReaderImpl.DEFAULT_HANDLER
static Sax2DefaultHandler DEFAULT_HANDLER
Definition: SAX2ReaderImpl.java:48