Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.xerces.readers
Class DefaultEntityHandler  view DefaultEntityHandler download DefaultEntityHandler.java

java.lang.Object
  extended byorg.apache.xerces.readers.DefaultEntityHandler
All Implemented Interfaces:
org.xml.sax.Locator, XMLEntityHandler, XMLEntityHandler.DTDHandler

public class DefaultEntityHandler
extends java.lang.Object
implements XMLEntityHandler, XMLEntityHandler.DTDHandler

Default entity handler implementation.

Version:
$Id: DefaultEntityHandler.java,v 1.2 2000/10/07 18:06:55 markd Exp $

Nested Class Summary
 class DefaultEntityHandler.EntityPool
           
static interface DefaultEntityHandler.EventHandler
           
private  class DefaultEntityHandler.NullReader
           
private  class DefaultEntityHandler.ReaderState
           
 
Nested classes inherited from class org.apache.xerces.readers.XMLEntityHandler
XMLEntityHandler.CharBuffer, XMLEntityHandler.CharDataHandler, XMLEntityHandler.DTDHandler, XMLEntityHandler.EntityReader
 
Field Summary
(package private) static int CHUNK_MASK
           
(package private) static int CHUNK_SHIFT
           
(package private) static int CHUNK_SIZE
           
private  XMLEntityHandler.CharDataHandler fCharDataHandler
           
private  int fEntityContext
           
private  int fEntityName
           
private  int[] fEntityNameStack
           
private  DefaultEntityHandler.EntityPool fEntityPool
           
private  int fEntityStackDepth
           
private  int fEntityType
           
private  byte[] fEntityTypeStack
           
private  org.apache.xerces.framework.XMLErrorReporter fErrorReporter
           
private  DefaultEntityHandler.EventHandler fEventHandler
           
private  int fNextReaderId
           
private  DefaultEntityHandler.NullReader fNullReader
           
private  DefaultEntityHandler.EntityPool fParameterEntityPool
           
private  java.lang.String fPublicId
           
private  XMLEntityHandler.EntityReader fReader
           
private  int fReaderDepth
           
protected  XMLEntityReaderFactory fReaderFactory
           
private  int fReaderId
           
private  java.util.Stack fReaderStack
           
private  DefaultEntityHandler.ReaderState fReaderStateFreeList
           
private  org.xml.sax.EntityResolver fResolver
           
private  boolean fSendCharDataAsCharArray
           
private  org.xml.sax.InputSource fSource
           
private  org.apache.xerces.utils.StringPool fStringPool
           
private  java.lang.String fSystemId
           
(package private) static int INITIAL_CHUNK_COUNT
           
 
Fields inherited from interface org.apache.xerces.readers.XMLEntityHandler
ATTVALUE_RESULT_COMPLEX, ATTVALUE_RESULT_INVALID_CHAR, ATTVALUE_RESULT_LESSTHAN, CHARREF_RESULT_INVALID_CHAR, CHARREF_RESULT_OUT_OF_RANGE, CHARREF_RESULT_SEMICOLON_REQUIRED, CONTENT_RESULT_END_OF_CDSECT, CONTENT_RESULT_INVALID_CHAR, CONTENT_RESULT_MARKUP_END_OF_INPUT, CONTENT_RESULT_MARKUP_NOT_RECOGNIZED, CONTENT_RESULT_MATCHING_ETAG, CONTENT_RESULT_REFERENCE_END_OF_INPUT, CONTENT_RESULT_START_OF_CDSECT, CONTENT_RESULT_START_OF_CHARREF, CONTENT_RESULT_START_OF_COMMENT, CONTENT_RESULT_START_OF_ELEMENT, CONTENT_RESULT_START_OF_ENTITYREF, CONTENT_RESULT_START_OF_ETAG, CONTENT_RESULT_START_OF_PI, ENTITYREF_DOCUMENT, ENTITYREF_EXTERNAL_SUBSET, ENTITYREF_IN_ATTVALUE, ENTITYREF_IN_CONTENT, ENTITYREF_IN_DEFAULTATTVALUE, ENTITYREF_IN_DTD_AS_MARKUP, ENTITYREF_IN_DTD_WITHIN_MARKUP, ENTITYREF_IN_ENTITYVALUE, ENTITYTYPE_DOCUMENT, ENTITYTYPE_EXTERNAL, ENTITYTYPE_EXTERNAL_PE, ENTITYTYPE_EXTERNAL_SUBSET, ENTITYTYPE_INTERNAL, ENTITYTYPE_INTERNAL_PE, ENTITYTYPE_UNPARSED, ENTITYVALUE_RESULT_END_OF_INPUT, ENTITYVALUE_RESULT_FINISHED, ENTITYVALUE_RESULT_INVALID_CHAR, ENTITYVALUE_RESULT_PEREF, ENTITYVALUE_RESULT_REFERENCE, STRINGLIT_RESULT_INVALID_CHAR, STRINGLIT_RESULT_QUOTE_REQUIRED
 
