Class DTDSubsetImpl

  • All Implemented Interfaces:
    org.codehaus.stax2.validation.DTDValidationSchema, org.codehaus.stax2.validation.XMLValidationSchema

    public final class DTDSubsetImpl
    extends DTDSubset
    The default implementation of DTDSubset
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.HashMap<java.lang.String,​EntityDecl> mDefinedPEs
      Map (name-to-WEntityDeclaration) that contains all parameter entities defined by this subset.
      (package private) java.util.HashMap<PrefixedName,​DTDElement> mElements  
      (package private) boolean mFullyValidating
      Whether this subset has full validation information; and consequently whether it will do actual validation, or just allow access to type information, notations, entities, and add default attribute values.
      (package private) java.util.HashMap<java.lang.String,​EntityDecl> mGeneralEntities
      Map (name-to-EntityDecl) of general entity declarations (internal, external) for this DTD subset.
      (package private) java.util.List<EntityDecl> mGeneralEntityList
      Lazily instantiated List that contains all notations from mGeneralEntities (preferably in their declaration order; depends on whether platform, ie.
      (package private) boolean mHasNsDefaults
      Flag that indicates whether any of the elements declarared has any attribute default values for namespace pseudo-attributes.
      (package private) boolean mIsCachable
      Whether this subset is cachable.
      (package private) java.util.List<javax.xml.stream.events.NotationDeclaration> mNotationList
      Lazily instantiated List that contains all notations from mNotations (preferably in their declaration order; depends on whether platform, ie.
      (package private) java.util.HashMap<java.lang.String,​javax.xml.stream.events.NotationDeclaration> mNotations
      Map (name-to-NotationDecl) that this subset has defined.
      (package private) java.util.Set<java.lang.String> mRefdGEs
      Set of names of general entities references by this subset.
      (package private) java.util.Set<java.lang.String> mRefdPEs
      Set of names of parameter entities references by this subset.
      • Fields inherited from interface org.codehaus.stax2.validation.XMLValidationSchema

        SCHEMA_ID_DTD, SCHEMA_ID_RELAXNG, SCHEMA_ID_TREX, SCHEMA_ID_W3C_SCHEMA
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private DTDSubsetImpl​(boolean cachable, java.util.HashMap<java.lang.String,​EntityDecl> genEnt, java.util.Set<java.lang.String> refdGEs, java.util.HashMap<java.lang.String,​EntityDecl> paramEnt, java.util.Set<java.lang.String> peRefs, java.util.HashMap<java.lang.String,​javax.xml.stream.events.NotationDeclaration> notations, java.util.HashMap<PrefixedName,​DTDElement> elements, boolean fullyValidating)  
    • Field Detail

      • mIsCachable

        final boolean mIsCachable
        Whether this subset is cachable. Only those external subsets that do not refer to PEs defined by internal subsets (or GEs via default attribute value expansion) are cachable.
      • mFullyValidating

        final boolean mFullyValidating
        Whether this subset has full validation information; and consequently whether it will do actual validation, or just allow access to type information, notations, entities, and add default attribute values.
      • mHasNsDefaults

        final boolean mHasNsDefaults
        Flag that indicates whether any of the elements declarared has any attribute default values for namespace pseudo-attributes.
      • mGeneralEntities

        final java.util.HashMap<java.lang.String,​EntityDecl> mGeneralEntities
        Map (name-to-EntityDecl) of general entity declarations (internal, external) for this DTD subset.
      • mGeneralEntityList

        transient volatile java.util.List<EntityDecl> mGeneralEntityList
        Lazily instantiated List that contains all notations from mGeneralEntities (preferably in their declaration order; depends on whether platform, ie. JDK version, has insertion-ordered Maps available), used by DTD event Objects.
      • mRefdGEs

        final java.util.Set<java.lang.String> mRefdGEs
        Set of names of general entities references by this subset. Note that only those GEs that are referenced by default attribute value definitions count, since GEs in text content are only expanded when reading documents, but attribute default values are expanded when reading DTD subset itself.

        Needed for determinining if external subset materially depends on definitions from internal subset; if so, such subset is not cachable. This also means that information is not stored for non-cachable instance.

      • mDefinedPEs

        final java.util.HashMap<java.lang.String,​EntityDecl> mDefinedPEs
        Map (name-to-WEntityDeclaration) that contains all parameter entities defined by this subset. May be empty if such information will not be needed for use; for example, external subset's definitions are needed, nor are combined DTD set's.
      • mRefdPEs

        final java.util.Set<java.lang.String> mRefdPEs
        Set of names of parameter entities references by this subset. Needed when determinining if external subset materially depends on definitions from internal subset, which is needed to know when caching external subsets.

        Needed for determinining if external subset materially depends on definitions from internal subset; if so, such subset is not cachable. This also means that information is not stored for non-cachable instance.

      • mNotations

        final java.util.HashMap<java.lang.String,​javax.xml.stream.events.NotationDeclaration> mNotations
        Map (name-to-NotationDecl) that this subset has defined.
      • mNotationList

        transient java.util.List<javax.xml.stream.events.NotationDeclaration> mNotationList
        Lazily instantiated List that contains all notations from mNotations (preferably in their declaration order; depends on whether platform, ie. JDK version, has insertion-ordered Maps available), used by DTD event Objects.
    • Constructor Detail

      • DTDSubsetImpl

        private DTDSubsetImpl​(boolean cachable,
                              java.util.HashMap<java.lang.String,​EntityDecl> genEnt,
                              java.util.Set<java.lang.String> refdGEs,
                              java.util.HashMap<java.lang.String,​EntityDecl> paramEnt,
                              java.util.Set<java.lang.String> peRefs,
                              java.util.HashMap<java.lang.String,​javax.xml.stream.events.NotationDeclaration> notations,
                              java.util.HashMap<PrefixedName,​DTDElement> elements,
                              boolean fullyValidating)
    • Method Detail

      • constructInstance

        public static DTDSubsetImpl constructInstance​(boolean cachable,
                                                      java.util.HashMap<java.lang.String,​EntityDecl> genEnt,
                                                      java.util.Set<java.lang.String> refdGEs,
                                                      java.util.HashMap<java.lang.String,​EntityDecl> paramEnt,
                                                      java.util.Set<java.lang.String> refdPEs,
                                                      java.util.HashMap<java.lang.String,​javax.xml.stream.events.NotationDeclaration> notations,
                                                      java.util.HashMap<PrefixedName,​DTDElement> elements,
                                                      boolean fullyValidating)
      • combineWithExternalSubset

        public DTDSubset combineWithExternalSubset​(InputProblemReporter rep,
                                                   DTDSubset extSubset)
                                            throws javax.xml.stream.XMLStreamException
        Method that will combine definitions from internal and external subsets, producing a single DTD set.
        Specified by:
        combineWithExternalSubset in class DTDSubset
        Throws:
        javax.xml.stream.XMLStreamException
      • createValidator

        public org.codehaus.stax2.validation.XMLValidator createValidator​(org.codehaus.stax2.validation.ValidationContext ctxt)
                                                                   throws javax.xml.stream.XMLStreamException
        Specified by:
        createValidator in interface org.codehaus.stax2.validation.XMLValidationSchema
        Specified by:
        createValidator in class DTDSubset
        Throws:
        javax.xml.stream.XMLStreamException
      • getEntityCount

        public int getEntityCount()
        Specified by:
        getEntityCount in interface org.codehaus.stax2.validation.DTDValidationSchema
        Specified by:
        getEntityCount in class DTDSubset
      • getNotationCount

        public int getNotationCount()
        Specified by:
        getNotationCount in interface org.codehaus.stax2.validation.DTDValidationSchema
        Specified by:
        getNotationCount in class DTDSubset
      • getNotationMap

        public java.util.HashMap<java.lang.String,​javax.xml.stream.events.NotationDeclaration> getNotationMap()
        Specified by:
        getNotationMap in class DTDSubset
      • getNotationList

        public java.util.List<javax.xml.stream.events.NotationDeclaration> getNotationList()
        Specified by:
        getNotationList in class DTDSubset
      • isReusableWith

        public boolean isReusableWith​(DTDSubset intSubset)
        Method used in determining whether cached external subset instance can be used with specified internal subset. If ext. subset references any parameter/general entities int subset (re-)defines, it can not; otherwise it can be used.
        Specified by:
        isReusableWith in class DTDSubset
        Returns:
        True if this (external) subset refers to a parameter entity defined in passed-in internal subset.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • throwNotationException

        public static void throwNotationException​(javax.xml.stream.events.NotationDeclaration oldDecl,
                                                  javax.xml.stream.events.NotationDeclaration newDecl)
                                           throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • throwElementException

        public static void throwElementException​(DTDElement oldElem,
                                                 javax.xml.stream.Location loc)
                                          throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • combineMaps

        private static <K,​V> void combineMaps​(java.util.Map<K,​V> m1,
                                                    java.util.Map<K,​V> m2)

        Note: The first Map argument WILL be modified; second one not. Caller needs to ensure this is acceptable.

      • combineElements

        private void combineElements​(InputProblemReporter rep,
                                     java.util.HashMap<PrefixedName,​DTDElement> intElems,
                                     java.util.HashMap<PrefixedName,​DTDElement> extElems)
                              throws javax.xml.stream.XMLStreamException
        Method that will try to merge in elements defined in the external subset, into internal subset; it will also check for redeclarations when doing this, as it's invalid to redeclare elements. Care has to be taken to only check actual redeclarations: placeholders should not cause problems.
        Throws:
        javax.xml.stream.XMLStreamException
      • checkNotations

        private static void checkNotations​(java.util.HashMap<java.lang.String,​javax.xml.stream.events.NotationDeclaration> fromInt,
                                           java.util.HashMap<java.lang.String,​javax.xml.stream.events.NotationDeclaration> fromExt)
                                    throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException