org.apache.crimson.parser
Class XMLReaderImpl

java.lang.Object
  extended byorg.apache.crimson.parser.XMLReaderImpl
All Implemented Interfaces:
org.xml.sax.XMLReader

public class XMLReaderImpl
extends Object
implements org.xml.sax.XMLReader

This implements the SAX2 XMLReader.

Author:
Rajiv Mordani, Edwin Goei

Field Summary
private  org.xml.sax.ContentHandler contentHandler
           
private static String DECLARATION_HANDLER
           
private  org.xml.sax.ext.DeclHandler declHandler
           
private  org.xml.sax.DTDHandler dtdHandler
           
private  org.xml.sax.EntityResolver entityResolver
           
private  org.xml.sax.ErrorHandler errorHandler
           
private static String EXTERNAL_GENERAL
           
private static String EXTERNAL_PARAMETER
           
private static String FEATURES
           
private static String LEXICAL_HANDLER
           
private static String LEXICAL_PARAMETER_ENTITIES
           
private  org.xml.sax.ext.LexicalHandler lexicalHandler
           
private static String NAMESPACE_PREFIXES
           
private  boolean namespaces
           
private static String NAMESPACES
           
private  Parser2 parser
           
private  boolean parsing
           
private  boolean prefixes
           
private static String PROPERTIES
           
private static String STRING_INTERNING
           
private  boolean validation
           
private static String VALIDATION
           
 
Constructor Summary
XMLReaderImpl()
          Default constructor is explicitly declared here
 
Method Summary
private  void checkNotParsing(String type, String name)
          Throw an exception if we are parsing.
 org.xml.sax.ContentHandler getContentHandler()
          Return the current content handler.
 org.xml.sax.DTDHandler getDTDHandler()
          Return the current DTD handler.
 org.xml.sax.EntityResolver getEntityResolver()
          Return the current entity resolver.
 org.xml.sax.ErrorHandler getErrorHandler()
          Return the current error handler.
 boolean getFeature(String name)
          Check a parser feature.
 Object getProperty(String name)
          Get a parser property.
 void parse(org.xml.sax.InputSource input)
          Parse an XML document.
 void parse(String systemId)
          Parse an XML document.
 void setContentHandler(org.xml.sax.ContentHandler handler)
          Set the content handler.
 void setDTDHandler(org.xml.sax.DTDHandler handler)
          Set the DTD handler.
 void setEntityResolver(org.xml.sax.EntityResolver resolver)
          Set the entity resolver.
 void setErrorHandler(org.xml.sax.ErrorHandler handler)
          Set the error handler.
 void setFeature(String name, boolean state)
          Set a feature for the parser.
 void setProperty(String name, Object value)
          Set a parser property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FEATURES

private static final String FEATURES
See Also:
Constant Field Values

NAMESPACES

private static final String NAMESPACES
See Also:
Constant Field Values

NAMESPACE_PREFIXES

private static final String NAMESPACE_PREFIXES
See Also:
Constant Field Values

STRING_INTERNING

private static final String STRING_INTERNING
See Also:
Constant Field Values

VALIDATION

private static final String VALIDATION
See Also:
Constant Field Values

EXTERNAL_GENERAL

private static final String EXTERNAL_GENERAL
See Also:
Constant Field Values

EXTERNAL_PARAMETER

private static final String EXTERNAL_PARAMETER
See Also:
Constant Field Values

LEXICAL_PARAMETER_ENTITIES

private static final String LEXICAL_PARAMETER_ENTITIES
See Also:
Constant Field Values

PROPERTIES

private static final String PROPERTIES
See Also:
Constant Field Values

LEXICAL_HANDLER

private static final String LEXICAL_HANDLER
See Also:
Constant Field Values

DECLARATION_HANDLER

private static final String DECLARATION_HANDLER
See Also:
Constant Field Values

namespaces

private boolean namespaces

prefixes

private boolean prefixes

validation

private boolean validation

lexicalHandler

private org.xml.sax.ext.LexicalHandler lexicalHandler

declHandler

private org.xml.sax.ext.DeclHandler declHandler

contentHandler

private org.xml.sax.ContentHandler contentHandler

dtdHandler

private org.xml.sax.DTDHandler dtdHandler

errorHandler

private org.xml.sax.ErrorHandler errorHandler

entityResolver

private org.xml.sax.EntityResolver entityResolver

parser

private Parser2 parser

parsing

private boolean parsing
Constructor Detail

XMLReaderImpl

public XMLReaderImpl()
Default constructor is explicitly declared here

Method Detail

getFeature

public boolean getFeature(String name)
                   throws org.xml.sax.SAXNotRecognizedException,
                          org.xml.sax.SAXNotSupportedException
Check a parser feature.

Specified by:
getFeature in interface org.xml.sax.XMLReader
Parameters:
name - The feature name, as a complete URI.
Returns:
The current feature state.
Throws:
org.xml.sax.SAXNotRecognizedException - If the feature name is not known.
org.xml.sax.SAXNotSupportedException - If querying the feature state is not supported.
See Also:
XMLReader.setFeature(java.lang.String, boolean)