Constructor Summary
DefaultEntityHandler(org.apache.xerces.utils.StringPool stringPool, org.apache.xerces.framework.XMLErrorReporter errorReporter)
           
 
Method Summary
 int addExternalEntityDecl(int name, int publicId, int systemId, boolean isExternal)
           
 int addExternalPEDecl(int name, int publicId, int systemId, boolean isExternal)
           
 int addInternalEntityDecl(int name, int value, boolean isExternal)
           
 int addInternalPEDecl(int name, int value, boolean isExternal)
          Declare entities and notations.
 int addNotationDecl(int notationName, int publicId, int systemId, boolean isExternal)
           
 void addRecognizer(XMLDeclRecognizer recognizer)
          Adds a recognizer.
 void addRequiredNotation(int notationName, org.xml.sax.Locator locator, int majorCode, int minorCode, java.lang.Object[] args)
          Remember a required but undeclared notation.
 int addUnparsedEntityDecl(int name, int publicId, int systemId, int notationName, boolean isExternal)
           
 XMLEntityHandler.EntityReader changeReaders()
          This method is called by the reader subclasses at the end of input, and also by the scanner directly to force a reader change during error recovery.
 void checkRequiredNotations()
          Check required but undeclared notations.
 void endEntityDecl()
          end an entity declaration
private  java.lang.String entityReferencePath(boolean isPE, int entityName)
           
 java.lang.String expandSystemId(java.lang.String systemId)
          Expands a system id and returns the system id as a URI, if it can be expanded.
private  java.lang.String expandSystemId(java.lang.String systemId, java.lang.String currentSystemId)
           
 boolean externalReferenceInContent(int entityHandle)
           
private static java.lang.String fixURI(java.lang.String str)
          Fixes a platform dependent filename to standard URI form.
 boolean getAllowJavaEncodings()
           
 XMLEntityHandler.CharDataHandler getCharDataHandler()
          Get the character data handler.
 int getColumnNumber()
          Return the column number of the current position within the document that we are processing.
 XMLEntityHandler.EntityReader getEntityReader()
          get the Entity reader.
 org.xml.sax.EntityResolver getEntityResolver()
          Gets the resolver used to resolve external entities.
protected  int getEntityValue(int entityHandle)
           
 int getLineNumber()
          Return the line number of the current position within the document that we are processing.
protected  int getParameterEntityValue(int peIndex)
           
 java.lang.String getPublicId()
          Return the public identifier of the InputSource that we are processing.
protected  java.lang.String getPublicIdOfEntity(int entityHandle)
           
protected  java.lang.String getPublicIdOfParameterEntity(int peIndex)
           
 int getReaderDepth()
          This method is provided for scanner implementations.
 int getReaderId()
          This method is provided for scanner implementations.
 java.lang.String getSystemId()
          Return the system identifier of the InputSource that we are processing.
protected  java.lang.String getSystemIdOfEntity(int entityHandle)
           
protected  java.lang.String getSystemIdOfParameterEntity(int peIndex)
           
protected  boolean isExternalEntity(int entityHandle)
           
protected  boolean isExternalParameterEntity(int peIndex)
           
 boolean isNotationDeclared(int notationName)
          Check for declared notation.
 boolean isUnparsedEntity(int entityName)
          Check for unparsed entity.
protected  int lookupEntity(int entityNameIndex)
           
protected  int lookupParameterEntity(int peName)
           
private  void popEntity()
           
private  void popReader()
           
private  boolean pushEntity(boolean isPE, int entityName)
           
private  void pushNullReader()
           
private  void pushReader()
           
