org.apache.jdo.impl.sco
Class HashMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byorg.apache.jdo.impl.sco.HashMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, SCO, SCOMap, java.io.Serializable

public class HashMap
extends java.util.HashMap
implements SCOMap

A mutable 2nd class object that represents HashMap.

Version:
1.0.1
Author:
Marina Vatkina
See Also:
HashMap, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
HashMap(java.lang.Class keyType, java.lang.Class valueType, boolean allowNulls)
          Creates a new empty HashMap object.
HashMap(java.lang.Class keyType, java.lang.Class valueType, boolean allowNulls, int initialCapacity)
          Creates a new empty HashMap object that has the specified initial capacity.
HashMap(java.lang.Class keyType, java.lang.Class valueType, boolean allowNulls, int initialCapacity, float loadFactor)
          Creates a new empty HashMap object that has the specified initial capacity..
 
Method Summary
 boolean allowNulls()
          Returns whether nulls are permitted as keys or values.
 void clear()
          Removes all of the elements from this map.
 void clearInternal()
          Clears Map without recording the event.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 boolean containsKey(java.lang.Object key)
          These methods need to thaw the map before performing the operation.
 boolean containsValue(java.lang.Object value)
           
 java.util.Iterator eitherIterator()
          Get an iterator regardless of whether the map is frozen.
 java.util.Set entrySet()
           
 boolean equals(java.lang.Object o)
           
 java.util.Iterator frozenIterator()
          Get an iterator over the frozen elements of this map.
 java.lang.Object get(java.lang.Object key)
           
 java.util.Collection getAddedKeys()
          Returns the Collection of added keys
 java.util.Collection getAddedValues()
          Returns the Collection of added values
 java.lang.String getFieldName()
          Returns the field name
 java.lang.Class getKeyType()
          Returns the type of the key assignment compatible with all keys of this map.
 java.lang.Object getOwner()
          Returns the owner object of the SCO instance
 java.util.Collection getRemovedKeys()
          Returns the Collection of removed keys
 java.util.Collection getRemovedValues()
          Returns the Collection of removed values
 java.lang.Class getValueType()
          Returns the type of the value assignment compatible with all values of this map.
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Set keySet()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Associates the specified value with the specified key in this map.
 void putAll(java.util.Map t)
          Copies all of the mappings from the specified map to this one.
 void putAllInternal(java.util.Map t)
          Copies all of the mappings from the specified map to this one without recording the event.
 void putInternal(java.lang.Object key, java.lang.Object value)
          Associates the specified value with the specified key in this map without recording the event.
 java.lang.Object remove(java.lang.Object key)
          Removes the mapping for this key from this map if present.
 void removeInternal(java.lang.Object key)
          Removes mappings from the Map without recording the event.
 void reset()
          Resets removed and added lists after flush
 void setFrozen(java.util.Map.Entry[] entries)
          Set the contents of this Map from the frozen entries.
 void setOwner(java.lang.Object owner, int fieldNumber)
          Sets the owner and field number.
 int size()
           
 java.lang.String toString()
           
 void unsetOwner(java.lang.Object owner, int fieldNumber)
          Nullifies references to the owner Object iff the passed in owner and fieldNumber match.
 java.util.Collection values()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HashMap

public HashMap(java.lang.Class keyType,
               java.lang.Class valueType,
               boolean allowNulls)
Creates a new empty HashMap object.

Parameters:
keyType - the type of the keys allowed.
valueType - the type of the values allowed.
allowNulls - true if nulls are allowed.
See Also:
HashMap

HashMap

public HashMap(java.lang.Class keyType,
               java.lang.Class valueType,
               boolean allowNulls,
               int initialCapacity)
Creates a new empty HashMap object that has the specified initial capacity.

Parameters:
keyType - the type of the keys allowed.
valueType - the type of the values allowed.
allowNulls - true if nulls are allowed
initialCapacity - the initial capacity of the hash map.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero.
See Also:
HashMap

HashMap

public HashMap(java.lang.Class keyType,
               java.lang.Class valueType,
               boolean allowNulls,
               int initialCapacity,
               float loadFactor)
Creates a new empty HashMap object that has the specified initial capacity..

Parameters:
keyType - the type of the keys allowed.
valueType - the type of the values allowed.
allowNulls - true if nulls are allowed
initialCapacity - the initial capacity of the hash map.
loadFactor - the load factor of the hash map.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero.
See Also:
HashMap
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.

Specified by:
put in interface java.util.Map
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.
See Also:
HashMap

putAll

public void putAll(java.util.Map t)
Copies all of the mappings from the specified map to this one. These mappings replace any mappings that this map had for any of the keys currently in the specified Map.

Specified by:
putAll in interface java.util.Map
Parameters:
t - Mappings to be stored in this map.
See Also:
HashMap

remove

public java.lang.Object remove(java.lang.Object key)
Removes the mapping for this key from this map if present.

Specified by:
remove in interface java.util.Map
Parameters:
key - key whose mapping is to be removed from the map.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.
See Also:
HashMap

clear

public void clear()
Removes all of the elements from this map.

Specified by:
clear in interface java.util.Map
See Also:
HashMap

clone

public java.lang.Object clone()
Creates and returns a copy of this object.

Mutable Second Class Objects are required to provide a public clone method in order to allow for copying PersistenceCapable objects. In contrast to Object.clone(), this method must not throw a CloneNotSupportedException.

Specified by:
clone in interface SCO

containsKey

