org.apache.openjpa.util
Class ProxyTreeSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.TreeSet
              extended by org.apache.openjpa.util.ProxyTreeSet
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.Set, java.util.SortedSet, Proxy, ProxyCollection

public class ProxyTreeSet
extends java.util.TreeSet
implements ProxyCollection

Extension of the TreeSet 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
ProxyTreeSet()
           
ProxyTreeSet(java.lang.Class elementType, boolean trackChanges, OpenJPAConfiguration conf)
           
ProxyTreeSet(java.lang.Class elementType, java.util.Comparator compare, boolean trackChanges, OpenJPAConfiguration conf)
           
 
Method Summary
 boolean add(java.lang.Object value)
           
 boolean addAll(java.util.Collection values)
           
 void clear()
           
 java.lang.Object copy(java.lang.Object orig)
          Return an unproxied copy of the given instance.
 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.
 java.util.Iterator iterator()
           
 ProxyCollection newInstance(java.lang.Class elementType, java.util.Comparator compare, boolean trackChanges, OpenJPAConfiguration conf)
          This method should return a new proxy of the same concrete type as the implementing class.
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 boolean retainAll(java.util.Collection c)
           
 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.
protected  java.lang.Object writeReplace()
           
 
Methods inherited from class java.util.TreeSet
clone, comparator, contains, first, headSet, isEmpty, last, size, subSet, tailSet
 
Methods inherited from class java.util.AbstractSet
equals, hashCode
 
Methods inherited from class java.util.AbstractCollection
containsAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, toArray, toArray
 

Constructor Detail

ProxyTreeSet

public ProxyTreeSet()

ProxyTreeSet

public ProxyTreeSet(java.lang.Class elementType,
                    boolean trackChanges,
                    OpenJPAConfiguration conf)

ProxyTreeSet

public ProxyTreeSet(java.lang.Class elementType,
                    java.util.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 java.lang.Object copy(java.lang.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 ProxyCollection newInstance(java.lang.Class elementType,
                                   java.util.Comparator compare,
                                   boolean trackChanges,
                                   OpenJPAConfiguration conf)
Description copied from interface: ProxyCollection
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 ProxyCollection

add

public boolean add(java.lang.Object value)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set
Overrides:
add in class java.util.TreeSet

addAll

public boolean addAll(java.util.Collection values)
Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.Set
Overrides:
addAll in class java.util.TreeSet

clear

public void clear()
Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.Set
Overrides:
clear in class java.util.TreeSet

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.Set
Overrides:
iterator in class java.util.TreeSet

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.Set
Overrides:
remove in class java.util.TreeSet

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.Set
Overrides:
removeAll in class java.util.AbstractSet

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.Set
Overrides:
retainAll in class java.util.AbstractCollection

writeReplace

protected java.lang.Object writeReplace()
                                 throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException


Copyright © 2006 Apache Software Foundation. All Rights Reserved.