private  void reportRecoverableXMLError(int majorCode, int minorCode, int stringIndex1)
           
 void reset(org.apache.xerces.utils.StringPool stringPool)
          Reset the entity handler.
 void setAllowJavaEncodings(boolean flag)
           
 void setCharDataHandler(XMLEntityHandler.CharDataHandler charDataHandler)
          Set the character data handler.
 void setEntityResolver(org.xml.sax.EntityResolver resolver)
          Sets the resolver used to resolve external entities.
 void setEventHandler(DefaultEntityHandler.EventHandler eventHandler)
           
 void setReaderDepth(int depth)
          This method is provided for scanner implementations.
 void setReaderFactory(XMLEntityReaderFactory readerFactory)
          Set the reader factory.
 void setSendCharDataAsCharArray(boolean flag)
          Set char data processing preference.
 boolean startEntityDecl(boolean isPE, int entityName)
          start an entity declaration
 boolean startReadingFromDocument(org.xml.sax.InputSource source)
          Start reading document from an InputSource.
 boolean startReadingFromEntity(int entityName, int readerDepth, int context)
          start reading from an external entity
private  boolean startReadingFromExternalEntity(boolean checkForTextDecl, int entityHandle)
           
 void startReadingFromExternalSubset(java.lang.String publicId, java.lang.String systemId, int readerDepth)
          start reading from an external DTD subset
private  void startReadingFromInternalEntity(int value, boolean addSpaces)
           
private  boolean startReadingFromParameterEntity(int peName, int readerDepth, int context)
           
 void stopReadingFromExternalSubset()
          stop reading from an external DTD subset
protected  int valueOfReferenceInAttValue(int entityHandle)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fReaderStateFreeList

private DefaultEntityHandler.ReaderState fReaderStateFreeList

fStringPool

private org.apache.xerces.utils.StringPool fStringPool

fEventHandler

private DefaultEntityHandler.EventHandler fEventHandler

fCharDataHandler

private XMLEntityHandler.CharDataHandler fCharDataHandler

fErrorReporter

private org.apache.xerces.framework.XMLErrorReporter fErrorReporter

fResolver

private org.xml.sax.EntityResolver fResolver

fEntityPool

private DefaultEntityHandler.EntityPool fEntityPool

fParameterEntityPool

private DefaultEntityHandler.EntityPool fParameterEntityPool

fEntityTypeStack

private byte[] fEntityTypeStack

fEntityNameStack

private int[] fEntityNameStack

fEntityStackDepth

private int fEntityStackDepth

fReaderStack

private java.util.Stack fReaderStack

fReader

private XMLEntityHandler.EntityReader fReader

fSource

private org.xml.sax.InputSource fSource

fEntityName

private int fEntityName

fEntityType

private int fEntityType

fEntityContext

private int fEntityContext

fPublicId

private java.lang.String fPublicId

fSystemId

private java.lang.String fSystemId

fReaderId

private int fReaderId

fReaderDepth

private int fReaderDepth

fNextReaderId

private int fNextReaderId

fNullReader

private DefaultEntityHandler.NullReader fNullReader

fReaderFactory

protected XMLEntityReaderFactory fReaderFactory

fSendCharDataAsCharArray

private boolean fSendCharDataAsCharArray

CHUNK_SHIFT

static final int CHUNK_SHIFT
See Also:
Constant Field Values

CHUNK_SIZE

static final int CHUNK_SIZE
See Also:
Constant Field Values

CHUNK_MASK

static final int CHUNK_MASK
See Also:
Constant Field Values

INITIAL_CHUNK_COUNT

static final int INITIAL_CHUNK_COUNT
See Also:
Constant Field Values
Constructor Detail

DefaultEntityHandler

public DefaultEntityHandler(org.apache.xerces.utils.StringPool stringPool,
                            org.apache.xerces.framework.XMLErrorReporter errorReporter)
Method Detail

setEventHandler

public void setEventHandler(DefaultEntityHandler.EventHandler eventHandler)

setCharDataHandler

public void setCharDataHandler(XMLEntityHandler.CharDataHandler charDataHandler)
Description copied from interface: XMLEntityHandler
Set the character data handler.

Specified by:
setCharDataHandler in interface XMLEntityHandler

getCharDataHandler

public XMLEntityHandler.CharDataHandler getCharDataHandler()
Description copied from interface: XMLEntityHandler
Get the character data handler.

Specified by:
getCharDataHandler in interface XMLEntityHandler

setSendCharDataAsCharArray

public void setSendCharDataAsCharArray(boolean flag)
Set char data processing preference.


setReaderFactory

public void setReaderFactory(XMLEntityReaderFactory readerFactory)
Set the reader factory.


reset

public void reset(org.apache.xerces.utils.StringPool stringPool)
Reset the entity handler.


setAllowJavaEncodings

public void setAllowJavaEncodings(boolean flag)

