ostore.util
Class VID

java.lang.Object
  |
  +--ostore.util.VID
All Implemented Interfaces:
Comparable, Digestible, QuickSerializable

public class VID
extends Object
implements Digestible, Comparable

A wrapper class for a DataObject version identifier. A VID contains a single SecureHash, which is either the VHash of a top-block, the VGUID of a top-block, or the GUID of a log object (LGUID).

Version:
$Id: VID.java,v 1.6 2002/04/04 18:48:45 geels Exp $
Author:
Dennis Geels

Field Summary
static byte LGUID
          The type code for a VID that consists of the GUID of the log object for a version.
static byte VGUID
          The type code for a VID that consists of the VGUID of a DataObject's top block (A checkpoint GUID).
static byte VHASH
          The type code for a VID that consists of the VHash of a DataObject's top block.
 
Constructor Summary
VID(byte[] data, int[] offset)
          Constructs a VID from its QuickSerializable form.
VID(byte type, SecureHash id)
          Constructs a new VID.
 
Method Summary
 void add_to_digest(SecureHashBuffer buffer)
          Adds this object's state to the specified SecureHashBuffer using the various add methods.
 int compareTo(Object o)
          Imposes an order on VIDs.
 boolean equals(Object other)
          Tests for equality (type and id).
 SecureHash get_id()
          Returns the VHash, VGUID, or GUID, as appropriate.
 byte get_type()
          Returns the type of identifier for this VID.
 int hashCode()
          Returns the hashcode of the internal identifier.
 void to_bytes(byte[] data, int[] offset)
          Store the object in its "on the wire" form in the byte array data, starting at index offset [0], and increment offset [0] by the number of bytes written; if data == null, increment offset [0] by the number of bytes that would have been written otherwise.
 String toString()
          Returns a human-readable representation of this VID.
 int type_code()
          Returns the unique integer associated with this class in the TypeTable.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VHASH

public static final byte VHASH
The type code for a VID that consists of the VHash of a DataObject's top block.

VGUID

public static final byte VGUID
The type code for a VID that consists of the VGUID of a DataObject's top block (A checkpoint GUID).

LGUID

public static final byte LGUID
The type code for a VID that consists of the GUID of the log object for a version.
Constructor Detail

VID

public VID(byte type,
           SecureHash id)
Constructs a new VID.

VID

public VID(byte[] data,
           int[] offset)
    throws QSException
Constructs a VID from its QuickSerializable form.
Method Detail

get_type

public byte get_type()
Returns the type of identifier for this VID.
Returns:
One of VHASH, VGUID, LGUID

get_id

public SecureHash get_id()
Returns the VHash, VGUID, or GUID, as appropriate.

to_bytes

public void to_bytes(byte[] data,
                     int[] offset)
Description copied from interface: QuickSerializable
Store the object in its "on the wire" form in the byte array data, starting at index offset [0], and increment offset [0] by the number of bytes written; if data == null, increment offset [0] by the number of bytes that would have been written otherwise.
Specified by:
to_bytes in interface QuickSerializable
Following copied from interface: ostore.util.QuickSerializable
Parameters:
data - The byte array to store into, or null.
offset - A single element array whose first element is the index in data to begin writing at on function entry, and which on function exit has been incremented by the number of bytes written.

type_code

public int type_code()
Description copied from interface: QuickSerializable
Returns the unique integer associated with this class in the TypeTable.
Specified by:
type_code in interface QuickSerializable
Following copied from interface: ostore.util.QuickSerializable
Returns:
an integer unique to this class

add_to_digest

public void add_to_digest(SecureHashBuffer buffer)
Description copied from interface: Digestible
Adds this object's state to the specified SecureHashBuffer using the various add methods.
Specified by:
add_to_digest in interface Digestible
Following copied from interface: ostore.util.Digestible
See Also:
SecureHashBuffer.add( byte ), SecureHashBuffer.add( byte[] ), SecureHashBuffer.add( byte[], int, int ), SecureHashBuffer.add( Digestible )

compareTo

public int compareTo(Object o)
Imposes an order on VIDs. The order is equivalent to the lexicographic order on corresponding VID.get_type(),VID.get_id() pairs.
Specified by:
compareTo in interface Comparable

hashCode

public int hashCode()
Returns the hashcode of the internal identifier.
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Tests for equality (type and id).
Overrides:
equals in class Object
Parameters:
other - possibly a VID.
Returns:
true iff other is a VID with the same identifier (including type).

toString

public String toString()
Returns a human-readable representation of this VID.
Overrides:
toString in class Object