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

 o attachObjId
The Id of the object that is being loaded from the data server
 o comCons
 o containers
Vector that contains the object's parent node
 o containersInMem
Indicates whether the object's containers are in memory
 o contents
Vector that contains the contents'
 o contentsInMem
Indicates whether the object's contents are in memory
 o contextVector
Vector which holds the context information after a getContext
 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 dirty
Flag which may be used to determine whether the object requires updating
 o isPersistent
Variable indicating whether the object has been saved before
 o loadVector
 o netClient
 o netSocket
 o numChildren
The number of children (objects that attaches to it) that the object has
 o numField
 o numObjField
The number of object fields the object has
 o objectClassName
The class name of the object which inherits the Persistent Object class.
 o outStreamString
 o permission
Access permission of the object (READ_ONLY, READ_WRITE) usage to be determined
 o successfulTransmit
 o testNoNet
 o userId
User Id of the Persistent Object (for network transactions)
 o version
String indicating the version of the object (release_name.number)

Constructor Index

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

Method Index

 o attach(PersistentObject)
Adds the Persistent Object to the contents Vector, adds this to the pObj's container Vector Returns PO.OK
 o closeServer(Socket)
Calls closeConnection to close a remote server connection If testNoNet flag is set, then the close is ignored and operations (load, save, etc.) will be done locally
 o connect(int, int)
Connect (Objects) Sets up the connection at the data back-end
 o connectServer()
Calls openConnection to connect to remote server If testNoNet flag is set, then the connection is ignored and operations (load, save, etc.) will be done locally
 o DEBUG(String)
Debug Prints debugging statements if the debug flag is set to true
 o deleteMe()
Delete Object Deletes the object at the data back-end
 o detach(PersistentObject)
Detach User can/should only Detach OctObjects that are not Persistent For detaching already Persistent OctObjects, disconnect should be called so that the information gets transferred back to the data server.
 o detachFrom(PersistentObject)
Detach the (DirObject) container's content's instance of this object
 o disconnect(int, int)
Disconnect (Objects) Voids the connections at the data back-end
 o getClassName()
Returns the Object Class Name
 o getContext()
Sets the vector of (className, str, id) information from the network data server
 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)
 o getField(int, String)
get the corresponding contents from an internal vector that parsed and stored the values of a network Load
 o getField(int, Vector)
 o getMemberInfo(int, int)
Return a MemberInfo object which contains the object class name and object id pair
 o getObjFields()
Determines how the fields of the objects should be filled after a (network) load To be declared by object developer
 o initGenContainers()
Load objects that are attached at the next upper level of the current object to the Vector contents Return PO.OK if operation is successful PO.ERROR if not
 o initGenContents()
Load objects that are attached at the next direct level of the current object to the Vector contents Return PO.OK if operation is successful PO.ERROR if not
 o instancePolicy(PersistentObject)
Policy that must be followed after instantiating an object
 o load(int)
Load (from Persistent Storage over the network).
 o load(String)
Load by a (database backend location) string has to be overloaded by the object developer if such a feature is desired
 o loadObject(String, int, String)
The actual method call thats being made when a load() is called.
 o loadVersion(String, int, String)
Load a specific version of the object Return PO.OK if Load is successful, PO.ERROR otherwise.
 o makeInstance()
Loads and instantiates a "copy" of the 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 parse(int)
parse This method is responsible for parsing responses from remote network server(s) (see http://www-cad.eecs.berkeley.edu/~mds/oct/protocol.html for details) (called after PO_NetClient.openConnection)
 o parseArray(StreamTokenizer)
Parses an array (arrangement)
 o parseContext(StreamTokenizer)
Method that parses stream into (className, str, id) information for DirObjects, stringID = content's 1st identifier for Version Object, stringId = content's version string
 o parseForWord(StreamTokenizer, String)
Verifies that the token is a word/String Prints out the msg if it is not a string, return null returns the String parsed otherwise
 o parseNumber(StreamTokenizer, String)
Verifies that the token is a number Prints out the msg if it is not a number, returns false
 o parseQuery(StreamTokenizer)
Method that parses the query reult for QueryObjects To be overloaded in QueryObject.java
 o postLoadPolicy(Object)
Post-object-loading policy, such as handling of dirty bits, etc., that the object developer has to overload
 o postSavePolicy(PersistentObject)
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, int)
Save Object returns Unique DbId if save is completed ERROR if not
 o savePolicy(PersistentObject)
