All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.vt.marian.common.FullID

java.lang.Object
   |
   +----edu.vt.marian.common.FullID

public class FullID
extends Object
The identifier of an object in the MARIAN universe is composed of class id and instance id. Class id can be regarded as database id and instance id can be regarded as a unique id in that database.

NOTE: classID is properly an unsigned 16-bit quantity; instanceID an unsigned 32-bit. Unfortunately there are no unsigneds in Java, so we use an int for classID and test the bounds. Properly, we should use a long for instanceID, but that's a lot of unused bits so we'll use an int and keep our fingers crossed.


Variable Index

 o BAD_PARAMS
 o classID
 o debug
just for debugging
 o instanceID
 o MAX_CLASS_ID
 o MAX_INSTANCE_ID
 o NULL_STREAM
 o OK
return values for methods of this class

Constructor Index

 o FullID(BufferedReader, Debug)
Create a full id object from the specified stream.
 o FullID(Debug)
Create an empty full id object where both classID and instanceID have been set to 0 (ABSURD).
 o FullID(FullID, Debug)
Create a full id object from another one.
 o FullID(int, int, Debug)
Create a full id object with the specified class id and instance id values.

Method Index

 o equals(Object)
Tell whether this object has the same class id and instance id as the parameter object.
 o getClassID()
Return the class id of this object.
 o getInstanceID()
Return the instance id of this object.
 o hashCode()
Generate a hash value suitable for java.util.HashTable.
 o isValid()
Test whether or not the fullID is valid.
 o readPacked(ByteArrayInputStream)
Read this out of compact storage in a byte array.
 o setClassID(int)
Set the class id of this object.
 o setInstanceID(int)
Set the instance id of this object.
 o toStream(PrintWriter)
Print the content of this object to a specified stream.
 o toString()
Convert this to a human-readable string.
 o writePacked(ByteArrayOutputStream)
Pack this into a byte array for compact storage.

Variables

 o debug
 protected Debug debug
just for debugging

 o classID
 protected int classID
 o instanceID
 protected int instanceID
 o MAX_CLASS_ID
 protected static final int MAX_CLASS_ID
 o MAX_INSTANCE_ID
 protected static final int MAX_INSTANCE_ID
 o OK
 public static final int OK
return values for methods of this class

 o BAD_PARAMS
 public static final int BAD_PARAMS
 o NULL_STREAM
 public static final int NULL_STREAM

Constructors

 o FullID
 public FullID(Debug debug)
Create an empty full id object where both classID and instanceID have been set to 0 (ABSURD).

Parameters:
debug - used for debugging
 o FullID
 public FullID(int clID,
               int instID,
               Debug debug)
Create a full id object with the specified class id and instance id values.

Parameters:
clID - class ID value;
instID - instance ID value;
debug - used for debugging
 o FullID
 public FullID(FullID id,
               Debug debug)
Create a full id object from another one. The created object will have the same class id and instance id as the parameter object.

Parameters:
id - the object to be copied
debug - used for debugging
 o FullID
 public FullID(BufferedReader br,
               Debug debug)
Create a full id object from the specified stream.

Parameters:
br - the stream to read out a full id object;
debug - used for debugging

Methods

 o isValid
 public boolean isValid()
Test whether or not the fullID is valid.

Note: The null object of any class (#classID:0#) is always valid. However, objects with a null classID are not. This is because the null class (CLASS_ABSURD) has no members.

Returns:
true / false
 o setClassID
 public int setClassID(int clID)
Set the class id of this object.

uses the services of class(es): none

Parameters:
clID - the class id of this object will be set to this value.
Returns:
OK == the value has been set;
BAD_PARAMS == invalid value for clID.
 o getClassID
 public int getClassID()
Return the class id of this object.

Returns:
the class id of this object as an integer
 o setInstanceID
 public int setInstanceID(int instID)
Set the instance id of this object.

Parameters:
instID - the instance id of this object will be set to this value
Returns:
OK == the value has been set;
BAD_PARAMS == invalid value for instID.
 o getInstanceID
 public int getInstanceID()
Return the instance id of this object.

Returns:
the instance id of this object as an integer
 o equals
 public boolean equals(Object o)
Tell whether this object has the same class id and instance id as the parameter object.

Parameters:
id - the object used to compare with this object
Returns:
true == this object has the same class id and instance id as the parameter object.
false == this object doesn't have the same class id and instance id as the parameter object.
Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Generate a hash value suitable for java.util.HashTable.

Returns:
a positive integer.
Overrides:
hashCode in class Object
 o writePacked
 public int writePacked(ByteArrayOutputStream bos)
Pack this into a byte array for compact storage.

Parameters:
bos - a ByteArrayOutputStream into which to pack this.
Returns:
OK == all jake.
NULL_STREAM == could not write.
 o readPacked
 public int readPacked(ByteArrayInputStream bis)
Read this out of compact storage in a byte array.

Parameters:
bis - a ByteArrayInputStream from which to unpack this.
Returns:
OK == all jake.
NULL_STREAM == could not read.
 o toString
 public String toString()
Convert this to a human-readable string.

Returns:
"@null@" if this is not a valid fullID; "#classID:instanceID#" if it is.
Overrides:
toString in class Object
 o toStream
 public int toStream(PrintWriter pw)
Print the content of this object to a specified stream.

Parameters:
pw - the stream to write this object
Returns:
OK == this object has been write to the stream correctly.
NULL_STREAM == could not read.

All Packages  Class Hierarchy  This Package  Previous  Next  Index