setFeature

public void setFeature(String name,
                       boolean state)
                throws org.xml.sax.SAXNotRecognizedException,
                       org.xml.sax.SAXNotSupportedException
Set a feature for the parser.

Specified by:
setFeature in interface org.xml.sax.XMLReader
Parameters:
name - The feature name, as a complete URI.
state - The requested feature state.
Throws:
org.xml.sax.SAXNotRecognizedException - If the feature name is not known.
org.xml.sax.SAXNotSupportedException - If the feature state is not supported.
See Also:
XMLReader.getFeature(java.lang.String)

getProperty

public Object getProperty(String name)
                   throws org.xml.sax.SAXNotRecognizedException,
                          org.xml.sax.SAXNotSupportedException
Get a parser property.

Specified by:
getProperty in interface org.xml.sax.XMLReader
Parameters:
name - The property name.
Returns:
The property value.
Throws:
org.xml.sax.SAXNotRecognizedException - If the feature name is not known.
org.xml.sax.SAXNotSupportedException - If the feature state is not supported.
See Also:
XMLReader.getProperty(java.lang.String)

setProperty

public void setProperty(String name,
                        Object value)
                 throws org.xml.sax.SAXNotRecognizedException,
                        org.xml.sax.SAXNotSupportedException
Set a parser property.

Specified by:
setProperty in interface org.xml.sax.XMLReader
Parameters:
name - The property name.
value - The property value.
Throws:
org.xml.sax.SAXNotRecognizedException - If the feature name is not known.
org.xml.sax.SAXNotSupportedException - If the feature state is not supported.
See Also:
XMLReader.getProperty(java.lang.String)

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Set the entity resolver.

Specified by:
setEntityResolver in interface org.xml.sax.XMLReader
Parameters:
resolver - The new entity resolver.
Throws:
NullPointerException - If the entity resolver parameter is null.
See Also:
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Return the current entity resolver.

Specified by:
getEntityResolver in interface org.xml.sax.XMLReader
Returns:
The current entity resolver, or null if none was supplied.
See Also:
XMLReader.getEntityResolver()

setDTDHandler

public void setDTDHandler(org.xml.sax.DTDHandler handler)
Set the DTD handler.

Specified by:
setDTDHandler in interface org.xml.sax.XMLReader
Throws:
NullPointerException - If the DTD handler parameter is null.
See Also:
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)

getDTDHandler

public org.xml.sax.DTDHandler getDTDHandler()
Return the current DTD handler.

Specified by:
getDTDHandler in interface org.xml.sax.XMLReader
Returns:
The current DTD handler, or null if none was supplied.
See Also:
XMLReader.getEntityResolver()

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler handler)
Set the content handler.

Specified by:
setContentHandler in interface org.xml.sax.XMLReader
Throws:
NullPointerException - If the content handler parameter is null.
See Also:
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)

getContentHandler

public org.xml.sax.ContentHandler getContentHandler()
Return the current content handler.

Specified by:
getContentHandler in interface org.xml.sax.XMLReader
Returns:
The current content handler, or null if none was supplied.
See Also:
XMLReader.getEntityResolver()

setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler handler)
Set the error handler.

Specified by:
setErrorHandler in interface org.xml.sax.XMLReader
Throws:
NullPointerException - If the error handler parameter is null.
See Also:
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)

getErrorHandler

public org.xml.sax.ErrorHandler getErrorHandler()
Return the current error handler.

Specified by:
getErrorHandler in interface org.xml.sax.XMLReader
Returns:
The current error handler, or null if none was supplied.
See Also:
XMLReader.getEntityResolver()

parse

public void parse(String systemId)
           throws IOException,
                  org.xml.sax.SAXException
Parse an XML document.

Specified by:
parse in interface org.xml.sax.XMLReader
Parameters:
systemId - The absolute URL of the document.
Throws:
IOException - If there is a problem reading the raw content of the document.
org.xml.sax.SAXException - If there is a problem processing the document.
See Also:
parse(org.xml.sax.InputSource), Parser.parse(java.lang.String)

parse

public void parse(org.xml.sax.InputSource input)
           throws IOException,
                  org.xml.sax.SAXException
Parse an XML document.

Specified by:
parse in interface org.xml.sax.XMLReader
Parameters:
input - An input source for the document.
Throws:
IOException - If there is a problem reading the raw content of the document.
org.xml.sax.SAXException - If there is a problem processing the document.
See Also:
parse(java.lang.String), Parser.parse(org.xml.sax.InputSource)

checkNotParsing

private void checkNotParsing(String type,
                             String name)
                      throws org.xml.sax.SAXNotSupportedException
Throw an exception if we are parsing.

Use this method to detect illegal feature or property changes.

Parameters:
type - The type of thing (feature or property).
name - The feature or property name.
Throws:
org.xml.sax.SAXNotSupportedException - If a document is currently being parsed.