com.triactive.jdo.store
Class OID

java.lang.Object
  extended bycom.triactive.jdo.store.OID
All Implemented Interfaces:
java.io.Serializable

public final class OID
extends java.lang.Object
implements java.io.Serializable

An object identifier. OIDs are normally used as object identifiers for persistent objects that use data store identity. They're also used for view objects, which actually use non-data store identity.

An OID is effectively a long containing a value in the range 0 to 260-1. The 60 bits encode three unsigned integer ID values; a 15-bit class ID value, a 30-bit object ID high value, and a 15-bit object ID low value.

The object ID value is separated into two parts to facilitate the use of a particular strategy for efficiently generating unique OID values, called the high/low approach. In this approach, the high value is obtained from a persistent store, and the low value is assigned locally by the application. The advantage is performance; it avoids the bottleneck of hitting the persistent store every time an ID needs to be generated.

Author:
Mike Martin
See Also:
StoreManager, Serialized Form

Field Summary
static int MAX_CLASSID
          The maximum class ID value.
static int MAX_LENGTH
          The maximum length of an OID in string form.
static int MAX_OBJIDHI
          The maximum hi portion of an object ID value.
static int MAX_OBJIDLO
          The maximum lo portion of an object ID value.
static long MAX_VALUE
          The maximum value of an OID as a long.
 
Constructor Summary
OID(int classID, int objIDHi, int objIDLo)
          Constructs an OID from three integer values.
OID(long value)
          Constructs an OID from its long value.
OID(java.lang.String s)
          Constructs an OID from its string representation.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int getClassID()
          Returns the class ID portion of the OID.
 int hashCode()
           
 long longValue()
          Returns the value of this OID as a long value.
 java.lang.String toString()
          Returns the string representation of the OID.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_VALUE

public static final long MAX_VALUE
The maximum value of an OID as a long. This equals 260 - 1.

See Also:
Constant Field Values

MAX_CLASSID

public static final int MAX_CLASSID
The maximum class ID value. This equals 215 - 1.

See Also:
Constant Field Values

MAX_OBJIDHI

public static final int MAX_OBJIDHI
The maximum hi portion of an object ID value. This equals 230 - 1.

See Also:
Constant Field Values

MAX_OBJIDLO

public static final int MAX_OBJIDLO
The maximum lo portion of an object ID value. This equals 215 - 1.

See Also:
Constant Field Values

MAX_LENGTH

public static final int MAX_LENGTH
The maximum length of an OID in string form.

See Also:
Constant Field Values
Constructor Detail

OID

public OID(long value)
    throws java.lang.IllegalArgumentException
Constructs an OID from its long value.

Parameters:
value - the long value of the OID.
Throws:
java.lang.IllegalArgumentException - if the argument is not in the range 0 to MAX_VALUE.

OID

public OID(int classID,
           int objIDHi,
           int objIDLo)
    throws java.lang.IllegalArgumentException
Constructs an OID from three integer values. All three arguments must be between zero and their respective maximums MAX_CLASSID, MAX_OBJIDHI, and MAX_OBJIDLO.

Parameters:
classID - the class ID value.
objIDHi - the hi portion of the object ID value.
objIDLo - the lo portion of the object ID value.
Throws:
java.lang.IllegalArgumentException - if one of the arguments is out of range.

OID

public OID(java.lang.String s)
    throws java.lang.IllegalArgumentException
Constructs an OID from its string representation.

Parameters:
s - the string representation of an OID.
Throws:
java.lang.IllegalArgumentException - if the given string representation is not valid.
See Also:
toString()
Method Detail

getClassID

public int getClassID()
Returns the class ID portion of the OID.

Returns:
the class ID.

longValue

public long longValue()
Returns the value of this OID as a long value.

Returns:
the value of this OID as a long.

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

toString

public java.lang.String toString()
Returns the string representation of the OID. The string representation is all three of the component values in base 32, zero-filled, separated by a dash '-' character:
 ccc-hhhhhh-lll
 

Returns:
the string representation of the OID.


Copyright 2001-2007 The TJDO Project All Rights Reserved.