com.ashridgetech.prevdb.client
Class Ref

java.lang.Object
  |
  +--com.ashridgetech.prevdb.client.Ref

public class Ref
extends Object

A reference from one persistent object to another. Holds only the oid of the referenced object until it is accessed, when it finds the object by looking it up in the extent of the referenced type. Immutable - a new object must be created if the reference changes.

Version:
1.0
Author:
paulb

Constructor Summary
Ref()
          Creates new null Ref that refers to no object.
Ref(Persistent object)
          Creates new Ref referring to a Persistent object.
Ref(Persistent container, Class persistentClass, Object oid)
          Creates new Ref with the oid of a Persistent object.
Ref(PersistentManager manager, Object oid)
          Creates new Ref with the oid of a Persistent object.
 
Method Summary
 boolean equals(Object o)
           
 Persistent get()
          Get the object referenced by this Ref.
 Object getOid()
          Get the oid of the object referenced by this Ref.
 int hashCode()
           
 boolean isNull()
          Indicate whether this ref is null (ie does not refer to an object)
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ref

public Ref()
Creates new null Ref that refers to no object.


Ref

public Ref(Persistent object)
Creates new Ref referring to a Persistent object.

Parameters:
object - the Persistent to which the new Ref will refer - may be null

Ref

public Ref(Persistent container,
           Class persistentClass,
           Object oid)
Creates new Ref with the oid of a Persistent object. Assumes the reference is to an object managed by the PersistentManager for persistentClass within the PrevDb to which container belongs

Parameters:
container - the object that contains this Ref
persistentClass - the class of object to which this Ref refers
oid - the oid of Persistent to which the new Ref will refer - NOT the Persistent itself
Throws:
IllegalArgumentException - if a Persistent is passed to oid

Ref

public Ref(PersistentManager manager,
           Object oid)
Creates new Ref with the oid of a Persistent object.

Parameters:
manager - the manager of the class of object to which this Ref refers - may be null if oid is null
oid - the oid of Persistent to which the new Ref will refer
Method Detail

getOid

public Object getOid()
Get the oid of the object referenced by this Ref.

Returns:
the oid

get

public Persistent get()
Get the object referenced by this Ref.


isNull

public boolean isNull()
Indicate whether this ref is null (ie does not refer to an object)

Returns:
true if it is null

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003 Ashridge Technologies Ltd. All Rights Reserved.