Package com.ctc.wstx.sr
Class CompactNsContext
- java.lang.Object
-
- com.ctc.wstx.util.BaseNsContext
-
- com.ctc.wstx.sr.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 inmNamespaces
(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.-
Fields inherited from class com.ctc.wstx.util.BaseNsContext
UNDECLARED_NS_URI
-
-
Constructor Summary
Constructors Constructor Description CompactNsContext(javax.xml.stream.Location loc, java.lang.String[] namespaces, int nsLen, int firstLocal)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
doGetNamespaceURI(java.lang.String prefix)
java.lang.String
doGetPrefix(java.lang.String nsURI)
java.util.Iterator<java.lang.String>
doGetPrefixes(java.lang.String nsURI)
java.util.Iterator<javax.xml.stream.events.Namespace>
getNamespaces()
void
outputNamespaceDeclarations(java.io.Writer w)
Method called byCompactStartElement
to output all 'local' namespace declarations active in current namespace scope, if any.void
outputNamespaceDeclarations(javax.xml.stream.XMLStreamWriter w)
-
Methods inherited from class com.ctc.wstx.util.BaseNsContext
getNamespaceURI, getPrefix, getPrefixes
-
-
-
-
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 inmNamespaces
(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 tomNsLength
(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.
-
-
Method Detail
-
doGetNamespaceURI
public java.lang.String doGetNamespaceURI(java.lang.String prefix)
- Specified by:
doGetNamespaceURI
in classBaseNsContext
- 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 classBaseNsContext
-
doGetPrefixes
public java.util.Iterator<java.lang.String> doGetPrefixes(java.lang.String nsURI)
- Specified by:
doGetPrefixes
in classBaseNsContext
-
getNamespaces
public java.util.Iterator<javax.xml.stream.events.Namespace> getNamespaces()
- Specified by:
getNamespaces
in classBaseNsContext
-
outputNamespaceDeclarations
public void outputNamespaceDeclarations(java.io.Writer w) throws java.io.IOException
Method called byCompactStartElement
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 classBaseNsContext
- Throws:
java.io.IOException
-
outputNamespaceDeclarations
public void outputNamespaceDeclarations(javax.xml.stream.XMLStreamWriter w) throws javax.xml.stream.XMLStreamException
- Specified by:
outputNamespaceDeclarations
in classBaseNsContext
- Throws:
javax.xml.stream.XMLStreamException
-
-