| |
|
| java.lang.Object com.sun.xml.stream.XMLEntityManager
XMLEntityManager | public class XMLEntityManager implements XMLComponent,XMLEntityResolver(Code) | | Will keep track of current entity.
The entity manager handles the registration of general and parameter
entities; resolves entities; and starts entities. The entity manager
is a central component in a standard parser configuration and this
class works directly with the entity scanner to manage the underlying
xni.
This component requires the following features and properties from the
component manager that uses it:
- http://xml.org/sax/features/validation
- http://xml.org/sax/features/external-general-entities
- http://xml.org/sax/features/external-parameter-entities
- http://apache.org/xml/features/allow-java-encodings
- http://apache.org/xml/properties/internal/symbol-table
- http://apache.org/xml/properties/internal/error-reporter
- http://apache.org/xml/properties/internal/entity-resolver
author: Andy Clark, IBM author: Arnaud Le Hors, IBM author: K.Venugopal SUN Microsystems author: Neeraj Bajaj SUN Microsystems version: $Id: XMLEntityManager.java,v 1.6 2007/03/16 14:48:45 spericas Exp $ |
Inner Class :final protected class RewindableInputStream extends InputStream | |
Method Summary | |
public void | closeReaders() Close all opened InputStreams and Readers opened by this parser. | protected Reader | createReader(InputStream inputStream, String encoding, Boolean isBigEndian) Creates a reader capable of reading the given input stream in
the specified encoding.
Parameters: inputStream - The input stream. Parameters: encoding - The encoding name that the input stream isencoded using. | public void | endEntity() | public void | endExternalSubset() | public static String | expandSystemId(String systemId) Expands a system id and returns the system id as a URI, if
it can be expanded. | public static String | expandSystemId(String systemId, String baseSystemId) Expands a system id and returns the system id as a URI, if
it can be expanded. | protected static String | fixURI(String str) Fixes a platform dependent filename to standard URI form.
Parameters: str - The string to fix. | public int | getColumnNumber() Return the column number where the current document event ends.
Warning: The return value from the method
is intended only as an approximation for the sake of error
reporting; it is not intended to provide sufficient information
to edit the character content of the original XML document.
The return value is an approximation of the column number
in the document entity or external parsed entity where the
markup triggering the event appears.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event. | public Entity.ScannedEntity | getCurrentEntity() Return the current entity being scanned. | protected Object[] | getEncodingName(byte[] b4, int count) Returns the IANA encoding name that is auto-detected from
the bytes specified, with the endian-ness of that encoding where appropriate.
Parameters: b4 - The first four bytes of the input. Parameters: count - The number of bytes actually read. | public XMLEntityReader | getEntityReader() | public XMLEntityStorage | getEntityStore() | public String | getExpandedSystemId() Return the expanded system identifier for the current document event. | public Boolean | getFeatureDefault(String featureId) Returns the default state for a feature, or null if this
component does not want to report a default value for this
feature. | public int | getLineNumber() Return the line number where the current document event ends.
Warning: The return value from the method
is intended only as an approximation for the sake of error
reporting; it is not intended to provide sufficient information
to edit the character content of the original XML document.
The return value is an approximation of the line number
in the document entity or external parsed entity where the
markup triggering the event appears.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event. | public String | getLiteralSystemId() Return the literal system identifier for the current document event. | public Object | getPropertyDefault(String propertyId) Returns the default state for a property, or null if this
component does not want to report a default value for this
property. | public String | getPublicId() Return the public identifier for the current document event. | public String[] | getRecognizedFeatures() Returns a list of feature identifiers that are recognized by
this component. | public String[] | getRecognizedProperties() Returns a list of property identifiers that are recognized by
this component. | public boolean | isStandalone() Returns true if the document entity is standalone. | final void | print() Prints the contents of the buffer. | public void | reset(PropertyManager propertyManager) | public void | reset(XMLComponentManager componentManager) Resets the component. | public XMLInputSource | resolveEntity(XMLResourceIdentifier resourceIdentifier) Resolves the specified public and system identifiers. | public StaxXMLInputSource | resolveEntityAsPerStax(XMLResourceIdentifier resourceIdentifier) | public void | setEntityHandler(XMLEntityHandler entityHandler) Sets the entity handler. | public void | setFeature(String featureId, boolean state) Sets the state of a feature. | public void | setProperty(String name, Object value) | public void | setStandalone(boolean standalone) Sets whether the document entity is standalone. | public void | startDTDEntity(XMLInputSource xmlInputSource) Starts the DTD entity. | public void | startDocumentEntity(XMLInputSource xmlInputSource) Starts the document entity. | public void | startEntity(String entityName, boolean literal) Starts a named entity. | public void | startEntity(String name, XMLInputSource xmlInputSource, boolean literal, boolean isExternal) Starts an entity. | public void | startExternalSubset() | public void | test() |
ALLOW_JAVA_ENCODINGS | final protected static String ALLOW_JAVA_ENCODINGS(Code) | | Feature identifier: allow Java encodings.
|
BUFFER_SIZE | final protected static String BUFFER_SIZE(Code) | | property identifier: buffer size.
|
DEFAULT_BUFFER_SIZE | final public static int DEFAULT_BUFFER_SIZE(Code) | | Default buffer size (2048).
|
DEFAULT_INTERNAL_BUFFER_SIZE | final public static int DEFAULT_INTERNAL_BUFFER_SIZE(Code) | | Default internal entity buffer size (1024).
|
DEFAULT_XMLDECL_BUFFER_SIZE | final public static int DEFAULT_XMLDECL_BUFFER_SIZE(Code) | | Default buffer size before we've finished with the XMLDecl:
|
ENTITY_RESOLVER | final protected static String ENTITY_RESOLVER(Code) | | Property identifier: entity resolver.
|
ERROR_REPORTER | final protected static String ERROR_REPORTER(Code) | | Property identifier: error reporter.
|
EXTERNAL_GENERAL_ENTITIES | final protected static String EXTERNAL_GENERAL_ENTITIES(Code) | | Feature identifier: external general entities.
|
EXTERNAL_PARAMETER_ENTITIES | final protected static String EXTERNAL_PARAMETER_ENTITIES(Code) | | Feature identifier: external parameter entities.
|
STAX_ENTITY_RESOLVER | final protected static String STAX_ENTITY_RESOLVER(Code) | | |
SYMBOL_TABLE | final protected static String SYMBOL_TABLE(Code) | | Property identifier: symbol table.
|
VALIDATION | final protected static String VALIDATION(Code) | | Feature identifier: validation.
|
VALIDATION_MANAGER | final protected static String VALIDATION_MANAGER(Code) | | |
WARN_ON_DUPLICATE_ENTITYDEF | final protected static String WARN_ON_DUPLICATE_ENTITYDEF(Code) | | Feature identifier: warn on duplicate EntityDef
|
defaultEncoding | final protected Object[] defaultEncoding(Code) | | |
fAllowJavaEncodings | protected boolean fAllowJavaEncodings(Code) | | Allow Java encoding names. This feature identifier is:
http://apache.org/xml/features/allow-java-encodings
|
fBufferSize | protected int fBufferSize(Code) | | Buffer size. We get this value from a property. The default size
is used if the input buffer size property is not specified.
REVISIT: do we need a property for internal entity buffer size?
|
fDeclaredEntities | protected Hashtable fDeclaredEntities(Code) | | Shared declared entities.
XXX understand it more deeply, why are we doing this ?? Is it really required ?
|
fEntityResolver | protected XMLEntityResolver fEntityResolver(Code) | | Entity resolver. This property identifier is:
http://apache.org/xml/properties/internal/entity-resolver
|
fEntityStack | protected Stack fEntityStack(Code) | | Entity stack.
|
fErrorReporter | protected XMLErrorReporter fErrorReporter(Code) | | Error reporter. This property identifier is:
http://apache.org/xml/properties/internal/error-reporter
|
fExternalGeneralEntities | protected boolean fExternalGeneralEntities(Code) | | External general entities. This feature identifier is:
http://xml.org/sax/features/external-general-entities
|
fExternalParameterEntities | protected boolean fExternalParameterEntities(Code) | | External parameter entities. This feature identifier is:
http://xml.org/sax/features/external-parameter-entities
|
fInExternalSubset | protected boolean fInExternalSubset(Code) | | |
fStandalone | protected boolean fStandalone(Code) | | True if the document entity is standalone. This should really
only be set by the document source (e.g. XMLDocumentScanner).
|
fSymbolTable | protected SymbolTable fSymbolTable(Code) | | Symbol table. This property identifier is:
http://apache.org/xml/properties/internal/symbol-table
|
fValidation | protected boolean fValidation(Code) | | Validation. This feature identifier is:
http://xml.org/sax/features/validation
|
XMLEntityManager | public XMLEntityManager()(Code) | | If this constructor is used to create the object, reset() should be invoked on this object
|
closeReaders | public void closeReaders()(Code) | | Close all opened InputStreams and Readers opened by this parser.
|
createReader | protected Reader createReader(InputStream inputStream, String encoding, Boolean isBigEndian) throws IOException(Code) | | Creates a reader capable of reading the given input stream in
the specified encoding.
Parameters: inputStream - The input stream. Parameters: encoding - The encoding name that the input stream isencoded using. If the user has specified thatJava encoding names are allowed, then theencoding name may be a Java encoding name;otherwise, it is an ianaEncoding name. Parameters: isBigEndian - For encodings (like uCS-4), whose names cannotspecify a byte order, this tells whether the order is bigEndian. null menasunknown or not relevant. Returns a reader. |
endExternalSubset | public void endExternalSubset()(Code) | | |
expandSystemId | public static String expandSystemId(String systemId)(Code) | | 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.
Parameters: systemId - The systemId to be expanded. Returns the URI string representing the expanded systemidentifier. A null value indicates that the givensystem identifier is already expanded. |
expandSystemId | public static String expandSystemId(String systemId, String baseSystemId)(Code) | | 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.
Parameters: systemId - The systemId to be expanded. Returns the URI string representing the expanded systemidentifier. A null value indicates that the givensystem identifier is already expanded. |
fixURI | protected static String fixURI(String str)(Code) | | Fixes a platform dependent filename to standard URI form.
Parameters: str - The string to fix. Returns the fixed URI string. |
getColumnNumber | public int getColumnNumber()(Code) | | Return the column number where the current document event ends.
Warning: The return value from the method
is intended only as an approximation for the sake of error
reporting; it is not intended to provide sufficient information
to edit the character content of the original XML document.
The return value is an approximation of the column number
in the document entity or external parsed entity where the
markup triggering the event appears.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event. The first column in each line is column 1.
The column number, or -1 if none is available. |
getCurrentEntity | public Entity.ScannedEntity getCurrentEntity()(Code) | | Return the current entity being scanned. Current entity is SET using startEntity function.
Entity.ScannedEntity |
getEncodingName | protected Object[] getEncodingName(byte[] b4, int count)(Code) | | Returns the IANA encoding name that is auto-detected from
the bytes specified, with the endian-ness of that encoding where appropriate.
Parameters: b4 - The first four bytes of the input. Parameters: count - The number of bytes actually read. a 2-element array: the first element, an IANA-encoding string,the second element a Boolean which is true iff the document is big endian, falseif it's little-endian, and null if the distinction isn't relevant. |
getEntityReader | public XMLEntityReader getEntityReader()(Code) | | return the entity responsible for reading the entity
|
getEntityStore | public XMLEntityStorage getEntityStore()(Code) | | get the entity storage object from entity manager
|
getExpandedSystemId | public String getExpandedSystemId()(Code) | | Return the expanded system identifier for the current document event.
The return value is the expanded system identifier of the document
entity or of the external parsed entity in which the markup
triggering the event appears.
If the system identifier is a URL, the parser must resolve it
fully before passing it to the application.
A string containing the expanded system identifier, or nullif none is available. |
getFeatureDefault | public Boolean getFeatureDefault(String featureId)(Code) | | Returns the default state for a feature, or null if this
component does not want to report a default value for this
feature.
Parameters: featureId - The feature identifier. since: Xerces 2.2.0 |
getLineNumber | public int getLineNumber()(Code) | | Return the line number where the current document event ends.
Warning: The return value from the method
is intended only as an approximation for the sake of error
reporting; it is not intended to provide sufficient information
to edit the character content of the original XML document.
The return value is an approximation of the line number
in the document entity or external parsed entity where the
markup triggering the event appears.
If possible, the SAX driver should provide the line position
of the first character after the text associated with the document
event. The first line in the document is line 1.
The line number, or -1 if none is available. |
getLiteralSystemId | public String getLiteralSystemId()(Code) | | Return the literal system identifier for the current document event.
The return value is the literal system identifier of the document
entity or of the external parsed entity in which the markup
triggering the event appears.
A string containing the literal system identifier, or nullif none is available. |
getPropertyDefault | public Object getPropertyDefault(String propertyId)(Code) | | Returns the default state for a property, or null if this
component does not want to report a default value for this
property.
Parameters: propertyId - The property identifier. since: Xerces 2.2.0 |
getPublicId | public String getPublicId()(Code) | | Return the public identifier for the current document event.
The return value is the public identifier of the document
entity or of the external parsed entity in which the markup
triggering the event appears.
A string containing the public identifier, ornull if none is available. |
getRecognizedFeatures | public String[] getRecognizedFeatures()(Code) | | Returns a list of feature identifiers that are recognized by
this component. This method may return null if no features
are recognized by this component.
|
getRecognizedProperties | public String[] getRecognizedProperties()(Code) | | Returns a list of property identifiers that are recognized by
this component. This method may return null if no properties
are recognized by this component.
|
isStandalone | public boolean isStandalone()(Code) | | Returns true if the document entity is standalone.
|
print | final void print()(Code) | | Prints the contents of the buffer.
|
reset | public void reset(XMLComponentManager componentManager) throws XMLConfigurationException(Code) | | Resets the component. The component can query the component manager
about any features and properties that affect the operation of the
component.
Parameters: componentManager - The component manager. throws: SAXException - Thrown by component on initialization error.For example, if a feature or property isrequired for the operation of the component, thecomponent manager may throw aSAXNotRecognizedException or aSAXNotSupportedException. |
resolveEntity | public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws IOException, XNIException(Code) | | Resolves the specified public and system identifiers. This
method first attempts to resolve the entity based on the
EntityResolver registered by the application. If no entity
resolver is registered or if the registered entity handler
is unable to resolve the entity, then default entity
resolution will occur.
Parameters: publicId - The public identifier of the entity. Parameters: systemId - The system identifier of the entity. Parameters: baseSystemId - The base system identifier of the entity.This is the system identifier of the currententity and is used to expand the systemidentifier when the system identifier is arelative URI. Returns an input source that wraps the resolved entity.This method will never return null. throws: IOException - Thrown on i/o error. throws: XNIException - Thrown by entity resolver to signal an error. |
setEntityHandler | public void setEntityHandler(XMLEntityHandler entityHandler)(Code) | | Sets the entity handler. When an entity starts and ends, the
entity handler is notified of the change.
Parameters: entityHandler - The new entity handler. |
setFeature | public void setFeature(String featureId, boolean state) throws XMLConfigurationException(Code) | | Sets the state of a feature. This method is called by the component
manager any time after reset when a feature changes state.
Note: Components should silently ignore features
that do not affect the operation of the component.
Parameters: featureId - The feature identifier. Parameters: state - The state of the feature. throws: SAXNotRecognizedException - The component should not throwthis exception. throws: SAXNotSupportedException - The component should not throwthis exception. |
setStandalone | public void setStandalone(boolean standalone)(Code) | | Sets whether the document entity is standalone.
Parameters: standalone - True if document entity is standalone. |
startDTDEntity | public void startDTDEntity(XMLInputSource xmlInputSource) throws IOException, XNIException(Code) | | Starts the DTD entity. The DTD entity has the "[dtd]"
pseudo-name.
Parameters: xmlInputSource - The input source of the DTD entity. throws: IOException - Thrown on i/o error. throws: XNIException - Thrown by entity handler to signal an error. |
startDocumentEntity | public void startDocumentEntity(XMLInputSource xmlInputSource) throws IOException, XNIException(Code) | | Starts the document entity. The document entity has the "[xml]"
pseudo-name.
Parameters: xmlInputSource - The input source of the document entity. throws: IOException - Thrown on i/o error. throws: XNIException - Thrown by entity handler to signal an error. |
startEntity | public void startEntity(String entityName, boolean literal) throws IOException, XNIException(Code) | | Starts a named entity.
Parameters: entityName - The name of the entity to start. Parameters: literal - True if this entity is started within a literalvalue. throws: IOException - Thrown on i/o error. throws: XNIException - Thrown by entity handler to signal an error. |
startEntity | public void startEntity(String name, XMLInputSource xmlInputSource, boolean literal, boolean isExternal) throws IOException, XNIException(Code) | | Starts an entity.
This method can be used to insert an application defined XML
entity stream into the parsing stream.
Parameters: name - The name of the entity. Parameters: xmlInputSource - The input source of the entity. Parameters: literal - True if this entity is started within aliteral value. Parameters: isExternal - whether this entity should be treated as an internal or external entity. throws: IOException - Thrown on i/o error. throws: XNIException - Thrown by entity handler to signal an error. |
startExternalSubset | public void startExternalSubset()(Code) | | |
|
|
|