Class PersistentObject
Class PersistentObject
java.lang.Object
|
+----PersistentObject
- public class PersistentObject
- extends Object
Persistent Object Class
(derived from BackendUtil.java)
This is a class which other objects that need network
access extends.
There are several abstract methods that the application developer
must overload in order to use this class.
Static variables
public static final int LOAD = 1;
public static final int SAVE = 2;
public static final int QUERY = 3;
public static final int IF_EXISTS = 4;
// modes for the network operations
// may include more in the future
public static final int PUT = 2;
public static final int GETSTR = 1;
public static final int MODIFY = 0;
public static final int GETID = 3;
public static final int GETATT = 4;
public static final int DELETE = 5;
public static final int CONNECT = 6;
public static final int CONNECTNEW = 7;
public static final int DISCONNECT = 8;
public static final int GETATTINFO = 9;
// types for type-casting
public static final int STRING = 1;
public static final int INT = 2;
public static final int FLOAT = 3;
public static final int DOUBLE = 4;
public static final int BOOLEAN = 5;
public static final int CHAR = 6;
public static final int OBJECT = 7;
public static final int VECTOR = 8;
public static final int PARENTS = 9;
public static final int CHILDREN = 10;
public static final int UNIQUE_ID = 11;
public static final int ARRAY = 12;
public static final int CONTAINERS = 9;
public static final int CONTENTS = 10;
// indicators for the declaration of functions with same name
// by different input type
// initial value does not matter
protected static final String STRING_INDICATOR = "str";
protected static final int INT_INDICATOR = 0;
protected static final float FLOAT_INDICATOR = 1;
protected static final double DOUBLE_INDICATOR = 2;
protected static final boolean BOOLEAN_INDICATOR = true;
protected static final char CHAR_INDICATOR = 'c';
protected static final Object OBJECT_INDICATOR = null;
protected double[] ARRAY_INDICATOR;
// responses from backend DB server
public static final int OK_VAL = 200;
public static final int DUPLICATE_VAL = 300;
public static final int BAD_REQUEST_VAL = 400;
public static final int NOT_FOUND_VAL = 404;
public static final int NOT_FOUND_A_VAL = 405;
public static final int NOT_FOUND_B_VAL = 406;
public static final int EMPTY_REQUEST_VAL = 407;
public static final int NO_ATTACH_VAL = 408;
public static final int SELF_ATTACH_VAL = 409;
public static final int PERM_ERROR_VAL = 410;
public static final int CONT_ERROR_VAL = 411;
public static final int INTERNAL_ERROR_VAL = 500;
public static final int ATTACH_NOT_FOUND_VAL = 501;
// save responses
public static final int OK = 0;
public static final int ERROR = 1;
public static final int DO_NOT_PROCEED = 4; // new
Static variables
-
attachObjId
- The Id of the object that is being loaded from the data server
-
containersInMem
- Indicates whether the object's containers are in memory
-
contentsInMem
- Indicates whether the object's contents are in memory
-
currentRelativeClass
- The name of the current class returned during parsing
-
dbId
- Unique identifier returned by the data server after a Save()
-
debugFlag
- Flag to print out debugging statements
-
fieldTypeArray
- The array whose contents indicate the type of the field in the
corresponding field position of the object
-
isPersistent
- Variable indicating whether the object has been saved before
-
loadVector
-
-
numChildren
- The number of children (objects that attaches to it) that the object has
-
numObjField
- The number of object fields the object has
-
numParents
- The number of parents (objects that it attaches to) that the object has
-
objectClassName
- The class name of the object which inherits the Persistent Object
class.
-
port
- Port number for the data server
-
succeedParse
- Variable indicating whether a parse (network operation)
has been successful
-
succeedTransmit
- Variable indicating whether a network operation has been successful
-
testNoNet
-
-
userId
- User Id of the Persistent Object (for network transactions)
-
PersistentObject()
- Constructor of PersistentObject
Should never be called explicitly
-
DEBUG(String)
-
Debug
Prints debugging statements if the debug flag is set to true
-
DeleteObj()
-
DeleteObj
Deletes the object at the data back-end
-
Disconnect(int, int)
-
Disconnect
Voids the connections at the data back-end
-
GetField(int, boolean)
-
-
GetField(int, char)
-
-
GetField(int, double)
-
-
GetField(int, double[])
-
-
GetField(int, float)
-
-
GetField(int, int)
-
-
GetField(int, Object, int)
-
-
GetField(int, String)
-
Get the corresponding contents from an internal vector
that parsed and stored the values of a network Load
-
GetMemberInfo(int, int)
- Return a MemberInfo object which contains the object class name
and object id pair
-
GetObjFields()
-
-
InstancePolicy(PersistentObject)
-
Policy that must be followed after instantiating an object
-
Load(int)
-
-
Load(String)
-
Load (from Persistent Storage over the network).
-
LoadObject(String, String, int)
- The actual method call thats being made when a Load() is called.
-
MakeInstance()
- Loads and instantiates a "copy" of the (non-OctCell) object from
the data back-end.
-
NetObjSetup(int, int, String)
-
Network Object Setup
method that needs to be run before the object can operate
as a persistent object over the network
-
PostLoadPolicy(Object)
-
Post-object-loading policy, such as handling of dirty bits, etc.,
that the object developer has to overload
-
PostSavePolicy(Object)
-
Post-object-saving policy, such as handling of dirty bits, etc.,
that the object developer has to overload
-
Save()
-
Save (Object)
Encapsulation of the actual call to SaveObject
(returns either OK, ERROR or the Object's UniqueID)
-
SaveObject(String)
-
Save Object
returns OK if save is completed
ERROR if not
-
SavePolicy(Object)
-
Object Saving policy, such as handling of dirty bits, etc., that
must/should be done before saving.
-
SetField(int, boolean, int)
-
-
SetField(int, char, int)
-
-
SetField(int, double, int)
-
-
SetField(int, double[], int)
-
-
SetField(int, float, int)
-
-
SetField(int, int, int)
-
-
SetField(int, Object, int)
-
-
SetField(int, String, int)
-
Sets the fields in the Vector holding the fields of the
object
Non-object types are stored in object that matches mostly closely
its type.
-
SetField(int, Vector, int)
-
-
SetNumField(int)
-
Initializes fieldTypeArray.
-
SetNumObjField(int)
- Sets the number of Object fields in the object
For generation of contents/children purposes
-
SetObjClassName(String)
-
Sets the Object Class Name for network transaction.
-
SetObjFields()
- Sets up the object's fields into internal data structure.
-
SetPersistent(boolean)
-
Sets the isPersistent flag which indicates that this object
has persistence (has a copy at the data backend)
Future operations will then make use of the object's unique id.
-
SetPort(int)
-
Sets the port number for network transaction.
-
SetType(int, int)
-
Sets the type of each field.
loadVector
protected Vector loadVector
numObjField
protected int numObjField
- The number of object fields the object has
fieldTypeArray
protected int fieldTypeArray[]
- The array whose contents indicate the type of the field in the
corresponding field position of the object
port
public int port
- Port number for the data server
objectClassName
public String objectClassName
- The class name of the object which inherits the Persistent Object
class.
dbId
protected int dbId
- Unique identifier returned by the data server after a Save()
numParents
protected int numParents
- The number of parents (objects that it attaches to) that the object has
numChildren
protected int numChildren
- The number of children (objects that attaches to it) that the object has
containersInMem
public boolean containersInMem
- Indicates whether the object's containers are in memory
contentsInMem
public boolean contentsInMem
- Indicates whether the object's contents are in memory
currentRelativeClass
protected String currentRelativeClass
- The name of the current class returned during parsing
attachObjId
protected int attachObjId
- The Id of the object that is being loaded from the data server
isPersistent
public boolean isPersistent
- Variable indicating whether the object has been saved before
userId
protected String userId
- User Id of the Persistent Object (for network transactions)
succeedTransmit
protected boolean succeedTransmit
- Variable indicating whether a network operation has been successful
succeedParse
protected boolean succeedParse
- Variable indicating whether a parse (network operation)
has been successful
debugFlag
public boolean debugFlag
- Flag to print out debugging statements
testNoNet
protected boolean testNoNet
PersistentObject
public PersistentObject()
- Constructor of PersistentObject
Should never be called explicitly
Load
public abstract boolean Load(String strId)
- Load (from Persistent Storage over the network).
Needs to be overloaded by the object developer.
Return OCT.OK if Load is successful, OCT.ERROR otherwise.
- Parameters:
- strId - String type of id
- intId - Integer type of id
Load
public abstract boolean Load(int intId)
SetObjFields
protected abstract void SetObjFields()
- Sets up the object's fields into internal data structure.
Needs to be overloaded by the object developer
NetObjSetup
protected void NetObjSetup(int port,
int numFields,
String objectClassName)
- Network Object Setup
method that needs to be run before the object can operate
as a persistent object over the network
- Parameters:
- port - Port number of the server
- numFields - Number of fields the object has
- objectClassName - Name of the class
SetNumField
protected void SetNumField(int fieldsSize)
- Initializes fieldTypeArray.
Set the number of fields and the size of the
field_type_array and object_field_vector of the object.
Needs to be done by the object developer
- Parameters:
- fieldsSize - Number of fields of the object
SetNumObjField
protected void SetNumObjField(int numObjs)
- Sets the number of Object fields in the object
For generation of contents/children purposes
SetType
protected void SetType(int nthField,
int type)
- Sets the type of each field.
This is a method the Object designer has to overload.
- Parameters:
- nthField - The position of the field
- type - The type of the field
SetPort
protected void SetPort(int port)
- Sets the port number for network transaction.
Needs to be done by the object developer.
- Parameters:
- port - The port number
SetObjClassName
protected void SetObjClassName(String name)
- Sets the Object Class Name for network transaction.
Needs to be done by the object developer.
- Parameters:
- name - Name of the Class
SetField
protected void SetField(int nthField,
String stringField,
int type)
- Sets the fields in the Vector holding the fields of the
object
Non-object types are stored in object that matches mostly closely
its type.
- Parameters:
- nthField - The position of the field
- Second_Argument - Different data types may be used
- type - The type of the field
SetField
protected void SetField(int nthField,
int intField,
int type)
SetField
protected void SetField(int nthField,
double doubleField,
int type)
SetField
protected void SetField(int nthField,
char charField,
int type)
SetField
protected void SetField(int nthField,
boolean boolField,
int type)
SetField
protected void SetField(int nthField,
float floatField,
int type)
SetField
protected void SetField(int nthField,
Vector vectorField,
int type)
SetField
protected void SetField(int nthField,
Object objField,
int type)
SetField
protected void SetField(int nthField,
double arrayField[],
int type)
LoadObject
protected boolean LoadObject(String objectClassName,
String strId,
int intId)
- The actual method call thats being made when a Load() is called.
- Parameters:
- objectClassName - (String) Name of the class
- strId - String type of Id of the object
- intId - Integer type of Id of the object
MakeInstance
protected PersistentObject MakeInstance()
- Loads and instantiates a "copy" of the (non-OctCell) object from
the data back-end.
InstancePolicy
public abstract void InstancePolicy(PersistentObject pObj)
- Policy that must be followed after instantiating an object
Save
public int Save()
- Save (Object)
Encapsulation of the actual call to SaveObject
(returns either OK, ERROR or the Object's UniqueID)
SaveObject
protected int SaveObject(String objectClassName)
- Save Object
returns OK if save is completed
ERROR if not
- Parameters:
- objectClassName - Name of the class
Disconnect
protected int Disconnect(int parentId,
int childId)
- Disconnect
Voids the connections at the data back-end
- Parameters:
- parentId - Id of the parent
- childId - Id of the child
DeleteObj
protected int DeleteObj()
- DeleteObj
Deletes the object at the data back-end
SavePolicy
protected abstract int SavePolicy(Object obj)
- Object Saving policy, such as handling of dirty bits, etc., that
must/should be done before saving.
The object developer has to overload this method.
- Parameters:
- obj - Object to be saved
PostSavePolicy
protected abstract void PostSavePolicy(Object obj)
- Post-object-saving policy, such as handling of dirty bits, etc.,
that the object developer has to overload
- Parameters:
- obj - Object that has been saved
PostLoadPolicy
protected abstract void PostLoadPolicy(Object obj)
- Post-object-loading policy, such as handling of dirty bits, etc.,
that the object developer has to overload
- Parameters:
- Object - that has been loaded
GetMemberInfo
protected MemberInfo GetMemberInfo(int type,
int index)
- Return a MemberInfo object which contains the object class name
and object id pair
- Parameters:
- type - Either PARENTS or CHILDREN
- index - The position of the object field
GetField
protected String GetField(int nthField,
String indicator)
- Get the corresponding contents from an internal vector
that parsed and stored the values of a network Load
- Parameters:
- nthField - Position of the field
- Indictor - Different types according to the type expected
GetField
protected int GetField(int nthField,
int indicator)
GetField
protected double GetField(int nthField,
double indicator)
GetField
protected boolean GetField(int nthField,
boolean indicator)
GetField
protected char GetField(int nthField,
char indicator)
GetField
protected float GetField(int nthField,
float indicator)
GetField
protected abstract Object GetField(int nthField,
Object indicator,
int nthObject)
GetObjFields
protected abstract int GetObjFields()
GetField
protected double[] GetField(int nthField,
double indicator[])
SetPersistent
protected void SetPersistent(boolean flag)
- Sets the isPersistent flag which indicates that this object
has persistence (has a copy at the data backend)
Future operations will then make use of the object's unique id.
DEBUG
protected void DEBUG(String debugStmt)
- Debug
Prints debugging statements if the debug flag is set to true
- Parameters:
- debugStmt - The debugging statement supplied