Object Saving policy, such as handling of dirty bits, etc., that must/should be done before saving.
 o send(String)
Sends the specified string to the remote server If testNoNet flag is set, then the message will be outputed to the screen
 o setDebug(boolean)
Sets the flag for debug statement
 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 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 for network operations
 o setServer(String)
Sets the server name for network operations
 o setTestNoNet(boolean)
Sets the flag for network operation
 o setType(int, int)
sets the type of each field.
 o versionSave(int)
Saves the object as a new version of the "basic object"

Variables

 o loadVector
  protected Vector loadVector
 o contextVector
  protected Vector contextVector
Vector which holds the context information after a getContext
 o comCons
  protected static PO_CommandConstructor comCons
 o netClient
  protected static PO_NetClient netClient
 o netSocket
  protected Socket netSocket
 o testNoNet
  public static boolean testNoNet
 o outStreamString
  protected String outStreamString
 o successfulTransmit
  protected boolean successfulTransmit
 o numField
  protected int numField
 o numObjField
  protected int numObjField
The number of object fields the object has
 o objectClassName
  protected String objectClassName
The class name of the object which inherits the Persistent Object class.
 o userId
  protected String userId
User Id of the Persistent Object (for network transactions)
 o dbId
  protected int dbId
Unique identifier returned by the data server after a Save()
 o version
  protected String version
String indicating the version of the object (release_name.number)
 o permission
  protected int permission
Access permission of the object (READ_ONLY, READ_WRITE) usage to be determined
 o contents
  public Vector contents
Vector that contains the contents'
 o containers
  public Vector containers
Vector that contains the object's parent node
 o numChildren
  protected int numChildren
The number of children (objects that attaches to it) that the object has
 o containersInMem
  protected boolean containersInMem
Indicates whether the object's containers are in memory
 o contentsInMem
  protected 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 dirty
  public boolean dirty
Flag which may be used to determine whether the object requires updating
 o debugFlag
  public static boolean debugFlag
Flag to print out debugging statements

Constructors

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

Methods

 o getClassName
  public String getClassName()
Returns the Object Class Name
 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 setServer
  protected void setServer(String server)
Sets the server name for network operations
Parameters:
server - Server name
 o setPort
  public static void setPort(int portNum)
Sets the port for network operations
Parameters:
port - Port Number
 o setDebug
  public static void setDebug(boolean flag)
Sets the flag for debug statement
Parameters:
flag - true to turn on debugging false otherwise
 o setTestNoNet
  public static void setTestNoNet(boolean flag)
