|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xerces.impl.XMLEntityManager
public class XMLEntityManager
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:
Nested Class Summary | |
---|---|
static class |
XMLEntityManager.Entity
Entity information. |
class |
XMLEntityManager.ScannedEntity
Entity state. |
Field Summary | |
---|---|
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: |
Constructor Summary | |
---|---|
XMLEntityManager()
Default constructor. |
|
XMLEntityManager(XMLEntityManager entityManager)
Constructs an entity manager that shares the specified entity declarations during each parse. |
Method Summary | |
---|---|
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 |
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)
|
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. |
XMLEntityManager.ScannedEntity |
getCurrentEntity()
|
XMLResourceIdentifier |
getCurrentResourceIdentifier()
|
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. |
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(XMLComponentManager componentManager)
Resets the component. |
XMLInputSource |
resolveEntity(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. |
static void |
setInstanceFollowRedirects(java.net.HttpURLConnection urlCon,
boolean followRedirects)
Attempt to set whether redirects will be followed for an HttpURLConnection . |
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,
XMLInputSource xmlInputSource,
boolean literal,
boolean isExternal)
This method uses the passed-in XMLInputSource to make fCurrentEntity usable for reading. |
void |
startDocumentEntity(XMLInputSource xmlInputSource)
Starts the document entity. |
void |
startDTDEntity(XMLInputSource xmlInputSource)
Starts the DTD entity. |
void |
startEntity(java.lang.String entityName,
boolean literal)
Starts a named entity. |
void |
startEntity(java.lang.String name,
XMLInputSource xmlInputSource,
boolean literal,
boolean isExternal)
Starts an entity. |
void |
startExternalSubset()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BUFFER_SIZE
public static final int DEFAULT_XMLDECL_BUFFER_SIZE
public static final int DEFAULT_INTERNAL_BUFFER_SIZE
Constructor Detail |
---|
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.
Method Detail |
---|
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 XMLResourceIdentifier getCurrentResourceIdentifier()
public XMLEntityManager.ScannedEntity getCurrentEntity()
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 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 XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws java.io.IOException, XNIException
resolveEntity
in interface XMLEntityResolver
resourceIdentifier
- The XMLResourceIdentifier for the resource to resolve.
java.io.IOException
- Thrown on i/o error.
XNIException
- Thrown by entity resolver to signal an error.XMLResourceIdentifier
public void startEntity(java.lang.String entityName, boolean literal) throws java.io.IOException, 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.
XNIException
- Thrown by entity handler to signal an error.public void startDocumentEntity(XMLInputSource xmlInputSource) throws java.io.IOException, XNIException
xmlInputSource
- The input source of the document entity.
java.io.IOException
- Thrown on i/o error.
XNIException
- Thrown by entity handler to signal an error.public void startDTDEntity(XMLInputSource xmlInputSource) throws java.io.IOException, XNIException
xmlInputSource
- The input source of the DTD entity.
java.io.IOException
- Thrown on i/o error.
XNIException
- Thrown by entity handler to signal an error.public void startExternalSubset()
public void endExternalSubset()
public void startEntity(java.lang.String name, XMLInputSource xmlInputSource, boolean literal, boolean isExternal) throws java.io.IOException, 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.
XNIException
- Thrown by entity handler to signal an error.public java.lang.String setupCurrentEntity(java.lang.String name, XMLInputSource xmlInputSource, boolean literal, boolean isExternal) throws java.io.IOException, 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.
XNIException
public void setScannerVersion(short version)
public XMLEntityScanner getEntityScanner()
public void closeReaders()
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException
reset
in interface 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.
XMLConfigurationException
public void reset()
public java.lang.String[] getRecognizedFeatures()
getRecognizedFeatures
in interface XMLComponent
public void setFeature(java.lang.String featureId, boolean state) throws XMLConfigurationException
Note: Components should silently ignore features that do not affect the operation of the component.
setFeature
in interface 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.
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 XMLComponent
public void setProperty(java.lang.String propertyId, java.lang.Object value) throws XMLConfigurationException
Note: Components should silently ignore properties that do not affect the operation of the component.
setProperty
in interface 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.
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 XMLComponent
featureId
- The feature identifier.public java.lang.Object getPropertyDefault(java.lang.String propertyId)
getPropertyDefault
in interface XMLComponent
propertyId
- The property identifier.public static void absolutizeAgainstUserDir(URI uri) throws URI.MalformedURIException
uri
- the URI to absolutize
URI.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 void setInstanceFollowRedirects(java.net.HttpURLConnection urlCon, boolean followRedirects)
HttpURLConnection
.
This may fail on earlier JDKs which do not support setting this preference.
public static java.io.OutputStream createOutputStream(java.lang.String uri) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |