Class CompactNsContext

  • All Implemented Interfaces:
    javax.xml.namespace.NamespaceContext

    public final class CompactNsContext
    extends BaseNsContext
    Simple implementation of separate non-transient namespace context object. Created for start-element event by transient namespace instance updated by stream reader.

    Note about implementation: Location information is only needed (and only needs to passed) if access is made via extended interface; one that can return information about actual Namespace event objects.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int mFirstLocalNs
      Index of first namespace pair in mNamespaces that is declared in scope of element for which this context was constructed.
      (package private) javax.xml.stream.Location mLocation  
      (package private) java.lang.String[] mNamespaces
      Array that contains 2 Strings for each declared default namespace (including default namespace declarations); first is the prefix, second URI.
      (package private) int mNsLength
      Number of entries in mNamespaces (which is twice the number of bindings)
      (package private) java.util.ArrayList<javax.xml.stream.events.Namespace> mNsList
      List only needed to support List accessor from start-element event; created lazily if/as needed.
    • Constructor Summary

      Constructors 
      Constructor Description
      CompactNsContext​(javax.xml.stream.Location loc, java.lang.String[] namespaces, int nsLen, int firstLocal)  
    • Field Detail

      • mLocation

        final javax.xml.stream.Location mLocation
      • mNamespaces

        final java.lang.String[] mNamespaces
        Array that contains 2 Strings for each declared default namespace (including default namespace declarations); first is the prefix, second URI.
      • mNsLength

        final int mNsLength
        Number of entries in mNamespaces (which is twice the number of bindings)
      • mFirstLocalNs

        final int mFirstLocalNs
        Index of first namespace pair in mNamespaces that is declared in scope of element for which this context was constructed. May be equal to mNsLength (which indicates there are no local bindings).
      • mNsList

        transient java.util.ArrayList<javax.xml.stream.events.Namespace> mNsList
        List only needed to support List accessor from start-element event; created lazily if/as needed.
    • Constructor Detail

      • CompactNsContext

        public CompactNsContext​(javax.xml.stream.Location loc,
                                java.lang.String[] namespaces,
                                int nsLen,
                                int firstLocal)
    • Method Detail

      • doGetNamespaceURI

        public java.lang.String doGetNamespaceURI​(java.lang.String prefix)
        Specified by:
        doGetNamespaceURI in class BaseNsContext
        Parameters:
        prefix - Non-null, non-empty prefix (base-class verifies these constraints) to find namespace URI for.
      • doGetPrefix

        public java.lang.String doGetPrefix​(java.lang.String nsURI)
        Specified by:
        doGetPrefix in class BaseNsContext
      • doGetPrefixes

        public java.util.Iterator<java.lang.String> doGetPrefixes​(java.lang.String nsURI)
        Specified by:
        doGetPrefixes in class BaseNsContext
      • getNamespaces

        public java.util.Iterator<javax.xml.stream.events.Namespace> getNamespaces()
        Specified by:
        getNamespaces in class BaseNsContext
      • outputNamespaceDeclarations

        public void outputNamespaceDeclarations​(java.io.Writer w)
                                         throws java.io.IOException
        Method called by CompactStartElement to output all 'local' namespace declarations active in current namespace scope, if any. Local means that declaration was done in scope of current element, not in a parent element.
        Specified by:
        outputNamespaceDeclarations in class BaseNsContext
        Throws:
        java.io.IOException
      • outputNamespaceDeclarations

        public void outputNamespaceDeclarations​(javax.xml.stream.XMLStreamWriter w)
                                         throws javax.xml.stream.XMLStreamException
        Specified by:
        outputNamespaceDeclarations in class BaseNsContext
        Throws:
        javax.xml.stream.XMLStreamException