Top Description Inners Fields Constructors Methods
com.sun.org.apache.xerces.internal.impl

public Class XMLEntityManager

extends Object
implements XMLComponent, XMLEntityResolver
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver, com.sun.org.apache.xerces.internal.xni.parser.XMLComponent
Imports
com.sun.org.apache.xerces.internal.impl.io.ASCIIReader, .UCSReader, .UTF16Reader, .UTF8Reader, com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter, com.sun.org.apache.xerces.internal.impl.validation.ValidationManager, com.sun.org.apache.xerces.internal.util.*, .URI, com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager, com.sun.org.apache.xerces.internal.xni.Augmentations, .XMLResourceIdentifier, .XNIException, com.sun.org.apache.xerces.internal.xni.parser.*, com.sun.xml.internal.stream.Entity, .StaxEntityResolverWrapper, .StaxXMLInputSource, .XMLEntityStorage, java.io.*, java.net.HttpURLConnection, .URISyntaxException, .URL, .URLConnection, java.util.HashMap, .Iterator, .Locale, .Map, .Stack, .StringTokenizer, javax.xml.XMLConstants, javax.xml.catalog.CatalogException, .CatalogFeatures.Feature, .CatalogFeatures, .CatalogManager, .CatalogResolver, javax.xml.stream.XMLInputFactory, javax.xml.transform.Source, jdk.xml.internal.JdkCatalog, .JdkConstants, .JdkProperty, .JdkXmlUtils, .SecuritySupport, .XMLLimitAnalyzer, .XMLSecurityManager, .XMLSecurityManager.Limit, org.xml.sax.InputSource

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:

Authors
Andy Clark, IBM, Arnaud Le Hors, IBM, K.Venugopal SUN Microsystems, Neeraj Bajaj SUN Microsystems, Sunitha Reddy SUN Microsystems

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
XMLEntityManager.EncodingInfo

Information about auto-detectable encodings.

protected class
XMLEntityManager.RewindableInputStream

This class wraps the byte inputstreams we're presented with.

Field Summary

Modifier and TypeField and Description
protected static final String
ALLOW_JAVA_ENCODINGS

Feature identifier: allow Java encodings.

protected static final String
BUFFER_SIZE

property identifier: buffer size.

private static final boolean
DEBUG_BUFFER

Debug printing of buffer.

private static final boolean
DEBUG_ENCODINGS

Debug switching readers for encodings.

private static final boolean
DEBUG_ENTITIES

Debug some basic entities.

public static final int
DEFAULT_BUFFER_SIZE

Default buffer size (2048).

public static final int
DEFAULT_INTERNAL_BUFFER_SIZE

Default internal entity buffer size (1024).

public static final int
DEFAULT_XMLDECL_BUFFER_SIZE

Default buffer size before we've finished with the XMLDecl:

protected final Object[]
private static final String
protected static final String
ENTITY_RESOLVER

Property identifier: entity resolver.

protected int
protected static final String
ERROR_REPORTER

Property identifier: error reporter.

pack-priv static final String
EXTERNAL_ACCESS_DEFAULT

access external dtd: file protocol

protected static final String
EXTERNAL_GENERAL_ENTITIES

Feature identifier: external general entities.

protected static final String
EXTERNAL_PARAMETER_ENTITIES

Feature identifier: external parameter entities.

protected String
fAccessExternalDTD

used to restrict external access

protected boolean
fAllowJavaEncodings

Allow Java encoding names.

protected int
fBufferSize

Buffer size.

pack-priv CatalogFeatures
private String
pack-priv CatalogResolver
protected Entity.ScannedEntity
fCurrentEntity

Current entity.

pack-priv CatalogResolver
private String
private static final Boolean[]
FEATURE_DEFAULTS

Feature defaults.

protected Map<String, Entity>
fEntities

Entities.

private final Augmentations
fEntityAugs

Augmentations for entities.

protected int
fEntityExpansionCount

count of entities expanded:

protected XMLEntityHandler
fEntityHandler

Entity handler.

protected XMLEntityResolver
fEntityResolver

Entity resolver.

protected XMLEntityScanner
fEntityScanner

Current entity scanner

protected Stack<Entity>
fEntityStack

Entity stack.

protected XMLEntityStorage
protected XMLErrorReporter
fErrorReporter

Error reporter.

protected boolean
fExternalGeneralEntities

External general entities.

protected boolean
fExternalParameterEntities

External parameter entities.

protected boolean
pack-priv boolean
fISCreatedByResolver

identify if the InputSource is created by a resolver

protected XMLLimitAnalyzer
protected boolean
fLoadExternalDTD

Load external DTD.

private String
protected PropertyManager
fPropertyManager

Property Manager.

protected Stack<Reader>
pack-priv boolean
private String
private final XMLResourceIdentifierImpl
fResourceIdentifier

Resource identifer.

protected XMLSecurityManager
fSecurityManager

Security Manager

pack-priv XMLSecurityPropertyManager
protected boolean
fStandalone

