public class XMLEntityManager
extends java.lang.Object
implements org.apache.xerces.xni.parser.XMLComponent, org.apache.xerces.xni.parser.XMLEntityResolver
This component requires the following features and properties from the component manager that uses it:
Modifier and Type | Class and Description |
---|---|
static class |
XMLEntityManager.Entity
Entity information.
|
protected static class |
XMLEntityManager.ExternalEntity
External entity.
|
protected static class |
XMLEntityManager.InternalEntity
Internal entity.
|
protected class |
XMLEntityManager.RewindableInputStream
This class wraps the byte inputstreams we're presented with.
|
class |
XMLEntityManager.ScannedEntity
Entity state.
|
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
ALLOW_JAVA_ENCODINGS
Feature identifier: allow Java encodings.
|
protected static java.lang.String |
BUFFER_SIZE
property identifier: buffer size.
|
static int |
DEFAULT_BUFFER_SIZE
Default buffer size (2048).
|
static int |
DEFAULT_INTERNAL_BUFFER_SIZE
Default internal entity buffer size (512).
|
static int |
DEFAULT_XMLDECL_BUFFER_SIZE
Default buffer size before we've finished with the XMLDecl:
|
protected static java.lang.String |
ENTITY_RESOLVER
Property identifier: entity resolver.
|
protected static java.lang.String |
ERROR_REPORTER
Property identifier: error reporter.
|
protected static java.lang.String |
EXTERNAL_GENERAL_ENTITIES
Feature identifier: external general entities.
|
protected static java.lang.String |
EXTERNAL_PARAMETER_ENTITIES
Feature identifier: external parameter entities.
|
protected boolean |
fAllowJavaEncodings
Allow Java encoding names.
|
protected int |
fBufferSize
Buffer size.
|
protected XMLEntityManager.ScannedEntity |
fCurrentEntity
Current entity.
|
protected java.util.Hashtable |
fDeclaredEntities
Shared declared entities.
|
protected java.util.Hashtable |
fEntities
Entities.
|
protected int |
fEntityExpansionCount |
protected int |
fEntityExpansionLimit |
protected XMLEntityHandler |
fEntityHandler
Entity handler.
|
protected org.apache.xerces.xni.parser.XMLEntityResolver |
fEntityResolver
Entity resolver.
|
protected XMLEntityScanner |
fEntityScanner
Current entity scanner.
|
protected java.util.Stack |
fEntityStack
Entity stack.
|
protected XMLErrorReporter |
fErrorReporter
Error reporter.
|
protected boolean |
fExternalGeneralEntities
External general entities.
|
protected boolean |
fExternalParameterEntities
External parameter entities.
|
protected boolean |
fHasPEReferences
True if the current document contains parameter entity references.
|
protected boolean |
fInExternalSubset |
protected java.util.Stack |
fReaderStack |
protected SecurityManager |
fSecurityManager |
protected boolean |
fStandalone
True if the document entity is standalone.
|
protected boolean |
fStrictURI
standard uri conformant (strict uri).
|
protected SymbolTable |
fSymbolTable
Symbol table.
|
protected boolean |
fValidation
Validation.
|
protected ValidationManager |
fValidationManager
Validation manager.
|
protected boolean |
fWarnDuplicateEntityDef
warn on duplicate Entity declaration.
|
protected XMLEntityScanner |
fXML10EntityScanner
XML 1.0 entity scanner.
|
protected XMLEntityScanner |
fXML11EntityScanner
XML 1.1 entity scanner.
|
protected static java.lang.String |
PARSER_SETTINGS |
protected static java.lang.String |
SECURITY_MANAGER
property identifier: security manager.
|
protected static java.lang.String |
STANDARD_URI_CONFORMANT
Feature identifier: standard uri conformant
|
protected static java.lang.String |
SYMBOL_TABLE
Property identifier: symbol table.
|
protected static java.lang.String |
VALIDATION
Feature identifier: validation.
|
protected static java.lang.String |
VALIDATION_MANAGER |
protected static java.lang.String |
WARN_ON_DUPLICATE_ENTITYDEF
Feature identifier: warn on duplicate EntityDef
|
Constructor and Description |
---|
XMLEntityManager()
Default constructor.
|
XMLEntityManager(XMLEntityManager entityManager)
Constructs an entity manager that shares the specified entity
declarations during each parse.
|
Modifier and Type | Method and Description |
---|---|
static void |
absolutizeAgainstUserDir(URI uri)
Absolutizes a URI using the current value
of the "user.dir" property as the base URI.
|
void |
addExternalEntity(java.lang.String name,
java.lang.String publicId,
java.lang.String literalSystemId,
java.lang.String baseSystemId)
Adds an external entity declaration.
|
void |
addInternalEntity(java.lang.String name,
java.lang.String text)
Adds an internal entity declaration.
|
void |
addInternalEntity(java.lang.String name,
java.lang.String text,
int paramEntityRefs)
Adds an internal entity declaration.
|
void |
addUnparsedEntity(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId,
java.lang.String baseSystemId,
java.lang.String notation)
Adds an unparsed entity declaration.
|
void |
closeReaders()
Close all opened InputStreams and Readers opened by this parser.
|
static java.io.OutputStream |
createOutputStream(java.lang.String uri) |
protected java.io.Reader |
createReader(java.io.InputStream inputStream,
java.lang.String encoding,
java.lang.Boolean isBigEndian)
Creates a reader capable of reading the given input stream in
the specified encoding.
|
void |
endExternalSubset() |
static java.lang.String |
expandSystemId(java.lang.String systemId,
java.lang.String baseSystemId,
boolean strict)
Expands a system id and returns the system id as a URI, if
it can be expanded.
|
protected static java.lang.String |
fixURI(java.lang.String str)
Fixes a platform dependent filename to standard URI form.
|
XMLEntityManager.ScannedEntity |
getCurrentEntity() |
org.apache.xerces.xni.XMLResourceIdentifier |
getCurrentResourceIdentifier() |
protected org.apache.xerces.impl.XMLEntityManager.EncodingInfo |
getEncodingInfo(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.
|
XMLEntityScanner |
getEntityScanner()
Returns the entity scanner.
|
java.lang.Boolean |
getFeatureDefault(java.lang.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.
|
int |
getParamEntityRefCount(java.lang.String entityName)
Returns the number of direct and indirect references to parameter
entities in the value of the entity.
|
java.lang.Object |
getPropertyDefault(java.lang.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.
|
java.lang.String[] |
getRecognizedFeatures()
Returns a list of feature identifiers that are recognized by
this component.
|
java.lang.String[] |
getRecognizedProperties()
Returns a list of property identifiers that are recognized by
this component.
|
boolean |
isDeclaredEntity(java.lang.String entityName)
Checks whether an entity given by name is declared.
|
boolean |
isEntityDeclInExternalSubset(java.lang.String entityName)
Checks whether the declaration of an entity given by name is
// in the external subset.
|
boolean |
isExternalEntity(java.lang.String entityName)
Checks whether an entity given by name is external.
|
boolean |
isStandalone()
Returns true if the document entity is standalone.
|
boolean |
isUnparsedEntity(java.lang.String entityName)
Checks whether an entity given by name is unparsed.
|
void |
reset() |
void |
reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager)
Resets the component.
|
org.apache.xerces.xni.parser.XMLInputSource |
resolveEntity(org.apache.xerces.xni.XMLResourceIdentifier resourceIdentifier)
Resolves the specified public and system identifiers.
|
void |
setEntityHandler(XMLEntityHandler entityHandler)
Sets the entity handler.
|
void |
setFeature(java.lang.String featureId,
boolean state)
Sets the state of a feature.
|
void |
setProperty(java.lang.String propertyId,
java.lang.Object value)
Sets the value of a property.
|
void |
setScannerVersion(short version) |
void |
setStandalone(boolean standalone)
Sets whether the document entity is standalone.
|
java.lang.String |
setupCurrentEntity(java.lang.String name,
org.apache.xerces.xni.parser.XMLInputSource xmlInputSource,
boolean literal,
boolean isExternal)
This method uses the passed-in XMLInputSource to make
fCurrentEntity usable for reading.
|
void |
startDocumentEntity(org.apache.xerces.xni.parser.XMLInputSource xmlInputSource)
Starts the document entity.
|
void |
startDTDEntity(org.apache.xerces.xni.parser.XMLInputSource xmlInputSource)
Starts the DTD entity.
|
void |
startEntity(java.lang.String entityName,
boolean literal)
Starts a named entity.
|
void |
startEntity(java.lang.String name,
org.apache.xerces.xni.parser.XMLInputSource xmlInputSource,
boolean literal,
boolean isExternal)
Starts an entity.
|
void |
startExternalSubset() |
public static final int DEFAULT_BUFFER_SIZE
public static final int DEFAULT_XMLDECL_BUFFER_SIZE
public static final int DEFAULT_INTERNAL_BUFFER_SIZE
protected static final java.lang.String VALIDATION
protected static final java.lang.String EXTERNAL_GENERAL_ENTITIES
protected static final java.lang.String EXTERNAL_PARAMETER_ENTITIES
protected static final java.lang.String ALLOW_JAVA_ENCODINGS
protected static final java.lang.String WARN_ON_DUPLICATE_ENTITYDEF
protected static final java.lang.String STANDARD_URI_CONFORMANT
protected static final java.lang.String PARSER_SETTINGS
protected static final java.lang.String SYMBOL_TABLE
protected static final java.lang.String ERROR_REPORTER
protected static final java.lang.String ENTITY_RESOLVER
protected static final java.lang.String VALIDATION_MANAGER
protected static final java.lang.String BUFFER_SIZE
protected static final java.lang.String SECURITY_MANAGER
protected boolean fValidation
protected boolean fExternalGeneralEntities
protected boolean fExternalParameterEntities
protected boolean fAllowJavaEncodings
protected boolean fWarnDuplicateEntityDef
protected boolean fStrictURI
protected SymbolTable fSymbolTable
protected XMLErrorReporter fErrorReporter
protected org.apache.xerces.xni.parser.XMLEntityResolver fEntityResolver
protected ValidationManager fValidationManager
protected int fBufferSize
protected SecurityManager fSecurityManager
protected boolean fStandalone
protected boolean fHasPEReferences
protected boolean fInExternalSubset
protected XMLEntityHandler fEntityHandler
protected XMLEntityScanner fEntityScanner
protected XMLEntityScanner fXML10EntityScanner
protected XMLEntityScanner fXML11EntityScanner
protected int fEntityExpansionLimit
protected int fEntityExpansionCount
protected final java.util.Hashtable fEntities
protected final java.util.Stack fEntityStack
protected XMLEntityManager.ScannedEntity fCurrentEntity
protected java.util.Hashtable fDeclaredEntities
protected java.util.Stack fReaderStack
public XMLEntityManager()
public XMLEntityManager(XMLEntityManager entityManager)
REVISIT: We might want to think about the "right" way to expose the list of declared entities. For now, the knowledge how to access the entity declarations is implicit.
public void setStandalone(boolean standalone)
standalone
- True if document entity is standalone.public boolean isStandalone()
public void setEntityHandler(XMLEntityHandler entityHandler)
entityHandler
- The new entity handler.public org.apache.xerces.xni.XMLResourceIdentifier getCurrentResourceIdentifier()
public XMLEntityManager.ScannedEntity getCurrentEntity()
public void addInternalEntity(java.lang.String name, java.lang.String text, int paramEntityRefs)
Note: This method ignores subsequent entity declarations.
Note: The name should be a unique symbol. The SymbolTable can be used for this purpose.
name
- The name of the entity.text
- The text of the entity.paramEntityRefs
- Count of direct and indirect references to parameter entities in the value of the entity.SymbolTable
public void addInternalEntity(java.lang.String name, java.lang.String text)
Note: This method ignores subsequent entity declarations.
Note: The name should be a unique symbol. The SymbolTable can be used for this purpose.
name
- The name of the entity.text
- The text of the entity.SymbolTable
public int getParamEntityRefCount(java.lang.String entityName)
entityName
- The name of the entity to check.public void addExternalEntity(java.lang.String name, java.lang.String publicId, java.lang.String literalSystemId, java.lang.String baseSystemId) throws java.io.IOException
Note: This method ignores subsequent entity declarations.
Note: The name should be a unique symbol. The SymbolTable can be used for this purpose.
name
- The name of the entity.publicId
- The public identifier of the entity.literalSystemId
- The system identifier of the entity.baseSystemId
- The base system identifier of the entity.
This is the system identifier of the entity
where the entity being added and
is used to expand the system identifier when
the system identifier is a relative URI.
When null the system identifier of the first
external entity on the stack is used instead.java.io.IOException
SymbolTable
public boolean isExternalEntity(java.lang.String entityName)
entityName
- The name of the entity to check.public boolean isEntityDeclInExternalSubset(java.lang.String entityName)
entityName
- The name of the entity to check.public void addUnparsedEntity(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String baseSystemId, java.lang.String notation)
Note: This method ignores subsequent entity declarations.
Note: The name should be a unique symbol. The SymbolTable can be used for this purpose.
name
- The name of the entity.publicId
- The public identifier of the entity.systemId
- The system identifier of the entity.notation
- The name of the notation.SymbolTable
public boolean isUnparsedEntity(java.lang.String entityName)
entityName
- The name of the entity to check.public boolean isDeclaredEntity(java.lang.String entityName)
entityName
- The name of the entity to check.public org.apache.xerces.xni.parser.XMLInputSource resolveEntity(org.apache.xerces.xni.XMLResourceIdentifier resourceIdentifier) throws java.io.IOException, org.apache.xerces.xni.XNIException
resolveEntity
in interface org.apache.xerces.xni.parser.XMLEntityResolver
resourceIdentifier
- The XMLResourceIdentifier for the resource to resolve.java.io.IOException
- Thrown on i/o error.org.apache.xerces.xni.XNIException
- Thrown by entity resolver to signal an error.XMLResourceIdentifier
public void startEntity(java.lang.String entityName, boolean literal) throws java.io.IOException, org.apache.xerces.xni.XNIException
entityName
- The name of the entity to start.literal
- True if this entity is started within a literal
value.java.io.IOException
- Thrown on i/o error.org.apache.xerces.xni.XNIException
- Thrown by entity handler to signal an error.public void startDocumentEntity(org.apache.xerces.xni.parser.XMLInputSource xmlInputSource) throws java.io.IOException, org.apache.xerces.xni.XNIException
xmlInputSource
- The input source of the document entity.java.io.IOException
- Thrown on i/o error.org.apache.xerces.xni.XNIException
- Thrown by entity handler to signal an error.public void startDTDEntity(org.apache.xerces.xni.parser.XMLInputSource xmlInputSource) throws java.io.IOException, org.apache.xerces.xni.XNIException
xmlInputSource
- The input source of the DTD entity.java.io.IOException
- Thrown on i/o error.org.apache.xerces.xni.XNIException
- Thrown by entity handler to signal an error.public void startExternalSubset()
public void endExternalSubset()
public void startEntity(java.lang.String name, org.apache.xerces.xni.parser.XMLInputSource xmlInputSource, boolean literal, boolean isExternal) throws java.io.IOException, org.apache.xerces.xni.XNIException
This method can be used to insert an application defined XML entity stream into the parsing stream.
name
- The name of the entity.xmlInputSource
- The input source of the entity.literal
- True if this entity is started within a
literal value.isExternal
- whether this entity should be treated as an internal or external entity.java.io.IOException
- Thrown on i/o error.org.apache.xerces.xni.XNIException
- Thrown by entity handler to signal an error.public java.lang.String setupCurrentEntity(java.lang.String name, org.apache.xerces.xni.parser.XMLInputSource xmlInputSource, boolean literal, boolean isExternal) throws java.io.IOException, org.apache.xerces.xni.XNIException
name
- name of the entity (XML is it's the document entity)xmlInputSource
- the input source, with sufficient information
to begin scanning characters.literal
- True if this entity is started within a
literal value.isExternal
- whether this entity should be treated as an internal or external entity.java.io.IOException
- if anything can't be read
XNIException If any parser-specific goes wrong.org.apache.xerces.xni.XNIException
public void setScannerVersion(short version)
public XMLEntityScanner getEntityScanner()
public void closeReaders()
public void reset(org.apache.xerces.xni.parser.XMLComponentManager componentManager) throws org.apache.xerces.xni.parser.XMLConfigurationException
reset
in interface org.apache.xerces.xni.parser.XMLComponent
componentManager
- The component manager.SAXException
- Thrown by component on initialization error.
For example, if a feature or property is
required for the operation of the component, the
component manager may throw a
SAXNotRecognizedException or a
SAXNotSupportedException.org.apache.xerces.xni.parser.XMLConfigurationException
public void reset()
public java.lang.String[] getRecognizedFeatures()
getRecognizedFeatures
in interface org.apache.xerces.xni.parser.XMLComponent
public void setFeature(java.lang.String featureId, boolean state) throws org.apache.xerces.xni.parser.XMLConfigurationException
Note: Components should silently ignore features that do not affect the operation of the component.
setFeature
in interface org.apache.xerces.xni.parser.XMLComponent
featureId
- The feature identifier.state
- The state of the feature.SAXNotRecognizedException
- The component should not throw
this exception.SAXNotSupportedException
- The component should not throw
this exception.org.apache.xerces.xni.parser.XMLConfigurationException
- Thrown for configuration error.
In general, components should
only throw this exception if
it is really
a critical error.public java.lang.String[] getRecognizedProperties()
getRecognizedProperties
in interface org.apache.xerces.xni.parser.XMLComponent
public void setProperty(java.lang.String propertyId, java.lang.Object value) throws org.apache.xerces.xni.parser.XMLConfigurationException
Note: Components should silently ignore properties that do not affect the operation of the component.
setProperty
in interface org.apache.xerces.xni.parser.XMLComponent
propertyId
- The property identifier.value
- The value of the property.SAXNotRecognizedException
- The component should not throw
this exception.SAXNotSupportedException
- The component should not throw
this exception.org.apache.xerces.xni.parser.XMLConfigurationException
- Thrown for configuration error.
In general, components should
only throw this exception if
it is really
a critical error.public java.lang.Boolean getFeatureDefault(java.lang.String featureId)
getFeatureDefault
in interface org.apache.xerces.xni.parser.XMLComponent
featureId
- The feature identifier.public java.lang.Object getPropertyDefault(java.lang.String propertyId)
getPropertyDefault
in interface org.apache.xerces.xni.parser.XMLComponent
propertyId
- The property identifier.public static void absolutizeAgainstUserDir(URI uri) throws URI.MalformedURIException
uri
- the URI to absolutizeURI.MalformedURIException
public static java.lang.String expandSystemId(java.lang.String systemId, java.lang.String baseSystemId, boolean strict) throws URI.MalformedURIException
systemId
- The systemId to be expanded.URI.MalformedURIException
public static java.io.OutputStream createOutputStream(java.lang.String uri) throws java.io.IOException
java.io.IOException
protected org.apache.xerces.impl.XMLEntityManager.EncodingInfo getEncodingInfo(byte[] b4, int count)
b4
- The first four bytes of the input.count
- The number of bytes actually read.protected java.io.Reader createReader(java.io.InputStream inputStream, java.lang.String encoding, java.lang.Boolean isBigEndian) throws java.io.IOException
inputStream
- The input stream.encoding
- The encoding name that the input stream is
encoded using. If the user has specified that
Java encoding names are allowed, then the
encoding name may be a Java encoding name;
otherwise, it is an ianaEncoding name.isBigEndian
- For encodings (like uCS-4), whose names cannot
specify a byte order, this tells whether the order is bigEndian. Null means
unknown or not relevant.java.io.IOException
protected static java.lang.String fixURI(java.lang.String str)
str
- The string to fix.Copyright © 1999-2022 The Apache Software Foundation. All Rights Reserved.