public class GbjGciObject extends GbjGciReport implements Cloneable
Object canonicalization: a weak hash dictionary is used to insure that there is only one copy of a given GS object with a particular oop.
Export set management: using object canonicalization and the java finalize mechanism, we can automatically track GS objects when brought over to java (putting them into the export set), and recognize when java GC's them (removing them from the export set).
Object change synchronization: using the Java Observable/Observer and the GCI dirty object tracking mechanisms, we can now track when a GS object changes and have java update the associated java GS object.
Much of the core functionality of the GBJ class GbjObject has been moved to this class, providing sufficient functionality for a "GBJ lite".
To support object canonicalization, constructors for GbjGciObject are different from the original GbjObject class.
There is some overhead associated with these mechanisms, so by default they are turned off. To activate them for a given session, set the GbjSession field monitorChangedObjects to true.
The first approach uses the method updateClient(). Customer applications should define their own versions of this method in superclasses of GbjGciObject to update local fields. Methods getBytes(), getNamedObjs(), getObjs(), and related methods will be useful here. Remember to also map your superclasses in the session using GbjGciSession.mapGsToJavaClass().
The second approach uses the Java Observable/Observer API to notify customer application when the associated GS server object has changed. Define an application class that implements the java Observer Interface. This class should define the method update(Observable o, Object arg), to handle the changed object (returned as the Observable o) as appropriate for your application. The second argument arg is returned as nil.
Next, for a GbjGciObject that you wish to monitor, call the method addObserver(observer), where observer is an instance of your application Observer class defined above.
When a change to the object occurs, the application Observer method update(GbjObject obj, nil) will be called, indicating that the object has changed.
Note that both updateClient() and Observer objects can be used together.
Constructor and Description |
---|
GbjGciObject(boolean b,
GbjGciSession s)
Construct new GbjGciObject for a session based on a boolean
|
GbjGciObject(byte b,
GbjGciSession s)
Construct new GbjGciObject for a session based on a byte
|
GbjGciObject(Calendar c,
GbjGciSession s)
Construct new GbjGciObject for a session based on a calendar.
|
GbjGciObject(char c,
GbjGciSession s)
Construct new GbjGciObject for a session based on a char
|
GbjGciObject(Date d,
GbjGciSession s)
Construct new GbjGciObject for a session based on a date.
|
GbjGciObject(double d,
GbjGciSession s)
Construct new GbjGciObject for a session based on a double
|
GbjGciObject(float f,
GbjGciSession s)
Construct new GbjGciObject for a session based on a float
|
GbjGciObject(int i,
GbjGciSession s)
Construct new GbjGciObject for a session based on a int
|
GbjGciObject(long i,
GbjGciSession s)
Construct new GbjGciObject for a session based on a long
|
GbjGciObject(Object o,
GbjGciSession s)
Construct new GbjGciObject for a session based on an object.
|
GbjGciObject(short i,
GbjGciSession s)
Construct new GbjGciObject for a session based on a short
|
GbjGciObject(String str,
GbjGciSession s)
Construct new GbjGciObject for a session based on a string
This will generate either a GS String or DoubleByteString
as appropriate.
|
Modifier and Type | Method and Description |
---|---|
BigInteger |
bigIntegerValue()
If this GS object is representable as a BigInteger, return that value.
|
boolean |
booleanValue()
If this GS object is representable as a boolean, return that value.
|
byte[] |
bytesValue()
If this GS object is reprentable in bytes (other than Strings),
return a byte array represention that value.
|
byte |
byteValue()
If this GS object is representable as a byte, return that value.
|
Calendar |
calendarValue()
If this GS object is representable as an calendar, return that value.
|
char |
charValue()
If this GS object is representable as a character, return that value.
|
Date |
dateValue()
If this GS object is representable as an date, return that value.
|
void |
debugPrint(PrintStream out)
Write to printstream a detailed multi-line string describing
internal structure of this GbjGciObject.
|
double |
doubleValue()
If this GS object is representable as a double, return that value.
|
boolean |
equals(Object o)
Equals comparison against another java object
|
float |
floatValue()
If this GS object is representable as a float, return that value.
|
byte |
getByte(int index)
Retrieve the designated byte from this byte-based GS object.
|
byte[] |
getBytes(int startIndex,
int numBytes)
Retrieve the designated bytes from this byte-based GS object.
|
long |
getIndexedSize()
Return the size of the indexed component
of this oop-based GS object
|
GbjGciObject |
getNamedObj(int index)
Retrieve the designated GS object from the named instvar for this GS object.
|
void |
getNamedObjs(int startIndex,
int numObjs,
GbjGciObject[] objs)
Retrieve the designated GS objects from the named instvars for this GS object.
|
int |
getNamedSize()
Return the size of named instance variables
of this oop-based GS object
|
GbjGciObject |
getObj(int index)
Retrieve the designated GS object from this indexable GS object
|
GbjGciObject[] |
getObjs(int startIndex,
int numObjs)
Retrieve the designated GS objects from this indexable GS object.
|
void |
getObjs(int startIndex,
int numObjs,
GbjGciObject[] objs)
Retrieve the designated GS objects from this indexable GS object.
|
int |
getObjType()
Returns an integer value representing the type of GS server
object.
|
GbjGciSession |
getSession()
Return the GbjGciSession object associated with this GS object
|
long |
getTotalSize()
Return the total size (including both instance variables and
indexed components) of this oop-based GS object
|
int |
getValType()
Returns an integer value representing the type of java object
cached on the client.
|
int |
hashCode()
Return a hash code value for this object
|
int |
intValue()
If this GS object is representable as an int, return that value.
|
boolean |
isString()
Return true if this GS object is a "string".
|
long |
longValue()
If this GS object is representable as a long, return that value.
|
static GbjGciObject |
named(String name,
GbjGciSession s)
Return the GS object with this name in the DB.
|
void |
putByte(int index,
byte b)
Write the designated byte to this byte-based GS object.
|
void |
putBytes(int startIndex,
byte[] bytes)
Write the designated bytes to this byte-based GS object.
|
void |
putBytes(int startIndex,
int numBytes,
byte[] bytes)
Write the designated bytes to this byte-based GS object.
|
void |
putNamedObj(int index,
GbjGciObject obj)
Write the designated GS object to the named instvars for this GS object.
|
void |
putNamedObjs(int startIndex,
GbjGciObject[] objs)
Write the designated GS objects to the named instvars for this GS object.
|
void |
putNamedObjs(int startIndex,
int numObjs,
GbjGciObject[] objs)
Write the designated GS objects to the named instvars for this GS object.
|
void |
putObj(int index,
GbjGciObject obj)
Write the designated GS object to this indexable GS object.
|
void |
putObjs(int startIndex,
GbjGciObject[] objs)
Write the designated GS objects to this indexable GS object.
|
void |
putObjs(int startIndex,
int numObjs,
GbjGciObject[] objs)
Write the designated GS objects to this indexable GS object.
|
short |
shortValue()
If this GS object is representable as a short, return that value.
|
String |
stringValue()
If this GS object is representable as a string, return that value.
|
String |
toString()
Return a short string representation of this GbjGciReport
|
static GbjGciObject |
withOop(long oopValue,
GbjGciSession s)
Return the GS object represented by this oop
|
clone, getOop, isNil, isSpecial
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
public GbjGciObject(boolean b, GbjGciSession s)
b
- booleans
- GbjGciSessionpublic GbjGciObject(byte b, GbjGciSession s)
b
- bytes
- GbjGciSessionpublic GbjGciObject(char c, GbjGciSession s)
c
- chars
- GbjGciSessionpublic GbjGciObject(short i, GbjGciSession s)
i
- shorts
- GbjGciSessionpublic GbjGciObject(int i, GbjGciSession s)
i
- ints
- GbjGciSessionpublic GbjGciObject(long i, GbjGciSession s)
i
- longs
- GbjGciSessionpublic GbjGciObject(float f, GbjGciSession s)
f
- flaots
- GbjGciSessionpublic GbjGciObject(double d, GbjGciSession s)
d
- doubles
- GbjGciSessionpublic GbjGciObject(String str, GbjGciSession s)
str
- Strings
- GbjGciSessionpublic GbjGciObject(Date d, GbjGciSession s)
d
- Dates
- GbjGciSessionpublic GbjGciObject(Calendar c, GbjGciSession s)
c
- Calendars
- GbjGciSessionpublic GbjGciObject(Object o, GbjGciSession s)
o
- Objects
- GbjGciSessionpublic int getValType()
getValType
in class GbjGciReport
public int getObjType()
getObjType
in class GbjGciReport
public GbjGciSession getSession()
public int getNamedSize()
public long getIndexedSize()
public long getTotalSize()
public static GbjGciObject withOop(long oopValue, GbjGciSession s)
oopValue
- oops
- GbjGciSessionpublic int hashCode()
hashCode
in class GbjGciReport
public boolean equals(Object o)
equals
in class GbjGciReport
public static GbjGciObject named(String name, GbjGciSession s)
name
- Name to uses
- GbjGciSessionpublic String toString()
toString
in class GbjGciReport
public void debugPrint(PrintStream out)
debugPrint
in class GbjGciReport
out
- PrintStream to write topublic boolean isString()
public boolean booleanValue()
ClassCastException
- thrown if GS object not a booleanpublic char charValue()
ClassCastException
- thrown if GS object not a characterpublic byte byteValue()
ClassCastException
- thrown if GS object not a bytepublic short shortValue()
ClassCastException
- thrown if GS object not a shortpublic int intValue()
ClassCastException
- thrown if GS object not a intpublic long longValue()
ClassCastException
- thrown if GS object not a longpublic BigInteger bigIntegerValue()
ClassCastException
- thrown if GS object not a BigIntegerpublic float floatValue()
ClassCastException
- thrown if GS object not a floatpublic double doubleValue()
ClassCastException
- thrown if GS object not a doublepublic byte[] bytesValue()
WARNING: only the cached portion of this value is returned, limited by the GbjGciInterface.initialize preloadSize. To insure getting the complete object, use the method getBytes().
ClassCastException
- thrown if GS object not bytespublic String stringValue()
WARNING: only the cached portion of this value is returned, limited by the GbjGciInterface.initialize preloadSize. To insure getting the complete object, use the method getValueString().
ClassCastException
- thrown if GS object not a stringpublic Date dateValue()
ClassCastException
- thrown if GS object not a datepublic Calendar calendarValue()
ClassCastException
- thrown if GS object not a calendarpublic byte[] getBytes(int startIndex, int numBytes)
startIndex
- The starting index (1-based)numBytes
- The number of bytes to retrieveGbjGciException
- thrown on any errorspublic byte getByte(int index)
index
- The index of the byte to retrieve (1-based)GbjGciException
- thrown on any errorspublic void getObjs(int startIndex, int numObjs, GbjGciObject[] objs)
startIndex
- The starting index (1-based)numObjs
- The number of objects to retrieveobjs
- An array of GS objects to hold the resultsGbjGciException
- thrown on any errorspublic GbjGciObject[] getObjs(int startIndex, int numObjs)
startIndex
- The starting index (1-based)numObjs
- The number of objects to retrieveGbjGciException
- thrown on any errorspublic GbjGciObject getObj(int index)
index
- The starting index (1-based)GbjGciException
- thrown on any errorspublic void getNamedObjs(int startIndex, int numObjs, GbjGciObject[] objs)
startIndex
- The starting index (1-based)numObjs
- The number of objects to retrieveobjs
- An array of GS objects to hold the resultsGbjGciException
- thrown on any errorspublic GbjGciObject getNamedObj(int index)
index
- The index of the desired instvar (1-based)GbjGciException
- thrown on any errorspublic void putBytes(int startIndex, int numBytes, byte[] bytes)
startIndex
- The starting index (1-based)numBytes
- The number of bytes to writebytes
- The bytes to write outGbjGciException
- thrown on any errorspublic void putBytes(int startIndex, byte[] bytes)
startIndex
- The starting index (1-based)bytes
- The bytes to write outGbjGciException
- thrown on any errorspublic void putByte(int index, byte b)
index
- The index (1-based)b
- The byte to write outGbjGciException
- thrown on any errorspublic void putObjs(int startIndex, int numObjs, GbjGciObject[] objs)
startIndex
- The starting index (1-based)numObjs
- The number of objects to writeobjs
- An array of GS objects to write outGbjGciException
- thrown on any errorspublic void putObjs(int startIndex, GbjGciObject[] objs)
startIndex
- The starting index (1-based)objs
- An array of GS objects to write outGbjGciException
- thrown on any errorspublic void putObj(int index, GbjGciObject obj)
index
- The index of the instvar to write out (1-based)obj
- The GS object to write outGbjGciException
- thrown on any errorspublic void putNamedObjs(int startIndex, int numObjs, GbjGciObject[] objs)
startIndex
- The starting index (1-based)numObjs
- The number of objects to writeobjs
- An array of GS objects to write outGbjGciException
- thrown on any errorspublic void putNamedObjs(int startIndex, GbjGciObject[] objs)
startIndex
- The starting index (1-based)objs
- An array of GS objects to write outGbjGciException
- thrown on any errorspublic void putNamedObj(int index, GbjGciObject obj)
index
- The index of the instvar to write out (1-based)obj
- The GS object to write outGbjGciException
- thrown on any errors