Top Description Fields Constructors Methods
com.ctc.wstx.util

public final Class BijectiveNsMap

extends Object
Class Inheritance
Imports
java.util.*, javax.xml.XMLConstants, javax.xml.namespace.NamespaceContext

Helper class that implements "bijective map" (Map that allows use of values as keys and vice versa, bidirectional access), and is specifically used for storing namespace binding information. One thing worth noting is that Strings stored are NOT assumed to have been unified (interned) -- if they were, different implementation would be more optimal.

Currently only used by stream writers, but could be more generally useful too.

Field Summary

Modifier and TypeField and Description
pack-priv static final int
DEFAULT_ARRAY_SIZE

Let's plan for having up to 14 explicit namespace declarations (2 defaults, for 'xml' and 'xmlns', are pre-populated)

private static final int
MAX_LOOP_FOR_NEW_PREFIX

As a simple protection against infinite loops, use an arbitrary but bound limit for iterators

pack-priv String[]
mNsStrings

Array that contains { prefix, ns-uri } pairs, up to (but not including) index mScopeEnd.

pack-priv int
pack-priv final int

Constructor Summary

AccessConstructor and Description
private
BijectiveNsMap(int scopeStart, String[] strs)

Method Summary

Modifier and TypeMethod and Description
public String
addGeneratedMapping(String prefixBase, NamespaceContext ctxt, String uri, int[] seqArr)

Method used to add a dynamic binding, and return the prefix used to bind the specified namespace URI.

public String

Returns:

If the prefix was already bound, the URI it was bound to: null if it's a new binding for the current scope.
addMapping
(String
Prefix to bind
prefix
,
String
URI to bind to the prefix
uri
)

Method to add a new prefix-to-URI mapping for the current scope.

public BijectiveNsMap
public static BijectiveNsMap
public String
public String
public List<String>
public int
public int
size()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_ARRAY_SIZEback to summary
pack-priv static final int DEFAULT_ARRAY_SIZE

Let's plan for having up to 14 explicit namespace declarations (2 defaults, for 'xml' and 'xmlns', are pre-populated)

MAX_LOOP_FOR_NEW_PREFIXback to summary
private static final int MAX_LOOP_FOR_NEW_PREFIX

As a simple protection against infinite loops, use an arbitrary but bound limit for iterators

mNsStringsback to summary
pack-priv String[] mNsStrings

Array that contains { prefix, ns-uri } pairs, up to (but not including) index mScopeEnd.

mScopeEndback to summary
pack-priv int mScopeEnd
mScopeStartback to summary
pack-priv final int mScopeStart

Constructor Detail

BijectiveNsMapback to summary
private BijectiveNsMap(int scopeStart, String[] strs)

Method Detail

addGeneratedMappingback to summary
public String addGeneratedMapping(String prefixBase, NamespaceContext ctxt, String uri, int[] seqArr)

Method used to add a dynamic binding, and return the prefix used to bind the specified namespace URI.

addMappingback to summary
public String addMapping(String prefix, String uri)

Method to add a new prefix-to-URI mapping for the current scope. Note that it should NOT be used for the default namespace declaration

Parameters
prefix:String

Prefix to bind

uri:String

URI to bind to the prefix

Returns:String

If the prefix was already bound, the URI it was bound to: null if it's a new binding for the current scope.

createChildback to summary
public BijectiveNsMap createChild()
createEmptyback to summary
public static BijectiveNsMap createEmpty()
findPrefixByUriback to summary
public String findPrefixByUri(String uri)
findUriByPrefixback to summary
public String findUriByPrefix(String prefix)
getPrefixesBoundToUriback to summary
public List<String> getPrefixesBoundToUri(String uri, List<String> l)
localSizeback to summary
public int localSize()
sizeback to summary
public int size()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override