com.triactive.jdo.sco
Class Map

java.lang.Object
  extended by com.triactive.jdo.sco.Map
All Implemented Interfaces:
SCO, java.lang.Cloneable, java.util.Map

public class Map
extends java.lang.Object
implements java.util.Map, SCO, java.lang.Cloneable

A map object which is backed "directly" by the database. SCO fields declared as type java.util.Map are populated with objects of this type whenever the field is actively being managed by the state manager.

When actively tethered to its owning object, the contents of the map are not mirrored in memory. Operations on the map "pass through" directly to the database.

An instance of this class "disconnects" from it backing storage whenever unsetOwner() is called. This occurs automatically in a variety of scenarios, such as when the object is cloned or when its owning object (the one whose Map field refers to it) transitions to a transient state. When a disconnect occurs, the object switches to being backed by a normal in-memory HashMap and subsequently behaves like a normal HashMap. If the disconnect occurs during a transaction the contents of the map are fully loaded from the database. Subsequent changes to the map affect only the in-memory copy. Once disconnected from its owner, an instance is never reconnected.

Author:
Mike Martin

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
Map(StateManager ownerSM, java.lang.String fieldName)
           
Map(StateManager ownerSM, java.lang.String fieldName, java.lang.Class keyType, java.lang.Class valueType, boolean allowNulls)
           
 
Method Summary
 void applyUpdates()
          Applies any pending updates for this object to the data store.
 void clear()
           
 java.lang.Object clone()
          Creates and returns a copy of this object.
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set entrySet()
           
 boolean equals(java.lang.Object o)
           
 java.lang.Object get(java.lang.Object key)
           
 java.lang.String getFieldName()
          Returns the field name.
 java.lang.Object getOwner()
          Returns the owner object of the SCO instance.
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Set keySet()
           
 void makeDirty()
          Marks object dirty.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map m)
           
 java.lang.Object remove(java.lang.Object key)
           
 void setValueFrom(java.lang.Object o)
          Assigns the value of this second-class object from an existing object of the same or compatible type.
 int size()
           
 java.lang.String toString()
           
 void unsetOwner()
          Nullifies references to the owner Object and Field.
 java.util.Collection values()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Map

public Map(StateManager ownerSM,
           java.lang.String fieldName)

Map

public Map(StateManager ownerSM,
           java.lang.String fieldName,
           java.lang.Class keyType,
           java.lang.Class valueType,
           boolean allowNulls)
Method Detail

setValueFrom

public void setValueFrom(java.lang.Object o)
Description copied from interface: SCO
Assigns the value of this second-class object from an existing object of the same or compatible type.

Specified by:
setValueFrom in interface SCO
Parameters:
o - the object from which to copy the value.

getFieldName

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

Specified by:
getFieldName in interface SCO
Returns:
field name

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

unsetOwner

public void unsetOwner()
Description copied from interface: SCO
Nullifies references to the owner Object and Field.

Specified by:
unsetOwner in interface SCO

applyUpdates

public void applyUpdates()
Description copied from interface: SCO
Applies any pending updates for this object to the data store.

Specified by:
applyUpdates in interface SCO

makeDirty

public void makeDirty()
Description copied from interface: SCO
Marks object dirty.

Specified by:
makeDirty in interface SCO

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.

Overrides:
clone in class java.lang.Object

equals

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

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map
Overrides:
hashCode in class java.lang.Object

size

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

isEmpty

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

containsValue

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

containsKey

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

get

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

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map

putAll

public void putAll(java.util.Map m)
Specified by:
putAll in interface java.util.Map

remove

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

clear

public void clear()
Specified by:
clear in interface java.util.Map

keySet

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

values

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

entrySet

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright ? 2001 TriActive, Inc. All Rights Reserved.