Class COM.odi.ExternalReference

java.lang.Object
   |
   +----COM.odi.ExternalReference

public class ExternalReference
extends Object
implements Cloneable
An object of the ExternalReference class is a reference to a particular persistent object. An application can encode the contents of an external reference into a text string, a network message, or any other data structure, and later decode it back into an external reference, from which it can get the persistent Java object.

You can use external references across transaction boundaries. They remain valid even if the database holding the referenced object is closed and opened.

However, external references to nonexported objects are not valid if the segment holding the referenced object has been reorganized, for example, a compaction tool has been run on the segment. To ensure that its encoded external references are still valid, an application must either only use external references to exported objects, or ensure that no reorgnization tools are run on the relevant segments.

Like other objects such as objects of class Database and Segment, an ExternalReference object can only be used in one session.


Constructor Index

 o ExternalReference()
Constructs an ExternalReference that refers to the null reference.
 o ExternalReference(Database, int, int)
Constructs an ExternalReference with the specified contents.
 o ExternalReference(Object)
Constructs an ExternalReference that refers to the specified object.

Method Index

 o equals(Object)
Two ExternalReference objects are considered to be equal if they both refer to the same underlying persistent object.
 o fromString(String)
Take a string that encodes an external reference, and create and return a corresponding ExternalReference object.
 o getDatabase()
Obtains the database that contains the referenced persistent object, or null if the underlying object is null.
 o getLocation()
Obtains the location of the referenced persistent object within its segment.
 o getObject()
Obtains the persistent object refered to by this ExternalReference.
 o getSegmentId()
Obtains the segment ID of the segment that contains the referenced persistent object.
 o hashCode()
Returns a hashCode for this ExternalReference.
 o setDatabase(Database)
Sets the database component of this external reference.
 o setLocation(int)
Sets the location component of this external reference.
 o setObject(Object)
Makes this ExternalReference refer to the specified persistent object.
 o setSegmentId(int)
Sets the segment ID component of this external reference.
 o toString()
Encodes this ExternalReference as a string.

Constructors

 o ExternalReference
  public ExternalReference()
Constructs an ExternalReference that refers to the null reference.

Throws: NoTransactionInProgressException
If there is no transaction in progress.
Throws: ObjectStoreException
If the current thread does not belong to a session and there is no global session.
 o ExternalReference
  public ExternalReference(Object o)
Constructs an ExternalReference that refers to the specified object.

Parameters:
o - The object that this external reference refers to. You can specify a Java peer object if it identifies a persistent C++ object.

Throws: DatabaseException
If the object belongs to the transient segment; in other words, if the object is a Java peer object that identifies a transient C++ object.
Throws: DatabaseNotOpenException
If the database is not open.
Throws: NoTransactionInProgressException
If there is no transaction in progress.
Throws: ObjectException
If the object is stale.
Throws: ObjectNotFoundException
If the object has been deleted.
Throws: ObjectNotPersistentException
The object is transient.
Throws: ObjectStoreException
If the session implied by the specified object has been terminated or if the current thread is associated with a session other than the session implied by the specified object.
 o ExternalReference
  public ExternalReference(Database d,
                           int segid,
                           int loc)
Constructs an ExternalReference with the specified contents.

Parameters:
d - The new database.
segid - The new segment ID.
loc - The new location.

Methods

 o equals
  public boolean equals(Object obj)
Two ExternalReference objects are considered to be equal if they both refer to the same underlying persistent object.

Overrides:
equals in class Object
 o hashCode
  public int hashCode()
Returns a hashCode for this ExternalReference.

Overrides:
hashCode in class Object
 o getDatabase
  public Database getDatabase()
Obtains the database that contains the referenced persistent object, or null if the underlying object is null.

Returns:
The database that contains the underlying persistent object.
 o getSegmentId
  public int getSegmentId()
Obtains the segment ID of the segment that contains the referenced persistent object.

Returns:
The segment ID of the segment that contains the underlying persistent object or -1 if the underlying object is null.
 o getLocation
  public int getLocation()
Obtains the location of the referenced persistent object within its segment.

Returns:
The location of the underlying persistent object within its segment, or -1 if the underlying object is null.
 o setDatabase
  public void setDatabase(Database d)
Sets the database component of this external reference.

Parameters:
d - The new database.
 o setSegmentId
  public void setSegmentId(int segid)
Sets the segment ID component of this external reference.

Parameters:
segid - The new segment ID.
 o setLocation
  public void setLocation(int loc)
Sets the location component of this external reference.

Parameters:
loc - The new location.
 o getObject
  public Object getObject()
Obtains the persistent object refered to by this ExternalReference.

Returns:
The persistent object refered to by this ExternalReference.
Throws: DatabaseException
If this is the transient database.
Throws: DatabaseNotOpenException
If the database is not open.
Throws: NoTransactionInProgressException
If no transaction is in progress.
Throws: ObjectNotFoundException
If the object was destroyed, or its segment was destroyed, or the contents of this object are not valid (for example, the segment ID is negative).
Throws: ObjectStoreException
If the session implied by the persistent object has been terminated or if the current thread is associated with a session other than the session implied by the persistent object.
Throws: SegmentException
If the Database is the transient database.
 o setObject
  public void setObject(Object o)
Makes this ExternalReference refer to the specified persistent object.

Parameters:
o - The object that this external reference should refer to.
Throws: DatabaseException
If the object belongs to the transient segment. In other words, if the object is a Java peer object that identifies a transient C++ object.
Throws: DatabaseNotOpenException
If the database is not open.
Throws: NoTransactionInProgressException
If there is no transaction in progress.
Throws: ObjectException
If the object is stale.
Throws: ObjectNotFoundException
If the object has been deleted.
Throws: ObjectNotPersistentException
If the object is transient.
Throws: ObjectStoreException
If the session implied by the persistent object has been terminated or if the current thread is associated with a session other than the session implied by the persistent object.
 o toString
  public String toString()
Encodes this ExternalReference as a string.

Returns:
The string encoding of this object.
Throws: ObjectStoreException
If the database's path name contains a vertical-bar character.
Overrides:
toString in class Object
 o fromString
  public static ExternalReference fromString(String string)
Take a string that encodes an external reference, and create and return a corresponding ExternalReference object. Open the object's database in ObjectStore.DEFAULT mode.

Parameters:
string - A string that encodes an external reference, with the encoding used by ExternalReference.toString.
Returns:
A new ExternalReference object.
Throws: AccessViolationException
If ObjectStore is unable to read the database because of a file system access violation.
Throws: DatabaseException
If the database is not in a valid format.
Throws: DatabaseNotFoundException
If a database with that name does not exist.
Throws: IllegalArgumentException
If the string is not a proper encoding of an external reference.
Throws: NoTransactionInProgressException
If no transaction is in progress.
Throws: ObjectStoreException
If the current thread is not associated with a session and there is no global session.

Copyright © 1996, 1997, 1998 Object Design, Inc. All rights reserved.