getAllowJavaEncodings

public boolean getAllowJavaEncodings()

addInternalPEDecl

public int addInternalPEDecl(int name,
                             int value,
                             boolean isExternal)
                      throws java.lang.Exception
Description copied from interface: XMLEntityHandler.DTDHandler
Declare entities and notations.

Specified by:
addInternalPEDecl in interface XMLEntityHandler.DTDHandler

addExternalPEDecl

public int addExternalPEDecl(int name,
                             int publicId,
                             int systemId,
                             boolean isExternal)
                      throws java.lang.Exception
Specified by:
addExternalPEDecl in interface XMLEntityHandler.DTDHandler

addInternalEntityDecl

public int addInternalEntityDecl(int name,
                                 int value,
                                 boolean isExternal)
                          throws java.lang.Exception
Specified by:
addInternalEntityDecl in interface XMLEntityHandler.DTDHandler

addExternalEntityDecl

public int addExternalEntityDecl(int name,
                                 int publicId,
                                 int systemId,
                                 boolean isExternal)
                          throws java.lang.Exception
Specified by:
addExternalEntityDecl in interface XMLEntityHandler.DTDHandler

addUnparsedEntityDecl

public int addUnparsedEntityDecl(int name,
                                 int publicId,
                                 int systemId,
                                 int notationName,
                                 boolean isExternal)
                          throws java.lang.Exception
Specified by:
addUnparsedEntityDecl in interface XMLEntityHandler.DTDHandler

addNotationDecl

public int addNotationDecl(int notationName,
                           int publicId,
                           int systemId,
                           boolean isExternal)
                    throws java.lang.Exception
Specified by:
addNotationDecl in interface XMLEntityHandler.DTDHandler

isUnparsedEntity

public boolean isUnparsedEntity(int entityName)
Description copied from interface: XMLEntityHandler.DTDHandler
Check for unparsed entity.

Specified by:
isUnparsedEntity in interface XMLEntityHandler.DTDHandler

isNotationDeclared

public boolean isNotationDeclared(int notationName)
Description copied from interface: XMLEntityHandler.DTDHandler
Check for declared notation.

Specified by:
isNotationDeclared in interface XMLEntityHandler.DTDHandler

addRequiredNotation

public void addRequiredNotation(int notationName,
                                org.xml.sax.Locator locator,
                                int majorCode,
                                int minorCode,
                                java.lang.Object[] args)
Description copied from interface: XMLEntityHandler.DTDHandler
Remember a required but undeclared notation.

Specified by:
addRequiredNotation in interface XMLEntityHandler.DTDHandler

checkRequiredNotations

public void checkRequiredNotations()
                            throws java.lang.Exception
Description copied from interface: XMLEntityHandler.DTDHandler
Check required but undeclared notations.

Specified by:
checkRequiredNotations in interface XMLEntityHandler.DTDHandler

lookupEntity

protected int lookupEntity(int entityNameIndex)

reportRecoverableXMLError

private void reportRecoverableXMLError(int majorCode,
                                       int minorCode,
                                       int stringIndex1)
                                throws java.lang.Exception

externalReferenceInContent

public boolean externalReferenceInContent(int entityHandle)
                                   throws java.lang.Exception

valueOfReferenceInAttValue

protected int valueOfReferenceInAttValue(int entityHandle)
                                  throws java.lang.Exception

isExternalEntity

protected boolean isExternalEntity(int entityHandle)

getEntityValue

protected int getEntityValue(int entityHandle)

getPublicIdOfEntity

protected java.lang.String getPublicIdOfEntity(int entityHandle)

getSystemIdOfEntity

protected java.lang.String getSystemIdOfEntity(int entityHandle)

lookupParameterEntity

protected int lookupParameterEntity(int peName)
                             throws java.lang.Exception

isExternalParameterEntity

protected boolean isExternalParameterEntity(int peIndex)

getParameterEntityValue

protected int getParameterEntityValue(int peIndex)

getPublicIdOfParameterEntity

protected java.lang.String getPublicIdOfParameterEntity(int peIndex)

getSystemIdOfParameterEntity

protected java.lang.String getSystemIdOfParameterEntity(int peIndex)

getEntityReader

public XMLEntityHandler.EntityReader getEntityReader()
get the Entity reader.

Specified by:
getEntityReader in interface XMLEntityHandler

addRecognizer

public void addRecognizer(XMLDeclRecognizer recognizer)
Adds a recognizer.


setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Sets the resolver used to resolve external entities. The EntityResolver interface supports resolution of public and system identifiers.


getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Gets the resolver used to resolve external entities. The EntityResolver interface supports resolution of public and system identifiers.


expandSystemId

public java.lang.String expandSystemId(java.lang.String systemId)
Expands a system id and returns the system id as a URI, if it can be expanded. A return value of null means that the identifier is already expanded. An exception thrown indicates a failure to expand the id.

Specified by:
expandSystemId in interface XMLEntityHandler

expandSystemId

private java.lang.String expandSystemId(java.lang.String systemId,
                                        java.lang.String currentSystemId)

fixURI

private static java.lang.String fixURI(java.lang.String str)
Fixes a platform dependent filename to standard URI form.


startReadingFromDocument

public boolean startReadingFromDocument(org.xml.sax.InputSource source)
                                 throws java.lang.Exception
Description copied from interface: XMLEntityHandler
Start reading document from an InputSource.

Specified by:
startReadingFromDocument in interface XMLEntityHandler

startReadingFromExternalSubset

public void startReadingFromExternalSubset(java.lang.String publicId,
                                           java.lang.String systemId,
                                           int readerDepth)
                                    throws java.lang.Exception
start reading from an external DTD subset

Specified by:
startReadingFromExternalSubset in interface XMLEntityHandler.DTDHandler

stopReadingFromExternalSubset

public void stopReadingFromExternalSubset()
                                   throws java.lang.Exception
stop reading from an external DTD subset

Specified by:
stopReadingFromExternalSubset in interface XMLEntityHandler.DTDHandler

startReadingFromEntity

public boolean startReadingFromEntity(int entityName,
                                      int readerDepth,
                                      int context)
                               throws java.lang.Exception
start reading from an external entity

Specified by:
startReadingFromEntity in interface XMLEntityHandler

startReadingFromParameterEntity

private boolean startReadingFromParameterEntity(int peName,
                                                int readerDepth,
                                                int context)
                                         throws java.lang.Exception

startReadingFromInternalEntity

private void startReadingFromInternalEntity(int value,
                                            boolean addSpaces)
                                     throws java.lang.Exception

startReadingFromExternalEntity

private boolean startReadingFromExternalEntity(boolean checkForTextDecl,
                                               int entityHandle)
                                        throws java.lang.Exception

pushNullReader

private void pushNullReader()

pushReader

private void pushReader()

popReader

private void popReader()

startEntityDecl

public boolean startEntityDecl(boolean isPE,
                               int entityName)
                        throws java.lang.Exception
start an entity declaration

Specified by:
startEntityDecl in interface XMLEntityHandler.DTDHandler

endEntityDecl

public void endEntityDecl()
                   throws java.lang.Exception
end an entity declaration

Specified by:
endEntityDecl in interface XMLEntityHandler.DTDHandler

pushEntity

private boolean pushEntity(boolean isPE,
                           int entityName)
                    throws java.lang.Exception

entityReferencePath

private java.lang.String entityReferencePath(boolean isPE,
                                             int entityName)

popEntity

private void popEntity()
                throws java.lang.Exception

getReaderId

public int getReaderId()
This method is provided for scanner implementations.

Specified by:
getReaderId in interface XMLEntityHandler

setReaderDepth

public void setReaderDepth(int depth)
This method is provided for scanner implementations.

Specified by:
setReaderDepth in interface XMLEntityHandler

getReaderDepth

public int getReaderDepth()
This method is provided for scanner implementations.

Specified by:
getReaderDepth in interface XMLEntityHandler

getPublicId

public java.lang.String getPublicId()
Return the public identifier of the InputSource that we are processing.

Specified by:
getPublicId in interface org.xml.sax.Locator

getSystemId

public java.lang.String getSystemId()
Return the system identifier of the InputSource that we are processing.

Specified by:
getSystemId in interface org.xml.sax.Locator

getLineNumber

public int getLineNumber()
Return the line number of the current position within the document that we are processing.

Specified by:
getLineNumber in interface org.xml.sax.Locator

getColumnNumber

public int getColumnNumber()
Return the column number of the current position within the document that we are processing.

Specified by:
getColumnNumber in interface org.xml.sax.Locator

changeReaders

public XMLEntityHandler.EntityReader changeReaders()
                                            throws java.lang.Exception
This method is called by the reader subclasses at the end of input, and also by the scanner directly to force a reader change during error recovery.

Specified by:
changeReaders in interface XMLEntityHandler