Top Description Fields Constructors Methods
org.eclipse.persistence.indirection

public Class IndirectMap<K, V>

extends Hashtable<K, V>
implements CollectionChangeTracker, IndirectCollection<Map.Entry<K, V>, Map<K, V>>
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.indirection.IndirectCollection, org.eclipse.persistence.indirection.IndirectContainer, org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker, org.eclipse.persistence.descriptors.changetracking.ChangeTracker
Type Parameters
<K>
the type of keys maintained by this map
<V>
the type of mapped values
Imports
java.beans.PropertyChangeListener, java.util.Collection, .Enumeration, .Hashtable, .Iterator, .Map, .Objects, .Set, .Spliterator, java.util.function.BiConsumer, .BiFunction, .Consumer, .Function, .Predicate, java.util.stream.Stream, org.eclipse.persistence.descriptors.changetracking.CollectionChangeEvent, .CollectionChangeTracker, .MapChangeEvent

IndirectMap allows a domain class to take advantage of TopLink indirection without having to declare its instance variable as a ValueHolderInterface.

To use an IndirectMap:

EclipseLink will place an IndirectMap in the instance variable when the containing domain object is read from the database. With the first message sent to the IndirectMap, the contents are fetched from the database and normal Hashtable/Map behavior is resumed.
Author
Big Country
Since
TOPLink/Java 2.5
See Also
org.eclipse.persistence.mappings.CollectionMapping, org.eclipse.persistence.indirection.IndirectList

Field Summary

Modifier and TypeField and Description
private transient String
attributeName

The mapping attribute name, used to raise change events.

private transient PropertyChangeListener
changeListener

Change tracking listener.

protected volatile Hashtable<K, V>
delegate

Reduce type casting

protected int
initialCapacity

Store initial size for lazy init.

protected float
loadFactor

Hides java.util.Hashtable.loadFactor.

Store load factor for lazy init.
protected volatile ValueHolderInterface<Map<K, V>>
valueHolder

Delegate indirection behavior to a value holder

Constructor Summary

AccessConstructor and Description
public
IndirectMap()

PUBLIC: Construct a new, empty IndirectMap with a default capacity and load factor.

public
IndirectMap(int
the initial capacity of the hashtable
initialCapacity
)

PUBLIC: Construct a new, empty IndirectMap with the specified initial capacity and default load factor.

public
IndirectMap(int
the initial capacity of the hashtable
initialCapacity
,
float
a number between 0.0 and 1.0
loadFactor
)

PUBLIC: Construct a new, empty IndirectMap with the specified initial capacity and load factor.

public
IndirectMap(Map<? extends K, ? extends V>
a map containing the mappings to use
m
)

PUBLIC: Construct a new IndirectMap with the same mappings as the given Map.

Method Summary

Modifier and TypeMethod and Description
public PropertyChangeListener
public void
protected Hashtable<K, V>
buildDelegate()

Return the freshly-built delegate.

public synchronized void
clear()

Overrides java.util.Hashtable.clear.

Implements java.util.Map.clear.

Clears this hashtable so that it contains no keys.
public void
clearDeferredChanges()

Implements org.eclipse.persistence.indirection.IndirectCollection.clearDeferredChanges.

INTERNAL: clear any changes that have been deferred to instantiation.
public synchronized Object
clone()

Overrides java.util.Hashtable.clone.

Creates a shallow copy of this hashtable.
public synchronized V
compute(K
key with which the specified value is to be associated
key
,
BiFunction<? super K, ? super V, ? extends V>
the remapping function to compute a value
remappingFunction
)

Overrides java.util.Hashtable.compute.

Overrides default java.util.Map.compute.

Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping).
public synchronized V
computeIfAbsent(K
key with which the specified value is to be associated
key
,
Function<? super K, ? extends V>
the mapping function to compute a value
mappingFunction
)

Overrides java.util.Hashtable.computeIfAbsent.

Overrides default java.util.Map.computeIfAbsent.

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null.
public synchronized V
computeIfPresent(K
key with which the specified value is to be associated
key
,
BiFunction<? super K, ? super V, ? extends V>
the remapping function to compute a value
remappingFunction
)

Overrides java.util.Hashtable.computeIfPresent.

Overrides default java.util.Map.computeIfPresent.

If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value.
public synchronized boolean
contains(Object
a value to search for
value
)

Overrides java.util.Hashtable.contains.

Tests if some key maps into the specified value in this hashtable.
public synchronized boolean
containsKey(Object
possible key
key
)

Overrides java.util.Hashtable.containsKey.

Implements java.util.Map.containsKey.

Tests if the specified object is a key in this hashtable.
public boolean
containsValue(Object
value whose presence in this hashtable is to be tested
value
)

Overrides java.util.Hashtable.containsValue.

Implements java.util.Map.containsValue.

Returns true if this hashtable maps one or more keys to this value.
public synchronized Enumeration<V>
elements()

Overrides java.util.Hashtable.elements.

Returns an enumeration of the values in this hashtable.
public Set<Map.Entry<K, V>>
entrySet()

Overrides java.util.Hashtable.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
public synchronized boolean
equals(Object
object to be compared for equality with this hashtable
o
)

Overrides java.util.Hashtable.equals.

Implements java.util.Map.equals.

Compares the specified Object with this Map for equality, as per the definition in the Map interface.
public synchronized void
forEach(BiConsumer<? super K, ? super V>
The action to be performed for each entry
action
)

Overrides java.util.Hashtable.forEach.

Overrides default java.util.Map.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.
public synchronized V
get(Object
the key whose associated value is to be returned
key
)

