org.apache.openjpa.util
Class ProxyTreeMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.TreeMap
          extended by org.apache.openjpa.util.ProxyTreeMap
All Implemented Interfaces:
Serializable, Cloneable, Map, SortedMap, Proxy, ProxyMap

public class ProxyTreeMap
extends TreeMap
implements ProxyMap

Extension of the TreeMap type that dirties the persistent/transactional field it is assigned to on modification. The need to dirty the field on any modification mandates that this class must override all mutator methods of the base type. This may lead to multiple calls to dirty for one state change if one mutator method of the base type calls another.

Author:
Abe White
See Also:
Serialized Form

Constructor Summary
ProxyTreeMap()
           
ProxyTreeMap(Class keyType, Class valueType, boolean trackChanges, OpenJPAConfiguration conf)
           
ProxyTreeMap(Class keyType, Class valueType, Comparator compare, boolean trackChanges, OpenJPAConfiguration conf)
           
 
Method Summary
 void clear()
           
 Object copy(Object orig)
          Return an unproxied copy of the given instance.
 Set entrySet()
           
 ChangeTracker getChangeTracker()
          Return the change tracker for this proxy, or null if none.
 OpenJPAStateManager getOwner()
          Return the owning object.
 int getOwnerField()
          Return the owning field index.
 Set keySet()
           
 ProxyMap newInstance(Class keyType, Class valueType, Comparator compare, boolean trackChanges, OpenJPAConfiguration conf)
          This method should return a new proxy of the same concrete type as the implementing class.
 Object put(Object key, Object value)
           
 void putAll(Map m)
           
 Object remove(Object key)
           
 void setOwner(OpenJPAStateManager sm, int field)
          Reset the state of the proxy, and set the owning instance of the proxy and the name of the field it is assigned to.
 Collection values()
           
protected  Object writeReplace()
           
 
Methods inherited from class java.util.TreeMap
clone, comparator, containsKey, containsValue, firstKey, get, headMap, lastKey, size, subMap, tailMap
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode, isEmpty
 

Constructor Detail

ProxyTreeMap

public ProxyTreeMap()

ProxyTreeMap

public ProxyTreeMap(Class keyType,
                    Class valueType,
                    boolean trackChanges,
                    OpenJPAConfiguration conf)

ProxyTreeMap

public ProxyTreeMap(Class keyType,
                    Class valueType,
                    Comparator compare,
                    boolean trackChanges,
                    OpenJPAConfiguration conf)
Method Detail

setOwner

public void setOwner(OpenJPAStateManager sm,
                     int field)
Description copied from interface: Proxy
Reset the state of the proxy, and set the owning instance of the proxy and the name of the field it is assigned to. Set to null to indicate that the proxy is no longer managed.

Specified by:
setOwner in interface Proxy

getOwner

public OpenJPAStateManager getOwner()
Description copied from interface: Proxy
Return the owning object.

Specified by:
getOwner in interface Proxy

getOwnerField

public int getOwnerField()
Description copied from interface: Proxy
Return the owning field index.

Specified by:
getOwnerField in interface Proxy

getChangeTracker

public ChangeTracker getChangeTracker()
Description copied from interface: Proxy
Return the change tracker for this proxy, or null if none.

Specified by:
getChangeTracker in interface Proxy

copy

public Object copy(Object orig)
Description copied from interface: Proxy
Return an unproxied copy of the given instance. This method is used by proxy managers to create backup values for use in rollback.

Specified by:
copy in interface Proxy

newInstance

public ProxyMap newInstance(Class keyType,
                            Class valueType,
                            Comparator compare,
                            boolean trackChanges,
                            OpenJPAConfiguration conf)
Description copied from interface: ProxyMap
This method should return a new proxy of the same concrete type as the implementing class. Used by the ProxyManager factories: one template instance of each type is created for the purpose of producing new instances via this method. Overcomes the performance penalties of reflection.

Specified by:
newInstance in interface ProxyMap

clear

public void clear()
Specified by:
clear in interface Map
Overrides:
clear in class TreeMap

keySet

public Set keySet()
Specified by:
keySet in interface Map
Overrides:
keySet in class TreeMap

values

public Collection values()
Specified by:
values in interface Map
Overrides:
values in class TreeMap

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
Overrides:
entrySet in class TreeMap

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map
Overrides:
put in class TreeMap

putAll

public void putAll(Map m)
Specified by:
putAll in interface Map
Overrides:
putAll in class TreeMap

remove

public Object remove(Object key)
Specified by:
remove in interface Map
Overrides:
remove in class TreeMap

writeReplace

protected Object writeReplace()
                       throws ObjectStreamException
Throws:
ObjectStreamException


Copyright © 2006 Apache Software Foundation. All Rights Reserved.