org.cyberneko.pull.parsers
Class Xerces2

java.lang.Object
  extended byorg.cyberneko.pull.parsers.Xerces2
All Implemented Interfaces:
org.apache.xerces.xni.parser.XMLComponentManager, XMLEventIterator, XMLPullParser

public class Xerces2
extends java.lang.Object
implements XMLPullParser

An implementation of a pull parser that can use any standard XNI parser configuration as a driver.

Note: This class is provided for convenience. However, for the best performance, a parser should be implemented directly to the NekoPull interfaces to provide pull parsing functionality.

Version:
$Id: Xerces2.java,v 1.3 2004/03/31 20:00:21 andyc Exp $
Author:
Andy Clark

Field Summary
protected  org.apache.xerces.xni.parser.XMLPullParserConfiguration fConfiguration
          XNI pull parser configuration.
protected  boolean fDone
          Finished parsing.
protected  EventCollector fEventCollector
          Event collector.
protected static java.lang.String REUSE_BUFFERS
          Feature identifer: reuse buffers.
 
Constructor Summary
Xerces2()
          Constructs a pull parser with the standard configuration.
Xerces2(org.apache.xerces.xni.parser.XMLPullParserConfiguration config)
          Constructs a pull parser with the specified configuration.
 
Method Summary
 void cleanup()
          If the application decides to terminate parsing before the xml document is fully parsed, the application should call this method to free any resource allocated during parsing.
 org.apache.xerces.xni.parser.XMLEntityResolver getEntityResolver()
          Returns the registered entity resolver.
 org.apache.xerces.xni.parser.XMLErrorHandler getErrorHandler()
          Returns the registered error handler.
 boolean getFeature(java.lang.String featureId)
          Returns the state of a feature.
 java.util.Locale getLocale()
          Returns the locale.
 java.lang.Object getProperty(java.lang.String propertyId)
          Returns the value of a property.
 XMLEvent nextEvent()
          Returns the next event in the document or null if there are no more events.
 void setEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)
          Sets the entity resolver.
 void setErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler errorHandler)
          Sets the error handler.
 void setFeature(java.lang.String featureId, boolean state)
          Sets the state of a feature.
 void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
          Sets the input source for the document to parse.
 void setLocale(java.util.Locale locale)
          Set the locale to use for messages.
 void setProperty(java.lang.String propertyId, java.lang.Object value)
          Sets the value of a property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REUSE_BUFFERS

protected static final java.lang.String REUSE_BUFFERS
Feature identifer: reuse buffers.

See Also:
Constant Field Values

fDone

protected boolean fDone
Finished parsing.


fConfiguration

protected org.apache.xerces.xni.parser.XMLPullParserConfiguration fConfiguration
XNI pull parser configuration.


fEventCollector

protected EventCollector fEventCollector
Event collector.

Constructor Detail

Xerces2

public Xerces2()
Constructs a pull parser with the standard configuration.


Xerces2

public Xerces2(org.apache.xerces.xni.parser.XMLPullParserConfiguration config)
Constructs a pull parser with the specified configuration.

Method Detail

setInputSource

public void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
                    throws org.apache.xerces.xni.parser.XMLConfigurationException,
                           java.io.IOException
Sets the input source for the document to parse.

Specified by:
setInputSource in interface XMLPullParser
Parameters:
inputSource - The document's input source.
Throws:
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown if there is a configuration error when initializing the parser.
java.io.IOException - Thrown on I/O error.
See Also:
nextEvent()

cleanup

public void cleanup()
If the application decides to terminate parsing before the xml document is fully parsed, the application should call this method to free any resource allocated during parsing. For example, close all opened streams.

Specified by:
cleanup in interface XMLPullParser

setFeature

public void setFeature(java.lang.String featureId,
                       boolean state)
                throws org.apache.xerces.xni.parser.XMLConfigurationException
Sets the state of a feature. This method is called by the parser and gets propagated to components in this parser configuration.

Specified by:
setFeature in interface XMLPullParser
Parameters:
featureId - The feature identifier.
state - The state of the feature.
Throws:
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown if there is a configuration error.

setProperty

public void setProperty(java.lang.String propertyId,
                        java.lang.Object value)
                 throws org.apache.xerces.xni.parser.XMLConfigurationException
Sets the value of a property. This method is called by the parser and gets propagated to components in this parser configuration.

Specified by:
setProperty in interface XMLPullParser
Parameters:
propertyId - The property identifier.
value - The value of the property.
Throws:
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown if there is a configuration error.

nextEvent

public XMLEvent nextEvent()
                   throws org.apache.xerces.xni.XNIException,
                          java.io.IOException
Returns the next event in the document or null if there are no more events. This method will return one and only one event if it is available; it will never return an event chain (i.e. an event with a non-null next field).

Specified by:
nextEvent in interface XMLPullParser
Throws:
org.apache.xerces.xni.XNIException - Any XNI 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 parser.
See Also:
setInputSource(org.apache.xerces.xni.parser.XMLInputSource)

getFeature

public boolean getFeature(java.lang.String featureId)
                   throws org.apache.xerces.xni.parser.XMLConfigurationException
Returns the state of a feature.

Specified by:
getFeature in interface XMLPullParser
Parameters:
featureId - The feature identifier.
Throws:
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown if there is a configuration error.

getProperty

public java.lang.Object getProperty(java.lang.String propertyId)
                             throws org.apache.xerces.xni.parser.XMLConfigurationException
Returns the value of a property.

Specified by:
getProperty in interface XMLPullParser
Parameters:
propertyId - The property identifier.
Throws:
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown if there is a configuration error.

setErrorHandler

public void setErrorHandler(org.apache.xerces.xni.parser.XMLErrorHandler errorHandler)
Sets the error handler.

Specified by:
setErrorHandler in interface XMLPullParser
Parameters:
errorHandler - The error resolver.

getErrorHandler

public org.apache.xerces.xni.parser.XMLErrorHandler getErrorHandler()
Returns the registered error handler.

Specified by:
getErrorHandler in interface XMLPullParser

setEntityResolver

public void setEntityResolver(org.apache.xerces.xni.parser.XMLEntityResolver entityResolver)
Sets the entity resolver.

Specified by:
setEntityResolver in interface XMLPullParser
Parameters:
entityResolver - The new entity resolver.

getEntityResolver

public org.apache.xerces.xni.parser.XMLEntityResolver getEntityResolver()
Returns the registered entity resolver.

Specified by:
getEntityResolver in interface XMLPullParser

setLocale

public void setLocale(java.util.Locale locale)
               throws org.apache.xerces.xni.XNIException
Set the locale to use for messages.

Specified by:
setLocale in interface XMLPullParser
Parameters:
locale - The locale object to use for localization of messages.
Throws:
org.apache.xerces.xni.XNIException - Thrown if the parser does not support the specified locale.

getLocale

public java.util.Locale getLocale()
Returns the locale.

Specified by:
getLocale in interface XMLPullParser


(C) Copyright 2002-2004, Andy Clark. All rights reserved.