gov.nist.nlpir.irf.proxy
Class Oid

java.lang.Object
  |
  +--gov.nist.nlpir.irf.proxy.Oid

public class Oid
extends java.lang.Object
implements java.io.Serializable

This class encapsulates the Object Identifier concept - a value which is unique to each object.

Right now, this class is just an int wrapper.

Version:
$Revision: 1.2 $
Author:
This software was produced by NIST, an agency of the U.S. government, and by statute is not subject to copyright in the United States. Recipients of this software assume all responsibilities associated with its operation, modification and maintenance.
See Also:
Serialized Form

Field Summary
private static boolean initialized
          Private lock for initialization of the class.
private static int lastUsedOid
          used to assign Oids to proxies only.
(package private) static long serialVersionUID
          serial version universal id - put here so Java does not insert one which may change due to revisions and make it impossible to deserialize earlier versions of serialized objects
private  int value
           
 
Constructor Summary
private Oid(int value)
          Private constructor used by getNextOid() and deserialization mechanism with readFrom().
 
Method Summary
 boolean equals(java.lang.Object obj)
          Overrides the Object method.
static int getLastUsedOid()
          Returns the value of the last used Oid It may be interesting to know how many Oids have already been given.
static Oid getNextOid()
          Gets the next Oid.
 int getValue()
          Gets the integer value oh this Oid.
 int hashCode()
          Returns a hashcode based on the value only.
static void init(int pLastUsedOid)
          Allows an exterior class to initialize the counter of given Oids.
static Oid readFrom(BufferedRandomAccessFile in)
          Reads the external representation of this object in the given file beginning where its pointer currently is.
 java.lang.String toString()
          Returns a string representation of this object
static void writeNullOid(BufferedRandomAccessFile out)
          Writes a null Oid to file This method is called by Oid clients when a optional Proxy they contain isn't present and thus doesn't have an Oid.
 void writeTo(BufferedRandomAccessFile out)
          Writes external representation of this object
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
serial version universal id - put here so Java does not insert one which may change due to revisions and make it impossible to deserialize earlier versions of serialized objects

value

private int value

initialized

private static boolean initialized
Private lock for initialization of the class.

lastUsedOid

private static int lastUsedOid
used to assign Oids to proxies only.
Constructor Detail

Oid

private Oid(int value)
Private constructor used by getNextOid() and deserialization mechanism with readFrom().
Method Detail

getValue

public final int getValue()
Gets the integer value oh this Oid.

toString

public final java.lang.String toString()
Returns a string representation of this object
Returns:
a string representation of this object
Overrides:
toString in class java.lang.Object

getNextOid

public static final Oid getNextOid()
Gets the next Oid. At initialization, starts at 1, and then gives them away 1 by 1. Doesn't use any mechanism like MS GUIDs or Corba UIDs, but the mechanism used for (de)serialization prevents the objects from being used outside IRF, so there is no problem with that.
Returns:
The next object identifier

getLastUsedOid

public static final int getLastUsedOid()
Returns the value of the last used Oid It may be interesting to know how many Oids have already been given.
Returns:
the last used Oid

init

public static final void init(int pLastUsedOid)
Allows an exterior class to initialize the counter of given Oids. This way, even after shutting down the application, Oids can be given in a consistent way, provided this method is called by an object that went through the shutdown remembering the last Oid given. This method can only be called once per run.
Parameters:
pLastUsedOid - the value to be used to initialize the lastUsedOid

hashCode

public final int hashCode()
Returns a hashcode based on the value only.
Overrides:
hashCode in class java.lang.Object

equals

public final boolean equals(java.lang.Object obj)
Overrides the Object method.
Returns:
True only if obj is an Oid with the same value (ie IS the same, but possibly a different object because materialization doesn't ensure unicity of Oids.
Overrides:
equals in class java.lang.Object

readFrom

public static Oid readFrom(BufferedRandomAccessFile in)
Reads the external representation of this object in the given file beginning where its pointer currently is.
Parameters:
in - random access file where the Oid must be read from.
Returns:
null if the Oid stored was null, the Oid otherwise.

writeTo

public void writeTo(BufferedRandomAccessFile out)
Writes external representation of this object
Parameters:
out - random access file handle

writeNullOid

public static void writeNullOid(BufferedRandomAccessFile out)
Writes a null Oid to file This method is called by Oid clients when a optional Proxy they contain isn't present and thus doesn't have an Oid. dTthe readFrom() method will restore this Oid as null.