Sets the flag for network operation
Parameters:
flag - true if there are no network operations false otherwise
 o netObjSetup
  protected void netObjSetup(int numFields,
                             int numObjs,
                             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 setObjFields
  protected abstract void setObjFields()
Sets up the object's fields into internal data structure. Calls setField with the respective parameters for different types Needs to be overloaded by the object developer
 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 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 connectServer
  protected boolean connectServer()
Calls openConnection to connect to remote server If testNoNet flag is set, then the connection is ignored and operations (load, save, etc.) will be done locally
 o closeServer
  protected boolean closeServer(Socket socket)
Calls closeConnection to close a remote server connection If testNoNet flag is set, then the close is ignored and operations (load, save, etc.) will be done locally
 o send
  protected void send(String msg)
Sends the specified string to the remote server If testNoNet flag is set, then the message will be outputed to the screen
Parameters:
msg - The message/string to be sent
 o save
  public int save()
Save (Object) Encapsulation of the actual call to SaveObject (returns either OK, ERROR or the Object's UniqueID)
 o versionSave
  public int versionSave(int versionFlag)
Saves the object as a new version of the "basic object"
Parameters:
versionFlag - Indicator of whether a "point" (single object) is to be saved or the whole "tree", rooted at this point
 o saveObject
  protected int saveObject(String objectClassName,
                           int versionFlag)
Save Object returns Unique DbId if save is completed ERROR if not
Parameters:
objectClassName - Name of the class
 o load
  public boolean load(int intId)
Load (from Persistent Storage over the network). Return PO.OK if Load is successful, PO.ERROR otherwise.
Parameters:
strId - String type of id
intId - Integer type of id
 o load
  public boolean load(String strId)
Load by a (database backend location) string has to be overloaded by the object developer if such a feature is desired
 o loadVersion
  public boolean loadVersion(String strId,
                             int intId,
                             String version)
Load a specific version of the object Return PO.OK if Load is successful, PO.ERROR otherwise.
Parameters:
strId - String type of id
intId - Integer type of id
version - Version of the object
 o getObjFields
  protected abstract void getObjFields()
Determines how the fields of the objects should be filled after a (network) load To be declared by object developer
 o loadObject
  protected boolean loadObject(String strId,
                               int intId,
                               String version)
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
version - Version of the object
 o makeInstance
  protected PersistentObject makeInstance()
Loads and instantiates a "copy" of the object from the data back-end.
 o instancePolicy
  public void instancePolicy(PersistentObject pObj)
Policy that must be followed after instantiating an object
 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 double[] getField(int nthField,
                              double indicator[])
 o getField
  protected Vector getField(int nthField,
                            Vector indicator)
 o getField
  protected PersistentObject getField(int nthField,
                                      Object indicator)
 o parse
  protected Vector parse(int preceedingOp)
parse This method is responsible for parsing responses from remote network server(s) (see http://www-cad.eecs.berkeley.edu/~mds/oct/protocol.html for details) (called after PO_NetClient.openConnection)
 o parseNumber
  protected boolean parseNumber(StreamTokenizer strToke,
                                String msg)
Verifies that the token is a number Prints out the msg if it is not a number, returns false
Parameters:
strToke - StreamTokenizer to be verified
msg - Error message to be outputed
 o parseArray
  protected double[] parseArray(StreamTokenizer strToke)
Parses an array (arrangement)
 o parseForWord
  protected String parseForWord(StreamTokenizer strToke,
                                String msg)
Verifies that the token is a word/String Prints out the msg if it is not a string, return null returns the String parsed otherwise
Parameters:
strToke - StreamTokenizer to be verified
msg - Error message to be outputed
 o parseContext
  protected Vector parseContext(StreamTokenizer strToke)
Method that parses stream into (className, str, id) information for DirObjects, stringID = content's 1st identifier for Version Object, stringId = content's version string
 o parseQuery
  protected Vector parseQuery(StreamTokenizer strToke)
Method that parses the query reult for QueryObjects To be overloaded in QueryObject.java
 o getContext
  public Vector getContext()
Sets the vector of (className, str, id) information from the network data server
 o connect
  protected int connect(int parentId,
                        int childId)
Connect (Objects) Sets up the connection at the data back-end
Parameters:
parentId - Id of the parent
childId - Id of the child
 o disconnect
  protected int disconnect(int parentId,
                           int childId)
Disconnect (Objects) Voids the connections at the data back-end
Parameters:
parentId - Id of the parent
childId - Id of the child
 o attach
  public int attach(PersistentObject pObj)
Adds the Persistent Object to the contents Vector, adds this to the pObj's container Vector Returns PO.OK
Parameters:
pObj - PersistentObject to be added
 o detach
  public int detach(PersistentObject pObj)
Detach User can/should only Detach OctObjects that are not Persistent For detaching already Persistent OctObjects, disconnect should be called so that the information gets transferred back to the data server.
Parameters:
obj - object to Detach
 o detachFrom
  public void detachFrom(PersistentObject cnt)
Detach the (DirObject) container's content's instance of this object
Parameters:
cnt - The container to delete from
 o deleteMe
  protected int deleteMe()
Delete Object Deletes the object at the data back-end
 o savePolicy
  protected int savePolicy(PersistentObject pObj)
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 void postSavePolicy(PersistentObject pObj)
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 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 initGenContents
  public int initGenContents()
Load objects that are attached at the next direct level of the current object to the Vector contents Return PO.OK if operation is successful PO.ERROR if not
 o initGenContainers
  public int initGenContainers()
Load objects that are attached at the next upper level of the current object to the Vector contents Return PO.OK if operation is successful PO.ERROR if not
 o getMemberInfo
  protected PersistentObject 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 DEBUG
  protected void DEBUG(String debugStmt)
Debug Prints debugging statements if the debug flag is set to true
Parameters:
debugStmt - The debugging statement supplied