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.
-
attachObjId
- The Id of the object that is being loaded from the data server
-
comCons
-
-
containers
- Vector that contains the object's parent node
-
containersInMem
- Indicates whether the object's containers are in memory
-
contents
- Vector that contains the contents'
-
contentsInMem
- Indicates whether the object's contents are in memory
-
contextVector
- Vector which holds the context information after a getContext
-
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
-
dirty
- Flag which may be used to determine whether the object requires updating
-
isPersistent
- Variable indicating whether the object has been saved before
-
loadVector
-
-
netClient
-
-
netSocket
-
-
numChildren
- The number of children (objects that attaches to it) that the object has
-
numField
-
-
numObjField
- The number of object fields the object has
-
objectClassName
- The class name of the object which inherits the Persistent Object
class.
-
outStreamString
-
-
permission
- Access permission of the object (READ_ONLY, READ_WRITE)
usage to be determined
-
successfulTransmit
-
-
testNoNet
-
-
userId
- User Id of the Persistent Object (for network transactions)
-
version
- String indicating the version of the object (release_name.number)
-
PersistentObject()
- Constructor of PersistentObject
Should never be called explicitly
-
attach(PersistentObject)
- Adds the Persistent Object to the contents Vector,
adds this to the pObj's container Vector
Returns PO.OK
-
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
-
connect(int, int)
-
Connect (Objects)
Sets up the connection at the data back-end
-
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
-
DEBUG(String)
-
Debug
Prints debugging statements if the debug flag is set to true
-
deleteMe()
-
Delete Object
Deletes the object at the data back-end
-
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.
-
detachFrom(PersistentObject)
-
Detach the (DirObject) container's content's instance of this object
-
disconnect(int, int)
-
Disconnect (Objects)
Voids the connections at the data back-end
-
getClassName()
-
Returns the Object Class Name
-
getContext()
- Sets the vector of (className, str, id) information
from the network data server
-
getField(int, boolean)
-
-
getField(int, char)
-
-
getField(int, double)
-
-
getField(int, double[])
-
-
getField(int, float)
-
-
getField(int, int)
-
-
getField(int, Object)
-
-
getField(int, String)
-
get the corresponding contents from an internal vector
that parsed and stored the values of a network Load
-
getField(int, Vector)
-
-
getMemberInfo(int, int)
- Return a MemberInfo object which contains the object class name
and object id pair
-
getObjFields()
-
Determines how the fields of the objects should be filled after
a (network) load
To be declared by object developer
-
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
-
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
-
instancePolicy(PersistentObject)
- Policy that must be followed after instantiating an object
-
load(int)
-
Load (from Persistent Storage over the network).
-
load(String)
- Load by a (database backend location) string has to be overloaded
by the object developer if such a feature is desired
-
loadObject(String, int, String)
- The actual method call thats being made when a load() is called.
-
loadVersion(String, int, String)
-
Load a specific version of the object
Return PO.OK if Load is successful, PO.ERROR otherwise.
-
makeInstance()
- Loads and instantiates a "copy" of the 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
-
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)
-
parseArray(StreamTokenizer)
- Parses an array (arrangement)
-
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
-
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
-
parseNumber(StreamTokenizer, String)
-
Verifies that the token is a number
Prints out the msg if it is not a number, returns false
-
parseQuery(StreamTokenizer)
-
Method that parses the query reult
for QueryObjects
To be overloaded in QueryObject.java
-
postLoadPolicy(Object)
-
Post-object-loading policy, such as handling of dirty bits, etc.,
that the object developer has to overload
-
postSavePolicy(PersistentObject)
-
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, int)
-
Save Object
returns Unique DbId if save is completed
ERROR if not
-
savePolicy(PersistentObject)
-
Object Saving policy, such as handling of dirty bits, etc., that
must/should be done before saving.
-
send(String)
-
Sends the specified string to the remote server
If testNoNet flag is set, then the message will be outputed
to the screen
-
setDebug(boolean)
- Sets the flag for debug statement
-
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)
-
-
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 for network operations
-
setServer(String)
- Sets the server name for network operations
-
setTestNoNet(boolean)
- Sets the flag for network operation
-
setType(int, int)
-
sets the type of each field.
-
versionSave(int)
- Saves the object as a new version of the "basic object"
loadVector
protected Vector loadVector
contextVector
protected Vector contextVector
- Vector which holds the context information after a getContext
comCons
protected static PO_CommandConstructor comCons
netClient
protected static PO_NetClient netClient
netSocket
protected Socket netSocket
testNoNet
public static boolean testNoNet
outStreamString
protected String outStreamString
successfulTransmit
protected boolean successfulTransmit
numField
protected int numField
numObjField
protected int numObjField
- The number of object fields the object has
objectClassName
protected String objectClassName
- The class name of the object which inherits the Persistent Object
class.
userId
protected String userId
- User Id of the Persistent Object (for network transactions)
dbId
protected int dbId
- Unique identifier returned by the data server after a Save()
version
protected String version
- String indicating the version of the object (release_name.number)
permission
protected int permission
- Access permission of the object (READ_ONLY, READ_WRITE)
usage to be determined
contents
public Vector contents
- Vector that contains the contents'
containers
public Vector containers
- Vector that contains the object's parent node
numChildren
protected int numChildren
- The number of children (objects that attaches to it) that the object has
containersInMem
protected boolean containersInMem
- Indicates whether the object's containers are in memory
contentsInMem
protected 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
dirty
public boolean dirty
- Flag which may be used to determine whether the object requires updating
debugFlag
public static boolean debugFlag
- Flag to print out debugging statements
PersistentObject
public PersistentObject()
- Constructor of PersistentObject
Should never be called explicitly
getClassName
public String getClassName()
- Returns the Object Class Name
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.
setServer
protected void setServer(String server)
- Sets the server name for network operations
- Parameters:
- server - Server name
setPort
public static void setPort(int portNum)
- Sets the port for network operations
- Parameters:
- port - Port Number
setDebug
public static void setDebug(boolean flag)
- Sets the flag for debug statement
- Parameters:
- flag - true to turn on debugging
false otherwise
setTestNoNet
public static void setTestNoNet(boolean flag)
- Sets the flag for network operation
- Parameters:
- flag - true if there are no network operations
false otherwise
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
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
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
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)
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
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
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
save
public int save()
- Save (Object)
Encapsulation of the actual call to SaveObject
(returns either OK, ERROR or the Object's UniqueID)
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
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
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
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
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
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
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
makeInstance
protected PersistentObject makeInstance()
- Loads and instantiates a "copy" of the object from
the data back-end.
instancePolicy
public void instancePolicy(PersistentObject pObj)
- Policy that must be followed after instantiating an object
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 double[] getField(int nthField,
double indicator[])
getField
protected Vector getField(int nthField,
Vector indicator)
getField
protected PersistentObject getField(int nthField,
Object indicator)
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)
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
parseArray
protected double[] parseArray(StreamTokenizer strToke)
- Parses an array (arrangement)
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
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
parseQuery
protected Vector parseQuery(StreamTokenizer strToke)
- Method that parses the query reult
for QueryObjects
To be overloaded in QueryObject.java
getContext
public Vector getContext()
- Sets the vector of (className, str, id) information
from the network data server
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
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
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
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
detachFrom
public void detachFrom(PersistentObject cnt)
- Detach the (DirObject) container's content's instance of this object
- Parameters:
- cnt - The container to delete from
deleteMe
protected int deleteMe()
- Delete Object
Deletes the object at the data back-end
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
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
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
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
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
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
DEBUG
protected void DEBUG(String debugStmt)
- Debug
Prints debugging statements if the debug flag is set to true
- Parameters:
- debugStmt - The debugging statement supplied