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.

Variable Index

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

 o attachObjId
The Id of the object that is being loaded from the data server
 o containersInMem
Indicates whether the object's containers are in memory
 o contentsInMem
Indicates whether the object's contents are in memory
 o currentRelativeClass
The name of the current class returned during parsing
 o dbId
Unique identifier returned by the data server after a Save()
 o debugFlag
Flag to print out debugging statements
 o fieldTypeArray
The array whose contents indicate the type of the field in the corresponding field position of the object
 o isPersistent
Variable indicating whether the object has been saved before
 o loadVector
 o numChildren
The number of children (objects that attaches to it) that the object has
 o numObjField
The number of object fields the object has
 o numParents
The number of parents (objects that it attaches to) that the object has
 o objectClassName
The class name of the object which inherits the Persistent Object class.
 o port
Port number for the data server
 o succeedParse
Variable indicating whether a parse (network operation) has been successful
 o succeedTransmit
Variable indicating whether a network operation has been successful
 o testNoNet
 o userId
User Id of the Persistent Object (for network transactions)

Constructor Index

 o PersistentObject()
Constructor of PersistentObject Should never be called explicitly

Method Index

 o DEBUG(String)
Debug Prints debugging statements if the debug flag is set to true
 o DeleteObj()
DeleteObj Deletes the object at the data back-end
 o Disconnect(int, int)
Disconnect Voids the connections at the data back-end
 o GetField(int, boolean)
 o GetField(int, char)
 o GetField(int, double)
 o GetField(int, double[])
 o GetField(int, float)
 o GetField(int, int)
 o GetField(int, Object, int)
 o GetField(int, String)
Get the corresponding contents from an internal vector that parsed and stored the values of a network Load
 o GetMemberInfo(int, int)
Return a MemberInfo object which contains the object class name and object id pair
 o GetObjFields()
 o InstancePolicy(PersistentObject)
Policy that must be followed after instantiating an object
 o Load(int)
 o Load(String)
Load (from Persistent Storage over the network).
 o LoadObject(String, String, int)
The actual method call thats being made when a Load() is called.
 o MakeInstance()
Loads and instantiates a "copy" of the (non-OctCell) object from the data back-end.
 o 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
 o PostLoadPolicy(Object)
Post-object-loading policy, such as handling of dirty bits, etc., that the object developer has to overload
 o PostSavePolicy(Object)
Post-object-saving policy, such as handling of dirty bits, etc., that the object developer has to overload
 o Save()
