org.sourceforge.jemm.client
Class ObjectAccessor

java.lang.Object
  extended by org.sourceforge.jemm.client.ObjectAccessor

public class ObjectAccessor
extends java.lang.Object

Accesses a JEMMObject enhanced class and provides access to the special fields for common client functionality.

Author:
Paul Keeble

Field Summary
static int DEFAULT_VERSION
           
 
Constructor Summary
ObjectAccessor(JEMMObject obj, ObjectSource database)
          Creates an Accessor to an enhanced object
 
Method Summary
 void create(ID id, MethodListener ml)
          When an object is first created an ID and ShadowUserObject need to be assigned.
 void finaliseAllFields()
           
 void finaliseField(java.lang.Class<?> declaringClass, java.lang.String fieldName)
          Clears an Objects field by setting it to null.
 void finaliseField(java.lang.reflect.Field f)
           
 java.util.Map<FieldInfo,java.lang.Object> getAllFieldsMap()
          Generates a Map of all the keys and values for all fields associated with this object.
 java.lang.Object getField(java.lang.Class<?> declaringClass, java.lang.String name)
          Gets the field value for the object.
 java.util.Map<FieldKey,JEMMObject> getInitialisedObjectFields()
          Returns the objects referred to by JEMMObject fields that are currently initialised.
 java.util.Map<FieldKey,ID> getUninitialisedObjectFields()
          Returns all JEMMObject fields that are uninitialised and their current value.
 void initialiseAllFields(Descriptor methodDescriptor)
           
 void initialiseField(java.lang.Class<?> declaringClass, java.lang.String fieldName)
           
 void initialiseField(java.lang.String declaringClass, java.lang.String fieldName)
          Initialises a JEMMObjects field to a real value.
 boolean isCreated()
           
 boolean isInitialised(java.lang.Class<?> declaringClass, java.lang.String fieldName)
           
 void setField(java.lang.Class<?> declaringClass, java.lang.String name, java.lang.Object value)
          Sets the field to a value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_VERSION

public static final int DEFAULT_VERSION
See Also:
Constant Field Values
Constructor Detail

ObjectAccessor

public ObjectAccessor(JEMMObject obj,
                      ObjectSource database)
Creates an Accessor to an enhanced object

Parameters:
obj - The enhanced Object
Method Detail

create

public void create(ID id,
                   MethodListener ml)
When an object is first created an ID and ShadowUserObject need to be assigned. This method does the creation steps to get the obejct ready for JEMM tracking.


isCreated

public boolean isCreated()

setField

public void setField(java.lang.Class<?> declaringClass,
                     java.lang.String name,
                     java.lang.Object value)
Sets the field to a value. If the field is a primitive then the value is set on the object, otherwise if its an JEMMObject then it is mapped in the ShadowData as the ID of the object.

Parameters:
name - The fields name
value - The value to set the field to.

getField

public java.lang.Object getField(java.lang.Class<?> declaringClass,
                                 java.lang.String name)
Gets the field value for the object. If the field is a primitive then the value is retrieved from the JEMMObject. Otherwise if it is a JEMMObject then the ID is returned.

Parameters:
declaringClass - The class on which the field is found
name - The field name
database - The ObjectDatabase to retrieve the field from
Returns:
A primitive object wrapper or ID

initialiseField

public void initialiseField(java.lang.String declaringClass,
                            java.lang.String fieldName)
Initialises a JEMMObjects field to a real value. If the field is an object then the ID is collected from the ShadowData, the object is retrieved from the Object database and then set onto the object. If the field is an array or primitive the field will be untouched.

Parameters:
declaringClass - The class which delcared the field
fieldName - The name of the field to set
database - The place to retrieve the Object from

initialiseField

public void initialiseField(java.lang.Class<?> declaringClass,
                            java.lang.String fieldName)

isInitialised

public boolean isInitialised(java.lang.Class<?> declaringClass,
                             java.lang.String fieldName)

initialiseAllFields

public void initialiseAllFields(Descriptor methodDescriptor)

finaliseField

public void finaliseField(java.lang.Class<?> declaringClass,
                          java.lang.String fieldName)
Clears an Objects field by setting it to null. Only works on fields which are Objects, any primtives/array will simply be left alone.

Parameters:
name - The field name

finaliseField

public void finaliseField(java.lang.reflect.Field f)

finaliseAllFields

public void finaliseAllFields()

getAllFieldsMap

public java.util.Map<FieldInfo,java.lang.Object> getAllFieldsMap()
Generates a Map of all the keys and values for all fields associated with this object. The values are either the actual primitive values or the ID of the object referenced, the Object is never retrieved.

Returns:

getUninitialisedObjectFields

public java.util.Map<FieldKey,ID> getUninitialisedObjectFields()
Returns all JEMMObject fields that are uninitialised and their current value. The value is either a valid ID or null if the field contains no mapping.

Returns:
Mapping of Field information to ID or null if no mapping exists

getInitialisedObjectFields

public java.util.Map<FieldKey,JEMMObject> getInitialisedObjectFields()
Returns the objects referred to by JEMMObject fields that are currently initialised.

Returns:
Mapping of Field to JEMMObject or null if no mapping exists


Copyright © 2009. All Rights Reserved.