org.apache.cayenne.util
Class PersistentObjectMap

java.lang.Object
  extended by org.apache.cayenne.util.RelationshipFault
      extended by org.apache.cayenne.util.PersistentObjectMap
All Implemented Interfaces:
java.io.Serializable, java.util.Map, ValueHolder

public class PersistentObjectMap
extends RelationshipFault
implements java.util.Map, ValueHolder

Since:
3.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
protected  Accessor mapKeyAccessor
           
protected  java.util.Map objectMap
           
 
Fields inherited from class org.apache.cayenne.util.RelationshipFault
relationshipName, relationshipOwner
 
Constructor Summary
PersistentObjectMap(Persistent relationshipOwner, java.lang.String relationshipName, Accessor mapKeyAccessor)
          Creates PersistentObjectList initializing it with list owner persistent object and relationship name that this list maps to.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set entrySet()
           
 java.lang.Object get(java.lang.Object key)
           
 java.lang.Object getValue()
          Returns an object stored by this ValueHolder.
 java.lang.Object getValueDirectly()
          Retrieves ValueHolder value without triggering fault resolution.
protected  java.util.Map indexCollection(java.util.Collection collection)
          Converts a collection into a map indexed by map key.
 void invalidate()
          Turns a ValueHolder into a fault.
 boolean isEmpty()
           
 boolean isFault()
          Returns true if the internal value is not yet resolved.
 java.util.Set keySet()
           
protected  void postprocessAdd(java.util.Collection collection)
           
protected  void postprocessAdd(java.lang.Object addedObject)
           
protected  void postprocessRemove(java.util.Collection collection)
           
protected  void postprocessRemove(java.lang.Object removedObject)
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map map)
           
 void putDirectly(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object remove(java.lang.Object key)
           
 void removeDirectly(java.lang.Object key)
           
protected  java.util.Map resolvedObjectMap()
          Returns internal objects list resolving it if needed.
 void setObjectMap(java.util.Map objectMap)
           
 java.lang.Object setValue(java.lang.Object value)
          Sets an object stored by this ValueHolder.
 java.lang.Object setValueDirectly(java.lang.Object value)
          Sets ValueHolder vaue without triggering fault resolution.
 int size()
           
 java.lang.String toString()
           
 java.util.Collection values()
           
 
Methods inherited from class org.apache.cayenne.util.RelationshipFault
getRelationshipName, getRelationshipOwner, isTransientParent, isUncommittedParent, resolveFromDB, updateReverse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

objectMap

protected java.util.Map objectMap

mapKeyAccessor

protected Accessor mapKeyAccessor
Constructor Detail

PersistentObjectMap

public PersistentObjectMap(Persistent relationshipOwner,
                           java.lang.String relationshipName,
                           Accessor mapKeyAccessor)
Creates PersistentObjectList initializing it with list owner persistent object and relationship name that this list maps to.

Parameters:
relationshipOwner - persistent object that owns this list.
relationshipName - a query used to resolve the list
mapKeyAccessor - an accessor that can read a map key from an object.
Method Detail

getValue

public java.lang.Object getValue()
                          throws CayenneRuntimeException
Description copied from interface: ValueHolder
Returns an object stored by this ValueHolder.

Specified by:
getValue in interface ValueHolder
Throws:
CayenneRuntimeException

getValueDirectly

public java.lang.Object getValueDirectly()
                                  throws CayenneRuntimeException
Description copied from interface: ValueHolder
Retrieves ValueHolder value without triggering fault resolution.

Specified by:
getValueDirectly in interface ValueHolder
Throws:
CayenneRuntimeException

invalidate

public void invalidate()
Description copied from interface: ValueHolder
Turns a ValueHolder into a fault.

Specified by:
invalidate in interface ValueHolder

isFault

public boolean isFault()
Description copied from interface: ValueHolder
Returns true if the internal value is not yet resolved.

Specified by:
isFault in interface ValueHolder

setValue

public java.lang.Object setValue(java.lang.Object value)
                          throws CayenneRuntimeException
Description copied from interface: ValueHolder
Sets an object stored by this ValueHolder.

Specified by:
setValue in interface ValueHolder
Parameters:
value - a new value of the ValueHolder.
Returns:
a previous value saved in the ValueHolder.
Throws:
CayenneRuntimeException

setValueDirectly

public java.lang.Object setValueDirectly(java.lang.Object value)
                                  throws CayenneRuntimeException
Description copied from interface: ValueHolder
Sets ValueHolder vaue without triggering fault resolution.

Specified by:
setValueDirectly in interface ValueHolder
Throws:
CayenneRuntimeException

setObjectMap

public void setObjectMap(java.util.Map objectMap)

resolvedObjectMap

protected java.util.Map resolvedObjectMap()
Returns internal objects list resolving it if needed.


indexCollection

protected java.util.Map indexCollection(java.util.Collection collection)
Converts a collection into a map indexed by map key.


toString

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

postprocessAdd

protected void postprocessAdd(java.lang.Object addedObject)

postprocessAdd

protected void postprocessAdd(java.util.Collection collection)

postprocessRemove

protected void postprocessRemove(java.lang.Object removedObject)

postprocessRemove

protected void postprocessRemove(java.util.Collection collection)

clear

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

containsKey

public boolean containsKey(java.lang.Object key)
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

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get 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

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 map)
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

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

putDirectly

public void putDirectly(java.lang.Object key,
                        java.lang.Object value)

removeDirectly

public void removeDirectly(java.lang.Object key)


Copyright © 2001-2012 Apache Cayenne. All Rights Reserved.