Save (Object) Encapsulation of the actual call to SaveObject (returns either OK, ERROR or the Object's UniqueID)
 o SaveObject(String)
Save Object returns OK if save is completed ERROR if not
 o SavePolicy(Object)
Object Saving policy, such as handling of dirty bits, etc., that must/should be done before saving.
 o SetField(int, boolean, int)
 o SetField(int, char, int)
 o SetField(int, double, int)
 o SetField(int, double[], int)
 o SetField(int, float, int)
 o SetField(int, int, int)
 o SetField(int, Object, int)
 o 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.
 o SetField(int, Vector, int)
 o SetNumField(int)
Initializes fieldTypeArray.
 o SetNumObjField(int)
Sets the number of Object fields in the object For generation of contents/children purposes
 o SetObjClassName(String)
Sets the Object Class Name for network transaction.
 o SetObjFields()
Sets up the object's fields into internal data structure.
 o 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.
 o SetPort(int)
Sets the port number for network transaction.
 o SetType(int, int)
Sets the type of each field.

Variables

 o loadVector
  protected Vector loadVector
 o numObjField
  protected int numObjField
The number of object fields the object has
 o fieldTypeArray
  protected int fieldTypeArray[]
The array whose contents indicate the type of the field in the corresponding field position of the object
 o port
  public int port
Port number for the data server
 o objectClassName
  public String objectClassName
The class name of the object which inherits the Persistent Object class.
 o dbId
  protected int dbId
Unique identifier returned by the data server after a Save()
 o numParents
  protected int numParents
The number of parents (objects that it attaches to) that the object has
 o numChildren
  protected int numChildren
The number of children (objects that attaches to it) that the object has
 o containersInMem
  public boolean containersInMem
Indicates whether the object's containers are in memory
 o contentsInMem
  public boolean contentsInMem
Indicates whether the object's contents are in memory
 o currentRelativeClass
  protected String currentRelativeClass
The name of the current class returned during parsing
 o attachObjId
  protected int attachObjId
The Id of the object that is being loaded from the data server
 o isPersistent
  public boolean isPersistent
Variable indicating whether the object has been saved before
 o userId
  protected String userId
User Id of the Persistent Object (for network transactions)
 o succeedTransmit
  protected boolean succeedTransmit
Variable indicating whether a network operation has been successful
 o succeedParse
  protected boolean succeedParse
Variable indicating whether a parse (network operation) has been successful
 o debugFlag
  public boolean debugFlag
Flag to print out debugging statements
 o testNoNet
  protected boolean testNoNet

Constructors

 o PersistentObject
  public PersistentObject()
Constructor of PersistentObject Should never be called explicitly

Methods

 o 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
 o Load
  public abstract boolean Load(int intId)
 o SetObjFields
  protected abstract void SetObjFields()
Sets up the object's fields into internal data structure. Needs to be overloaded by the object developer
 o 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
 o 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
 o SetNumObjField
  protected void SetNumObjField(int numObjs)
Sets the number of Object fields in the object For generation of contents/children purposes
 o 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
 o 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
 o 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
 o 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
 o SetField
  protected void SetField(int nthField,
                          int intField,
                          int type)
 o SetField
  protected void SetField(int nthField,
                          double doubleField,
                          int type)
 o SetField
  protected void SetField(int nthField,
                          char charField,
                          int type)
 o SetField
  protected void SetField(int nthField,
                          boolean boolField,
                          int type)
 o SetField
  protected void SetField(int nthField,
                          float floatField,
                          int type)
 o SetField
  protected void SetField(int nthField,
                          Vector vectorField,
                          int type)
 o SetField
  protected void SetField(int nthField,
                          Object objField,
                          int type)
 o SetField
  protected void SetField(int nthField,
                          double arrayField[],
                          int type)
 o 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
 o MakeInstance
  protected PersistentObject MakeInstance()
Loads and instantiates a "copy" of the (non-OctCell) object from the data back-end.
 o InstancePolicy
  public abstract void InstancePolicy(PersistentObject pObj)
Policy that must be followed after instantiating an object
 o Save
  public int Save()
Save (Object) Encapsulation of the actual call to SaveObject (returns either OK, ERROR or the Object's UniqueID)
 o SaveObject
  protected int SaveObject(String objectClassName)
Save Object returns OK if save is completed ERROR if not
Parameters:
objectClassName - Name of the class
 o 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
 o DeleteObj
  protected int DeleteObj()
DeleteObj Deletes the object at the data back-end
 o 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
 o 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
 o 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
 o 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
 o 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
 o GetField
  protected int GetField(int nthField,
                         int indicator)
 o GetField
  protected double GetField(int nthField,
                            double indicator)
 o GetField
  protected boolean GetField(int nthField,
                             boolean indicator)
 o GetField
  protected char GetField(int nthField,
                          char indicator)
 o GetField
  protected float GetField(int nthField,
                           float indicator)
 o GetField
  protected abstract Object GetField(int nthField,
                                     Object indicator,
                                     int nthObject)
 o GetObjFields
  protected abstract int GetObjFields()
 o GetField
  protected double[] GetField(int nthField,
                              double indicator[])
 o 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.
 o DEBUG
  protected void DEBUG(String debugStmt)
Debug Prints debugging statements if the debug flag is set to true
Parameters:
debugStmt - The debugging statement supplied