Home » Xerces-J-src.2.9.1 » org.apache.xerces » impl » [javadoc | source]
org.apache.xerces.impl
public class: XMLEntityManager [javadoc | source]
java.lang.Object
   org.apache.xerces.impl.XMLEntityManager

All Implemented Interfaces:
    XMLComponent, XMLEntityResolver

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:
abstract public static class  XMLEntityManager.Entity  Entity information. 
protected static class  XMLEntityManager.InternalEntity  Internal entity. 
protected static class  XMLEntityManager.ExternalEntity  External entity. 
public class  XMLEntityManager.ScannedEntity  Entity state. 
protected final class  XMLEntityManager.RewindableInputStream  This class wraps the byte inputstreams we're presented with. We need it because java.io.InputStreams don't provide functionality to reread processed bytes, and they have a habit of reading more than one character when you call their read() methods. This means that, once we discover the true (declared) encoding of a document, we can neither backtrack to read the whole doc again nor start reading where we are with a new reader. This class allows rewinding an inputStream by allowing a mark to be set, and the stream reset to that position. The class assumes that it needs to read one character per invocation when it's read() method is inovked, but uses the underlying InputStream's read(char[], offset length) method--it won't buffer data read this way! 
Field Summary
public static final  int DEFAULT_BUFFER_SIZE    Default buffer size (2048). 
public static final  int DEFAULT_XMLDECL_BUFFER_SIZE    Default buffer size before we've finished with the XMLDecl: 
public static final  int DEFAULT_INTERNAL_BUFFER_SIZE    Default internal entity buffer size (512). 
protected static final  String VALIDATION    Feature identifier: validation. 
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 static final  String ALLOW_JAVA_ENCODINGS    Feature identifier: allow Java encodings. 
protected static final  String WARN_ON_DUPLICATE_ENTITYDEF    Feature identifier: warn on duplicate EntityDef 
protected static final  String STANDARD_URI_CONFORMANT    Feature identifier: standard uri conformant 
protected static final  String PARSER_SETTINGS     
protected static final  String SYMBOL_TABLE    Property identifier: symbol table. 
protected static final  String ERROR_REPORTER    Property identifier: error reporter. 
protected static final  String ENTITY_RESOLVER    Property identifier: entity resolver. 
protected static final  String VALIDATION_MANAGER     
protected static final  String BUFFER_SIZE    property identifier: buffer size. 
protected static final  String SECURITY_MANAGER    property identifier: security manager. 
protected  boolean fValidation    Validation. This feature identifier is: http://xml.org/sax/features/validation 
protected  boolean fExternalGeneralEntities    External general entities. This feature identifier is: http://xml.org/sax/features/external-general-entities 
protected  boolean fExternalParameterEntities    External parameter entities. This feature identifier is: http://xml.org/sax/features/external-parameter-entities 
protected  boolean fAllowJavaEncodings    Allow Java encoding names. This feature identifier is: http://apache.org/xml/features/allow-java-encodings 
protected  boolean fWarnDuplicateEntityDef    warn on duplicate Entity declaration. http://apache.org/xml/features/warn-on-duplicate-entitydef 
protected  boolean fStrictURI    standard uri conformant (strict uri). http://apache.org/xml/features/standard-uri-conformant 
protected  SymbolTable fSymbolTable    Symbol table. This property identifier is: http://apache.org/xml/properties/internal/symbol-table 
protected  XMLErrorReporter fErrorReporter    Error reporter. This property identifier is: http://apache.org/xml/properties/internal/error-reporter 
protected  XMLEntityResolver fEntityResolver    Entity resolver. This property identifier is: http://apache.org/xml/properties/internal/entity-resolver 
protected  ValidationManager fValidationManager    Validation manager. This property identifier is: http://apache.org/xml/properties/internal/validation-manager 
protected  int fBufferSize    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? 
protected  SecurityManager fSecurityManager     
protected  boolean fStandalone    True if the document entity is standalone. This should really only be set by the document source (e.g. XMLDocumentScanner). 
protected  boolean fHasPEReferences    True if the current document contains parameter entity references. 
protected  boolean fInExternalSubset     
protected  XMLEntityHandler fEntityHandler    Entity handler. 
protected  XMLEntityScanner fEntityScanner    Current entity scanner. 
protected  XMLEntityScanner fXML10EntityScanner    XML 1.0 entity scanner. 
protected  XMLEntityScanner fXML11EntityScanner    XML 1.1 entity scanner. 
protected  int fEntityExpansionLimit     
protected  int fEntityExpansionCount     
protected final  Hashtable fEntities    Entities. 
protected final  Stack fEntityStack    Entity stack. 
protected  XMLEntityManager.ScannedEntity fCurrentEntity    Current entity. 
protected  Hashtable fDeclaredEntities    Shared declared entities. 
protected  Stack fReaderStack     
Constructor:
 public XMLEntityManager() 
 public XMLEntityManager(XMLEntityManager entityManager) 
    Constructs an entity manager that shares the specified entity declarations during each parse.

    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 from org.apache.xerces.impl.XMLEntityManager Summary:
