com.sun.xml.bind.v2.runtime.output

Class NamespaceContextImpl

public final class NamespaceContextImpl extends Object implements NamespaceContext2

Keeps track of in-scope namespace bindings for the marshaller.

This class is also used to keep track of tag names for each element for the marshaller (for the performance reason.)

Nested Class Summary
classNamespaceContextImpl.Element
This model of namespace declarations maintain the following invariants.
Field Summary
booleancollectionMode
True to allow new URIs to be declared.
Constructor Summary
NamespaceContextImpl(XMLSerializer owner)
Method Summary
intcount()
Number of total bindings declared.
StringdeclareNamespace(String namespaceUri, String preferedPrefix, boolean requirePrefix)
intdeclareNsUri(String uri, String preferedPrefix, boolean requirePrefix)
Returns the prefix index to the specified URI.
intforce(String uri, String prefix)
NamespaceContextImpl.ElementgetCurrent()
StringgetNamespaceURI(int prefixIndex)
StringgetNamespaceURI(String prefix)
Gets the namespace URI that is bound to the specified prefix.
StringgetPrefix(int prefixIndex)
Gets the prefix from a prefix index.
StringgetPrefix(String uri)
Returns the prefix of the specified URI, or null if none exists.
Iterator<String>getPrefixes(String uri)
intgetPrefixIndex(String uri)
Returns the prefix index of the specified URI.
NamespacePrefixMappergetPrefixMapper()
intput(String uri, String prefix)
Puts this new binding into the declared prefixes list without doing any duplicate check.
voidreset()
voidsetPrefixMapper(NamespacePrefixMapper mapper)

Field Detail

collectionMode

public boolean collectionMode
True to allow new URIs to be declared. False otherwise.

Constructor Detail

NamespaceContextImpl

public NamespaceContextImpl(XMLSerializer owner)

Method Detail

count

public int count()
Number of total bindings declared.

declareNamespace

public String declareNamespace(String namespaceUri, String preferedPrefix, boolean requirePrefix)

declareNsUri

public int declareNsUri(String uri, String preferedPrefix, boolean requirePrefix)
Returns the prefix index to the specified URI. This method allocates a new URI if necessary.

force

public int force(String uri, String prefix)

getCurrent

public NamespaceContextImpl.Element getCurrent()

getNamespaceURI

public String getNamespaceURI(int prefixIndex)

getNamespaceURI

public String getNamespaceURI(String prefix)
Gets the namespace URI that is bound to the specified prefix.

Returns: null if the prefix is unbound.

getPrefix

public String getPrefix(int prefixIndex)
Gets the prefix from a prefix index. The behavior is undefined if the index is out of range.

getPrefix

public String getPrefix(String uri)
Returns the prefix of the specified URI, or null if none exists.

getPrefixes

public Iterator<String> getPrefixes(String uri)

getPrefixIndex

public int getPrefixIndex(String uri)
Returns the prefix index of the specified URI. It is an error if the URI is not declared.

getPrefixMapper

public NamespacePrefixMapper getPrefixMapper()

put

public int put(String uri, String prefix)
Puts this new binding into the declared prefixes list without doing any duplicate check. This can be used to forcibly set namespace declarations.

Most of the time NamespaceContextImpl shall be used.

Returns: the index of this new binding.

reset

public void reset()

setPrefixMapper

public void setPrefixMapper(NamespacePrefixMapper mapper)