public boolean containsKey(java.lang.Object key)
These methods need to thaw the map before performing the operation.

Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

size

public int size()
Specified by:
size in interface java.util.Map

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

toString

public java.lang.String toString()

reset

public void reset()
Description copied from interface: SCOMap
Resets removed and added lists after flush

Specified by:
reset in interface SCOMap
See Also:
SCOMap.reset()

putInternal

public void putInternal(java.lang.Object key,
                        java.lang.Object value)
Description copied from interface: SCOMap
Associates the specified value with the specified key in this map without recording the event. Used internaly to initially populate the Map.

Specified by:
putInternal in interface SCOMap
See Also:
SCOMap.putInternal(Object key, Object value)

putAllInternal

public void putAllInternal(java.util.Map t)
Description copied from interface: SCOMap
Copies all of the mappings from the specified map to this one without recording the event. Used internaly to initially populate the Map.

Specified by:
putAllInternal in interface SCOMap
See Also:
SCOMap.putAllInternal(Map t)

getAddedKeys

public java.util.Collection getAddedKeys()
Description copied from interface: SCOMap
Returns the Collection of added keys

Specified by:
getAddedKeys in interface SCOMap
Returns:
Collection of the added keys as java.util.Collection
See Also:
SCOMap.getAddedKeys()

getAddedValues

public java.util.Collection getAddedValues()
Description copied from interface: SCOMap
Returns the Collection of added values

Specified by:
getAddedValues in interface SCOMap
Returns:
Collection of the added values as java.util.Collection
See Also:
SCOMap.getAddedValues()

getRemovedKeys

public java.util.Collection getRemovedKeys()
Description copied from interface: SCOMap
Returns the Collection of removed keys

Specified by:
getRemovedKeys in interface SCOMap
Returns:
Collection of the removed keys as java.util.Collection
See Also:
SCOMap.getRemovedKeys()

getRemovedValues

public java.util.Collection getRemovedValues()
Description copied from interface: SCOMap
Returns the Collection of removed values

Specified by:
getRemovedValues in interface SCOMap
Returns:
Collection of the removed values as java.util.Collection
See Also:
SCOMap.getRemovedValues()

clearInternal

public void clearInternal()
Description copied from interface: SCOMap
Clears Map without recording the event. Used internaly to clear the Map

Specified by:
clearInternal in interface SCOMap
See Also:
SCOMap.clearInternal()

removeInternal

public void removeInternal(java.lang.Object key)
Description copied from interface: SCOMap
Removes mappings from the Map without recording the event. Used internally to update the Map

Specified by:
removeInternal in interface SCOMap
See Also:
SCOMap.removeInternal(Object key)

unsetOwner

public void unsetOwner(java.lang.Object owner,
                       int fieldNumber)
Description copied from interface: SCO
Nullifies references to the owner Object iff the passed in owner and fieldNumber match.

Specified by:
unsetOwner in interface SCO
Parameters:
owner - the existing owner object.
fieldNumber - the existing number of the field.
See Also:
SCO.unsetOwner(Object owner, int fieldNumber)

setOwner

public void setOwner(java.lang.Object owner,
                     int fieldNumber)
Description copied from interface: SCO
Sets the owner and field number. Called by StateManager upon assignment to a managed instance.

Specified by:
setOwner in interface SCO
Parameters:
owner - the owner object.
fieldNumber - the number of the field associated with this instance.
See Also:
(Object owner, int fieldNumber)

getOwner

public java.lang.Object getOwner()
Description copied from interface: SCO
Returns the owner object of the SCO instance

Specified by:
getOwner in interface SCO
Returns:
owner object
See Also:
SCO.getOwner()

getFieldName

public java.lang.String getFieldName()
Description copied from interface: SCO
Returns the field name

Specified by:
getFieldName in interface SCO
Returns:
field name as java.lang.String
See Also:
SCO.getFieldName()

getKeyType

public java.lang.Class getKeyType()
Description copied from interface: SCOMap
Returns the type of the key assignment compatible with all keys of this map.

Specified by:
getKeyType in interface SCOMap
Returns:
the type of the key assignment compatible with all keys.
See Also:
{

getValueType

public java.lang.Class getValueType()
Description copied from interface: SCOMap
Returns the type of the value assignment compatible with all values of this map.

Specified by:
getValueType in interface SCOMap
Returns:
the type of the value assignment compatible with all values.
See Also:
{

allowNulls

public boolean allowNulls()
Description copied from interface: SCOMap
Returns whether nulls are permitted as keys or values.

Specified by:
allowNulls in interface SCOMap
Returns:
true if nulls are permitted as keys or values.
See Also:
{

setFrozen

public void setFrozen(java.util.Map.Entry[] entries)
Set the contents of this Map from the frozen entries.

Specified by:
setFrozen in interface SCOMap
Parameters:
entries - the frozen entries
Since:
1.0.1

eitherIterator

public java.util.Iterator eitherIterator()
Get an iterator regardless of whether the map is frozen. If frozen, get a frozen iterator. If thawed, get a regular iterator.

Specified by:
eitherIterator in interface SCOMap
Returns:
the iterator.
Since:
1.0.1

frozenIterator

public java.util.Iterator frozenIterator()
Get an iterator over the frozen elements of this map. This allows iteration of the elements without thawing them, as is needed for transcription.

Specified by:
frozenIterator in interface SCOMap
Returns:
the iterator.
Since:
1.0.1


Copyright © 2005 Apache Software Foundation. All Rights Reserved.