absolutizeAgainstUserDir,   addExternalEntity,   addInternalEntity,   addUnparsedEntity,   closeReaders,   createOutputStream,   createReader,   endEntity,   endExternalSubset,   expandSystemId,   fixURI,   getCurrentEntity,   getCurrentResourceIdentifier,   getDeclaredEntities,   getEncodingName,   getEntityScanner,   getFeatureDefault,   getPropertyDefault,   getRecognizedFeatures,   getRecognizedProperties,   hasPEReferences,   isDeclaredEntity,   isEntityDeclInExternalSubset,   isExternalEntity,   isStandalone,   isUnparsedEntity,   notifyHasPEReferences,   print,   reset,   reset,   resolveEntity,   setEntityHandler,   setFeature,   setInstanceFollowRedirects,   setProperty,   setScannerVersion,   setStandalone,   setupCurrentEntity,   startDTDEntity,   startDocumentEntity,   startEntity,   startEntity,   startExternalSubset
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.xerces.impl.XMLEntityManager Detail:
 public static  void absolutizeAgainstUserDir(URI uri) throws URI.MalformedURIException 
    Absolutizes a URI using the current value of the "user.dir" property as the base URI. If the URI is already absolute, this is a no-op.
 public  void addExternalEntity(String name,
    String publicId,
    String literalSystemId,
    String baseSystemId) throws IOException 
    Adds an external entity declaration.

    Note: This method ignores subsequent entity declarations.

    Note: The name should be a unique symbol. The SymbolTable can be used for this purpose.

 public  void addInternalEntity(String name,
    String text) 
    Adds an internal entity declaration.

    Note: This method ignores subsequent entity declarations.

    Note: The name should be a unique symbol. The SymbolTable can be used for this purpose.

 public  void addUnparsedEntity(String name,
    String publicId,
    String systemId,
    String baseSystemId,
    String notation) 
    Adds an unparsed entity declaration.

    Note: This method ignores subsequent entity declarations.

    Note: The name should be a unique symbol. The SymbolTable can be used for this purpose.

 public  void closeReaders() 
    Close all opened InputStreams and Readers opened by this parser.
 public static OutputStream createOutputStream(String uri) throws IOException 
 protected Reader createReader(InputStream inputStream,
    String encoding,
    Boolean isBigEndian) throws IOException 
    Creates a reader capable of reading the given input stream in the specified encoding.
  void endEntity() throws XNIException 
    Ends an entity.
 public  void endExternalSubset() 
 public static String expandSystemId(String systemId,
    String baseSystemId,
    boolean strict) throws URI.MalformedURIException 
    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.
 protected static String fixURI(String str) 
    Fixes a platform dependent filename to standard URI form.
 public XMLEntityManager.ScannedEntity getCurrentEntity() 
 public XMLResourceIdentifier getCurrentResourceIdentifier() 
 Hashtable getDeclaredEntities() 
    Returns the hashtable of declared entities.

    REVISIT: This should be done the "right" way by designing a better way to enumerate the declared entities. For now, this method is needed by the constructor that takes an XMLEntityManager parameter.

 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.
 public XMLEntityScanner getEntityScanner() 
    Returns the entity scanner.
 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 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[] getRecognizedFeatures() 
    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.
 public String[] getRecognizedProperties() 
    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.
 final boolean hasPEReferences() 
    Returns true if the document contains parameter entity references.
 public boolean isDeclaredEntity(String entityName) 
    Checks whether an entity given by name is declared.
 public boolean isEntityDeclInExternalSubset(String entityName) 
    Checks whether the declaration of an entity given by name is // in the external subset.
 public boolean isExternalEntity(String entityName) 
    Checks whether an entity given by name is external.
 public boolean isStandalone() 
    Returns true if the document entity is standalone.
 public boolean isUnparsedEntity(String entityName) 
    Checks whether an entity given by name is unparsed.
 final  void notifyHasPEReferences() 
    Notifies the entity manager that the current document being processed contains parameter entity references.
 static final  void print(XMLEntityManager.ScannedEntity currentEntity) 
    Prints the contents of the buffer.
 public  void reset() 
 public  void reset(XMLComponentManager componentManager) throws XMLConfigurationException 
    Resets the component. The component can query the component manager about any features and properties that affect the operation of the component.
 public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws IOException, XNIException 
    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.
 public  void setEntityHandler(XMLEntityHandler entityHandler) 
    Sets the entity handler. When an entity starts and ends, the entity handler is notified of the change.
 public  void setFeature(String featureId,
    boolean state) throws XMLConfigurationException 
    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.

 public static  void setInstanceFollowRedirects(HttpURLConnection urlCon,
    boolean followRedirects) 
    Attempt to set whether redirects will be followed for an HttpURLConnection. This may fail on earlier JDKs which do not support setting this preference.
 public  void setProperty(String propertyId,
    Object value) throws XMLConfigurationException 
    Sets the value of a property. This method is called by the component manager any time after reset when a property changes value.

    Note: Components should silently ignore properties that do not affect the operation of the component.

 public  void setScannerVersion(short version) 
 public  void setStandalone(boolean standalone) 
    Sets whether the document entity is standalone.
 public String setupCurrentEntity(String name,
    XMLInputSource xmlInputSource,
    boolean literal,
    boolean isExternal) throws IOException, XNIException 
    This method uses the passed-in XMLInputSource to make fCurrentEntity usable for reading.
 public  void startDTDEntity(XMLInputSource xmlInputSource) throws IOException, XNIException 
    Starts the DTD entity. The DTD entity has the "[dtd]" pseudo-name.
 public  void startDocumentEntity(XMLInputSource xmlInputSource) throws IOException, XNIException 
    Starts the document entity. The document entity has the "[xml]" pseudo-name.
 public  void startEntity(String entityName,
    boolean literal) throws IOException, XNIException 
    Starts a named entity.
 public  void startEntity(String name,
    XMLInputSource xmlInputSource,
    boolean literal,
    boolean isExternal) throws IOException, XNIException 
    Starts an entity.

    This method can be used to insert an application defined XML entity stream into the parsing stream.

 public  void startExternalSubset()