Top Description Inners Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.util

public final Class QNameMap<V>

extends Object
Class Inheritance
Imports
org.glassfish.jaxb.runtime.v2.runtime.Name, javax.xml.namespace.QName, java.util.*

Map keyed by QName. This specialized map allows a look up operation without constructing a new QName instance, for a performance reason. This Map assumes that both namespace URI and local name are interned.
Since
JAXB 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private class
private class
private abstract class

Field Summary

Modifier and TypeField and Description
private static final int
DEFAULT_INITIAL_CAPACITY

The default initial capacity - MUST be a power of two.

private static final float
DEFAULT_LOAD_FACTOR

The load factor used when none specified in constructor.

private Set<QNameMap.Entry<V>>
entrySet

Gives an entrySet view of this map

private static final int
MAXIMUM_CAPACITY

The maximum capacity, used if a higher value is implicitly specified by either of the constructors with arguments.

pack-priv transient int
size

The number of key-value mappings contained in this identity hash map.

pack-priv transient QNameMap.Entry<V>[]
table

The table, resized as necessary.

private int
threshold

The next size value at which to resize .

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
addEntry(int hash, String nsUri, String localName, V value, int bucketIndex)

Add a new entry with the specified keys, value and hash code to the specified bucket.

public boolean
containsKey(String nsUri, String localName)

public Set<QNameMap.Entry<V>>
public V

Returns:

the value to which this map maps the specified set of keya, or null if the map contains no mapping for this set of keys.
get
(String
the namespaceUri key whose associated value is to be returned.
nsUri
,
String
the localPart key whose associated value is to be returned.
localPart
)

Returns the value to which the specified keys are mapped in this QNameMap, or null if the map contains no mapping for this key.

public V
get(QName name)

private QNameMap.Entry<V>
getEntry(String nsUri, String localName)

public QNameMap.Entry<V>
getOne()

Returns one random item in the map.

private static int
hash(String x)

Returns a hash value for the specified object.The hash value is computed for the localName.

private static int
indexFor(int h, int length)

Returns index for hash code h.

public boolean
isEmpty()

Returns true if this map is empty.

public Collection<QName>
private Iterator<QNameMap.Entry<V>>
public void
put(String
First key with which the specified value is to be associated.
namespaceUri
,
String
Second key with which the specified value is to be associated.
localname
,
V
value to be associated with the specified key.
value
)

Associates the specified value with the specified keys in this map.

public void
put(QName name, V value)

public void
put(Name name, V value)

public QNameMap<V>
putAll(QNameMap<? extends V>
mappings to be stored in this map.
map
)

Copies all of the mappings from the specified map to this map These mappings will replace any mappings that this map had for any of the keys currently in the specified map.

private void
resize(int newCapacity)

Rehashes the contents of this map into a new array with a larger capacity.

public int

Returns:

the number of keys-value mappings in this map.
size
()

Returns the number of keys-value mappings in this map.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private void
transfer(QNameMap.Entry<V>[] newTable)

Transfer all entries from current table to newTable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_INITIAL_CAPACITYback to summary
private static final int DEFAULT_INITIAL_CAPACITY

The default initial capacity - MUST be a power of two.

DEFAULT_LOAD_FACTORback to summary
private static final float DEFAULT_LOAD_FACTOR

The load factor used when none specified in constructor.

entrySetback to summary
private Set<QNameMap.Entry<V>> entrySet

Gives an entrySet view of this map

MAXIMUM_CAPACITYback to summary
private static final int MAXIMUM_CAPACITY

The maximum capacity, used if a higher value is implicitly specified by either of the constructors with arguments. MUST be a power of two <= 1<<30.

sizeback to summary
pack-priv transient int size

The number of key-value mappings contained in this identity hash map.

tableback to summary
pack-priv transient QNameMap.Entry<V>[] table

The table, resized as necessary. Length MUST Always be a power of two.

thresholdback to summary
private int threshold

The next size value at which to resize . Taking it as MAXIMUM_CAPACITY

Constructor Detail

QNameMapback to summary
public QNameMap()

Method Detail

addEntryback to summary
private void addEntry(int hash, String nsUri, String localName, V value, int bucketIndex)

Add a new entry with the specified keys, value and hash code to the specified bucket. It is the responsibility of this method to resize the table if appropriate.

containsKeyback to summary
public boolean containsKey(String nsUri, String localName)
entrySetback to summary
public Set<QNameMap.Entry<V>> entrySet()
getback to summary
public V get(String nsUri, String localPart)

Returns the value to which the specified keys are mapped in this QNameMap, or null if the map contains no mapping for this key.

Parameters
nsUri:String

the namespaceUri key whose associated value is to be returned.

localPart:String

the localPart key whose associated value is to be returned.

Returns:V

the value to which this map maps the specified set of keya, or null if the map contains no mapping for this set of keys.

See Also
put(String, String, Object)
getback to summary
public V get(QName name)
getEntryback to summary
private QNameMap.Entry<V> getEntry(String nsUri, String localName)
getOneback to summary
public QNameMap.Entry<V> getOne()

Returns one random item in the map. If this map is empty, return null.

This method is useful to obtain the value from a map that only contains one element.

hashback to summary
private static int hash(String x)

Returns a hash value for the specified object.The hash value is computed for the localName.

indexForback to summary
private static int indexFor(int h, int length)

Returns index for hash code h.

isEmptyback to summary
public boolean isEmpty()

Returns true if this map is empty.

keySetback to summary
public Collection<QName> keySet()
newEntryIteratorback to summary
private Iterator<QNameMap.Entry<V>> newEntryIterator()
putback to summary
public void put(String namespaceUri, String localname, V value)

Associates the specified value with the specified keys in this map. If the map previously contained a mapping for this key, the old value is replaced.

Parameters
namespaceUri:String

First key with which the specified value is to be associated.

localname:String

Second key with which the specified value is to be associated.

value:V

value to be associated with the specified key.

putback to summary
public void put(QName name, V value)
putback to summary
public void put(Name name, V value)
putAllback to summary
public QNameMap<V> putAll(QNameMap<? extends V> map)

Copies all of the mappings from the specified map to this map These mappings will replace any mappings that this map had for any of the keys currently in the specified map.

Parameters
map:QNameMap<? extends V>

mappings to be stored in this map.

resizeback to summary
private void resize(int newCapacity)

Rehashes the contents of this map into a new array with a larger capacity. This method is called automatically when the number of keys in this map reaches its threshold.

sizeback to summary
public int size()

Returns the number of keys-value mappings in this map.

Returns:int

the number of keys-value mappings in this map.

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.

Annotations
@Override
transferback to summary
private void transfer(QNameMap.Entry<V>[] newTable)

Transfer all entries from current table to newTable.

org.glassfish.jaxb.runtime.v2.util back to summary

public final Class QNameMap.Entry<V>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int
public final String
localName

The localPart.

pack-priv QNameMap.Entry<V>
public final String
nsUri

The namespace URI.

pack-priv V

Constructor Summary

AccessConstructor and Description
pack-priv
Entry(int h, String nsUri, String localName, V v, QNameMap.Entry<V> n)

Create new entry.

Method Summary

Modifier and TypeMethod and Description
public QName
createQName()

Creates a new QName object from nsUri and localName.

public boolean
equals(Object o)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public V
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public V
setValue(V newValue)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

hashback to summary
pack-priv final int hash
localNameback to summary
public final String localName

The localPart.

nextback to summary
pack-priv QNameMap.Entry<V> next
nsUriback to summary
public final String nsUri

The namespace URI.

valueback to summary
pack-priv V value

Constructor Detail

Entryback to summary
pack-priv Entry(int h, String nsUri, String localName, V v, QNameMap.Entry<V> n)

Create new entry.

Method Detail

createQNameback to summary
public QName createQName()

Creates a new QName object from nsUri and localName.

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getValueback to summary
public V getValue()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
setValueback to summary
public V setValue(V newValue)
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.

Annotations
@Override
org.glassfish.jaxb.runtime.v2.util back to summary

private Class QNameMap.EntryIterator

extends QNameMap<V>.HashIterator<QNameMap.Entry<V>>
Class Inheritance

Field Summary

Inherited from org.glassfish.jaxb.runtime.v2.util.QNameMap.HashIterator:
indexnext

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public QNameMap.Entry<V>
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

Inherited from org.glassfish.jaxb.runtime.v2.util.QNameMap.HashIterator:
hasNextnextEntryremove

Constructor Detail

EntryIteratorback to summary
private EntryIterator()

Method Detail

nextback to summary
public QNameMap.Entry<V> next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Annotations
@Override
org.glassfish.jaxb.runtime.v2.util back to summary

private Class QNameMap.EntrySet

extends AbstractSet<QNameMap.Entry<V>>
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(Object o)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Returns true if this set contains the specified element.

public Iterator<QNameMap.Entry<V>>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this set.

public boolean
remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Removes the specified element from this set if it is present (optional operation).

public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Returns the number of elements in this set (its cardinality).

Inherited from java.util.AbstractSet:
equalshashCoderemoveAll

Constructor Detail

EntrySetback to summary
private EntrySet()

Method Detail

containsback to summary
public boolean contains(Object o)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

Annotations
@Override
iteratorback to summary
public Iterator<QNameMap.Entry<V>> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Annotations
@Override
removeback to summary
public boolean remove(Object o)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Doc from java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this set contains such an element. Returns true if this set contained the element (or equivalently, if this set changed as a result of the call). (This set will not contain the element once the call returns.)

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Annotations
@Override
org.glassfish.jaxb.runtime.v2.util back to summary

private abstract Class QNameMap.HashIterator<E>

extends Object
implements Iterator<E>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Known Direct Subclasses
org.glassfish.jaxb.runtime.v2.util.QNameMap.EntryIterator

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv QNameMap.Entry<V>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

pack-priv QNameMap.Entry<V>
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

indexback to summary
pack-priv int index
nextback to summary
pack-priv QNameMap.Entry<V> next

Constructor Detail

HashIteratorback to summary
pack-priv HashIterator()

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Annotations
@Override
nextEntryback to summary
pack-priv QNameMap.Entry<V> nextEntry()
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override