Package org.datanucleus.store.types
Interface SCO<T>
- Type Parameters:
T
- The type of the field/property
- All Known Subinterfaces:
SCOCollection<T,
,E> SCOContainer<T>
,SCOList<T,
,E> SCOMap<T,
K, V>
- All Known Implementing Classes:
ArrayList
,ArrayList
,BitSet
,Collection
,Collection
,Date
,GregorianCalendar
,HashMap
,HashMap
,HashSet
,HashSet
,Hashtable
,Hashtable
,LinkedHashMap
,LinkedHashMap
,LinkedHashSet
,LinkedHashSet
,LinkedList
,LinkedList
,List
,List
,Map
,Map
,PriorityQueue
,PriorityQueue
,Properties
,Properties
,Queue
,Queue
,Set
,Set
,SortedMap
,SortedMap
,SortedSet
,SortedSet
,SqlDate
,SqlTime
,SqlTimestamp
,Stack
,Stack
,TreeMap
,TreeMap
,TreeSet
,TreeSet
,Vector
,Vector
public interface SCO<T>
Representation of a wrapper/proxy for a mutable SCO type (e.g Date, Collection, Map).
An implementation of this interface must have a constructor with the arguments
DNStateManager
ownerOP, AbstractMemberMetaData mmd.
The constructor must be capable of taking nulls for these arguments to create a non-managed wrapper
which effectively just acts like an unwrapped object.-
Method Summary
Modifier and TypeMethodDescriptionvoid
attachCopy
(T value) Method to return an attached copy of this object.clone()
Mutable second class objects are required to provide a public clone() method so that copying of persistable objects can take place.detachCopy
(FetchPlanState state) Method to return a detached copy of this object.Accessor for the field name.getOwner()
Accessor for the owner object of the SCO instance.getValue()
Method to return the value of the unwrapped type.void
Method to initialise the SCO for use, and allowing the SCO to be loaded from the datastore (when we have a backing store).void
initialise
(T value) Method to initialise the SCO for use with the provided initial value.void
initialise
(T newValue, Object oldValue) Method to initialise the SCO for use, where replacing an old value with a new value such as when calling a setter field passing in a new value.void
Nullifies references to the owner Object and field.
-
Method Details
-
initialise
Method to initialise the SCO for use with the provided initial value. This is used, for example, when retrieving the field from the datastore and setting it in the persistable object.- Parameters:
value
- the object from which to copy the value.
-
initialise
void initialise()Method to initialise the SCO for use, and allowing the SCO to be loaded from the datastore (when we have a backing store). This can be utilised to perform any eager loading of information from the datastore. -
initialise
Method to initialise the SCO for use, where replacing an old value with a new value such as when calling a setter field passing in a new value. Note that oldValue is marked as Object since for cases where the member type is Collection the newValue could be, for example, ArrayList, and the oldValue of type Collection (representing null).- Parameters:
newValue
- New value (to wrap)oldValue
- Old value (to use in deciding what needs deleting etc)
-
getFieldName
String getFieldName()Accessor for the field name.- Returns:
- field name, or null if no longer associated with an object
-
getOwner
Object getOwner()Accessor for the owner object of the SCO instance. Is typically a persistable object.- Returns:
- owner object, or null if no longer associated with an object
-
unsetOwner
void unsetOwner()Nullifies references to the owner Object and field. Thereafter the SCO is no longer associated with the owner and thus should not issue any request to the datastore. -
getValue
T getValue()Method to return the value of the unwrapped type.- Returns:
- The value that is wrapped by this object.
-
clone
Object clone()Mutable second class objects are required to provide a public clone() method so that copying of persistable objects can take place. This mustn't throw aCloneNotSupportedException
.- Returns:
- A clone of the object
-
detachCopy
Method to return a detached copy of this object. Detaches all components of this object that are also persistable.- Parameters:
state
- State of the detachment process- Returns:
- The detached copy
-
attachCopy
Method to return an attached copy of this object. Attaches all components of this object that are also persistable.- Parameters:
value
- The object value from the detached instance
-