True if the document entity is standalone.

protected StaxEntityResolverWrapper
fStaxEntityResolver

Stax Entity Resolver.

protected boolean
fStrictURI

standard uri conformant (strict uri).

pack-priv boolean
fSupportDTD

StAX properties

pack-priv boolean
protected SymbolTable
fSymbolTable

Symbol table.

private boolean
fUseCatalog

indicate whether Catalog should be used for resolving external resources

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.

private static char[]
private static char[]
private static char[]
private static boolean[]
private static String
private static URI
protected static final String
LOAD_EXTERNAL_DTD

Feature identifier: load external DTD.

protected static final String
private static final Object[]
PROPERTY_DEFAULTS

Property defaults.

private static final String[]
RECOGNIZED_FEATURES

Recognized features.

private static final String[]
RECOGNIZED_PROPERTIES

Recognized properties.

protected static final String
SECURITY_MANAGER

property identifier: security manager.

protected static final String
STANDARD_URI_CONFORMANT

Feature identifier: standard uri conformant

protected static final String
protected static final String
SYMBOL_TABLE

Property identifier: symbol table.

protected static final String
VALIDATION

Feature identifier: validation.

protected static final String
protected static final String
WARN_ON_DUPLICATE_ENTITYDEF

Feature identifier: warn on duplicate EntityDef

private static final String
XML_SECURITY_PROPERTY_MANAGER

Property identifier: Security property manager.

private static final String

Constructor Summary

AccessConstructor and Description
public
XMLEntityManager()

If this constructor is used to create the object, reset() should be invoked on this object

public
XMLEntityManager(XMLSecurityPropertyManager securityPropertyMgr, XMLSecurityManager securityManager)

public
XMLEntityManager(PropertyManager propertyManager)

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public static void
absolutizeAgainstUserDir(URI
the URI to absolutize
uri
)

Absolutizes a URI using the current value of the "user.dir" property as the base URI.

public void
addExternalEntity(String
The name of the entity.
name
,
String
The public identifier of the entity.
publicId
,
String
The system identifier of the entity.
literalSystemId
,
String
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.
baseSystemId
)

Adds an external entity declaration.

public void
addInternalEntity(String
The name of the entity.
name
,
String
The text of the entity.
text
)

Adds an internal entity declaration.

public void
addUnparsedEntity(String
The name of the entity.
name
,
String
The public identifier of the entity.
publicId
,
String
The system identifier of the entity.
systemId
,
String baseSystemId, String
The name of the notation.
notation
)

Adds an unparsed entity declaration.

private void
checkSupportDTD()

Checks the supportDTD setting.

public void
closeReaders()

Close all opened InputStreams and Readers opened by this parser.

public static OutputStream
protected Reader

Returns:

Returns a reader.
createReader
(InputStream
The input stream.
inputStream
,
String
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.
encoding
,
Boolean
For encodings (like uCS-4), whose names cannot specify a byte order, this tells whether the order is bigEndian. null if unknown or irrelevant.
isBigEndian
)

Creates a reader capable of reading the given input stream in the specified encoding.

public void
public void
public static String

Returns:

Returns the URI string representing the expanded system identifier. A null value indicates that the given system identifier is already expanded.
expandSystemId
(String
The systemId to be expanded.
systemId
)

Expands a system id and returns the system id as a URI, if it can be expanded.

public static String

Returns:

Returns the URI string representing the expanded system identifier. A null value indicates that the given system identifier is already expanded.
expandSystemId
(String
The systemId to be expanded.
systemId
,
String baseSystemId)

Expands a system id and returns the system id as a URI, if it can be expanded.

public static String

Returns:

Returns the URI string representing the expanded system identifier. A null value indicates that the given system identifier is already expanded.
expandSystemId
(String
The systemId to be expanded.
systemId
,
String baseSystemId, boolean strict)

Expands a system id and returns the system id as a URI, if it can be expanded.

private static String
expandSystemIdStrictOff(String systemId, String baseSystemId)

Helper method for expandSystemId(String,String,boolean):String

private static String
expandSystemIdStrictOff1(String systemId, String baseSystemId)

private static String
expandSystemIdStrictOn(String systemId, String baseSystemId)

Helper method for expandSystemId(String,String,boolean):String

protected static String

Returns:

Returns the fixed URI string.
fixURI
(String
The string to fix.
str
)

Fixes a platform dependent filename to standard URI form.

public int

Returns:

The column number, or -1 if none is available.
getColumnNumber
()

Return the column number where the current document event ends.

public Entity.ScannedEntity

Returns:

Entity.ScannedEntity
getCurrentEntity
()

Return the current entity being scanned.

public XMLResourceIdentifier
protected XMLEntityManager.EncodingInfo

Returns:

an instance of EncodingInfo which represents the auto-detected encoding.
getEncodingInfo
(byte[]
The first four bytes of the input.
b4
,
int
The number of bytes actually read.
count
)

Returns the IANA encoding name that is auto-detected from the bytes specified, with the endian-ness of that encoding where appropriate.