Overrides java.util.Hashtable.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
public Collection<Map.Entry<K, V>>
getAddedElements()

Implements org.eclipse.persistence.indirection.IndirectCollection.getAddedElements.

INTERNAL: Return the elements that have been added before instantiation.
protected Hashtable<K, V>
getDelegate()

INTERNAL: Check whether the contents have been read from the database.

public Map<K, V>
getDelegateObject()

Implements org.eclipse.persistence.indirection.IndirectCollection.getDelegateObject.

INTERNAL: Return the real collection object.
public synchronized V
getOrDefault(Object
the key whose associated value is to be returned
key
,
V
the default mapping of the key
defaultValue
)

Overrides java.util.Hashtable.getOrDefault.

Overrides default java.util.Map.getOrDefault.

Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.
public Collection<Map.Entry<K, V>>
getRemovedElements()

Implements org.eclipse.persistence.indirection.IndirectCollection.getRemovedElements.

INTERNAL: Return the elements that have been removed before instantiation.
public String
getTrackedAttributeName()

Implements org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker.getTrackedAttributeName.

INTERNAL: Return the mapping attribute name, used to raise change events.
public ValueHolderInterface<Map<K, V>>
public boolean
hasDeferredChanges()

Implements org.eclipse.persistence.indirection.IndirectCollection.hasDeferredChanges.

INTERNAL: Return if any elements that have been added or removed before instantiation.
public synchronized int
hashCode()

Overrides java.util.Hashtable.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this Map as per the definition in the Map interface.
public boolean
hasTrackedPropertyChangeListener()

INTERNAL: Return if the collection has a property change listener for change tracking.

protected void
initialize(int initialCapacity, float loadFactor)

Initialize the instance.

protected void
initialize(Map<? extends K, ? extends V> m)

Initialize the instance.

public boolean
isEmpty()

Overrides java.util.Hashtable.isEmpty.

Implements java.util.Map.isEmpty.

Tests if this hashtable maps no keys to values.
public boolean
isInstantiated()

Implements org.eclipse.persistence.indirection.IndirectContainer.isInstantiated.

PUBLIC: Return whether the contents have been read from the database.
public synchronized Enumeration<K>
keys()

Overrides java.util.Hashtable.keys.

Returns an enumeration of the keys in this hashtable.
public Set<K>
keySet()

Overrides java.util.Hashtable.keySet.

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.
public synchronized V
merge(K
key with which the resulting value is to be associated
key
,
V
the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key
value
,
BiFunction<? super V, ? super V, ? extends V>
the remapping function to recompute a value if present
remappingFunction
)

Overrides java.util.Hashtable.merge.

Overrides default java.util.Map.merge.

If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value.
public synchronized V
put(K
the hashtable key
key
,
V
the value
value
)

Overrides java.util.Hashtable.put.

Implements java.util.Map.put.

Maps the specified key to the specified value in this hashtable.
public synchronized void
putAll(Map<? extends K, ? extends V>
mappings to be stored in this map
t
)

Overrides java.util.Hashtable.putAll.

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this hashtable.
public synchronized V
putIfAbsent(K
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Overrides java.util.Hashtable.putIfAbsent.

Overrides default java.util.Map.putIfAbsent.

If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value.
protected void
raiseAddChangeEvent(Object key, Object value)

Raise the add change event and relationship maintainence.

protected void
raiseRemoveChangeEvent(Object key, Object value)

Raise the remove change event.

protected void
rehash()

Overrides java.util.Hashtable.rehash.

Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.
public synchronized boolean
remove(Object
key with which the specified value is associated
key
,
Object
value expected to be associated with the specified key
value
)

Overrides java.util.Hashtable.remove.

Overrides default java.util.Map.remove.

Removes the entry for the specified key only if it is currently mapped to the specified value.
public synchronized V
remove(Object
the key that needs to be removed
key
)

Overrides java.util.Hashtable.remove.

Implements java.util.Map.remove.

Removes the key (and its corresponding value) from this hashtable.
public synchronized V
replace(K
key with which the specified value is associated
key
,
V
value to be associated with the specified key
value
)

Overrides java.util.Hashtable.replace.

Overrides default java.util.Map.replace.

Replaces the entry for the specified key only if it is currently mapped to some value.
public synchronized boolean
replace(K
key with which the specified value is associated
key
,
V
value expected to be associated with the specified key
oldValue
,
V
value to be associated with the specified key
newValue
)

Overrides java.util.Hashtable.replace.

Overrides default java.util.Map.replace.

Replaces the entry for the specified key only if currently mapped to the specified value.
public synchronized void
replaceAll(BiFunction<? super K, ? super V, ? extends V>
the function to apply to each entry
function
)

Overrides java.util.Hashtable.replaceAll.

Overrides default java.util.Map.replaceAll.

Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception.
public void
setTrackedAttributeName(String attributeName)

Implements org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker.setTrackedAttributeName.

INTERNAL: Set the mapping attribute name, used to raise change events.
public void
setUseLazyInstantiation(boolean useLazyInstantiation)

Implements org.eclipse.persistence.indirection.IndirectCollection.setUseLazyInstantiation.

INTERNAL Set whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB
public void
public int
size()

Overrides java.util.Hashtable.size.

Implements java.util.Map.size.

Returns the number of keys in this hashtable.
public String
toString()

Overrides java.util.Hashtable.toString.

PUBLIC: Use the Hashtable.toString(); but wrap it with braces to indicate there is a bit of indirection.
public Collection<V>
values()

Overrides java.util.Hashtable.values.

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.