public XMLEntityScanner
getEntityScanner()

return the entity responsible for reading the entity

public XMLEntityStorage
getEntityStore()

get the entity storage object from entity manager

public String

Returns:

A string containing the expanded system identifier, or null if none is available.
getExpandedSystemId
()

Return the expanded system identifier for the current document event.

public Boolean
getFeatureDefault(String
The feature identifier.
featureId
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getFeatureDefault.

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

Returns:

The line number, or -1 if none is available.
getLineNumber
()

Return the line number where the current document event ends.

public String

Returns:

A string containing the literal system identifier, or null if none is available.
getLiteralSystemId
()

Return the literal system identifier for the current document event.

private static String
public Object
getPropertyDefault(String
The property identifier.
propertyId
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getPropertyDefault.

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

Returns:

A string containing the public identifier, or null if none is available.
getPublicId
()

Return the public identifier for the current document event.

public String[]
getRecognizedFeatures()

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getRecognizedFeatures.

Returns a list of feature identifiers that are recognized by this component.

public String[]
getRecognizedProperties()

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.getRecognizedProperties.

Returns a list of property identifiers that are recognized by this component.

public Entity.ScannedEntity
getTopLevelEntity()

Return the top level entity handled by this manager, or null if no entity was added.

private static synchronized URI
private void
public boolean
public boolean

Returns:

True if the entity was declared in the external subset, false otherwise (including when the entity is not declared).
isEntityDeclInExternalSubset
(String
The name of the entity to check.
entityName
)

Checks whether the declaration of an entity given by name is // in the external subset.

public boolean

Returns:

True if the entity is external, false otherwise (including when the entity is not declared).
isExternalEntity
(String
The name of the entity to check.
entityName
)

Checks whether an entity given by name is external.

public boolean
isStandalone()

Returns true if the document entity is standalone.

public boolean
public void
reset(PropertyManager propertyManager)

public void
reset(XMLComponentManager
The component manager.
componentManager
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.reset.

Resets the component.

public void
private XMLInputSource
resolveEntity(String catalogName, CatalogResolver cr, String publicId, String systemId, String base)

public XMLInputSource

Returns:

Returns an input source that wraps the resolved entity. This method will never return null.
resolveEntity
(XMLResourceIdentifier
The public identifier of the entity.
resourceIdentifier
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver.resolveEntity.

Resolves the specified public and system identifiers.

public StaxXMLInputSource
private XMLInputSource
resolveEntityOrURI(String catalogName, CatalogResolver cr, String publicId, String systemId, String base)

Resolves the external resource using the Catalog specified and returns a XMLInputSource.

private InputSource
resolveWithCatalog(CatalogResolver cr, String cFile, String publicId, String systemId)

Resolves the external resource using the Catalog specified and returns a InputSource.

private StaxXMLInputSource
resolveWithCatalogStAX(CatalogResolver cr, String cFile, String publicId, String systemId)

Resolves the external resource using the Catalog specified and returns a StaxXMLInputSource.

public void
setEntityHandler(XMLEntityHandler
The new entity handler.
entityHandler
)

Sets the entity handler.

public void
setFeature(String
The feature identifier.
featureId
,
boolean
The state of the feature.
state
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.setFeature.

Sets the state of a feature.

public void
public void
setProperty(String
The property identifier.
propertyId
,
Object
The value of the property.
value
)

Implements com.sun.org.apache.xerces.internal.xni.parser.XMLComponent.setProperty.

Sets the value of a property.

public void
setScannerVersion(short version)

public void
setStandalone(boolean
True if document entity is standalone.
standalone
)

Sets whether the document entity is standalone.

public String

Returns:

the encoding of the new entity or null if a character stream was employed
setupCurrentEntity
(boolean
flag to indicate whether the entity is an Entity Reference.
reference
,
String
name of the entity (XML is it's the document entity)
name
,
XMLInputSource
the input source, with sufficient information to begin scanning characters.
xmlInputSource
,
boolean
True if this entity is started within a literal value.
literal
,
boolean
whether this entity should be treated as an internal or external entity.
isExternal
)

This method uses the passed-in XMLInputSource to make fCurrentEntity usable for reading.

public void
startDocumentEntity(XMLInputSource
The input source of the document entity.
xmlInputSource
)

Starts the document entity.

public void
startDTDEntity(XMLInputSource
The input source of the DTD entity.
xmlInputSource
)

Starts the DTD entity.

public void
startEntity(boolean
flag to indicate whether the entity is a General Entity
isGE
,
String
The name of the entity to start.
entityName
,
boolean
True if this entity is started within a literal value.
literal
)

Starts a named entity.

public void
startEntity(boolean
flag to indicate whether the entity is a General Entity
isGE
,
String
The name of the entity.
name
,
XMLInputSource
The input source of the entity.
xmlInputSource
,
boolean
True if this entity is started within a literal value.
literal
,
boolean
whether this entity should be treated as an internal or external entity.
isExternal
)

Starts an entity.

public void
public void
test()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait