com.sleepycat.persist.impl
Class VisitedObjects

java.lang.Object
  extended by com.sleepycat.persist.impl.VisitedObjects

 class VisitedObjects
extends java.lang.Object

Keeps track of a set of visited objects and their corresponding offset in a byte array. This uses a resizable int array for speed and simplicity. If in the future the array resizing or linear search are performance issues, we could try using an IdentityHashMap instead.

Author:
Mark Hayes

Field Summary
(package private) static int PRI_KEY_VISITED_OFFSET
           
(package private) static java.lang.String PROHIBIT_NESTED_REF_MSG
           
(package private) static java.lang.Object PROHIBIT_REF_OBJECT
           
(package private) static int PROHIBIT_REF_OFFSET
           
 
Constructor Summary
VisitedObjects()
          Creates an empty set.
 
Method Summary
(package private)  int add(java.lang.Object o, int offset)
          Adds a visited object and offset, growing the visited arrays as needed.
(package private)  java.lang.Object getObject(int offset)
          Returns the visited object for a given offset, or null if never visited.
(package private)  int getOffset(java.lang.Object o)
          Returns the offset for a visited object, or -1 if never visited.
(package private)  void replaceObject(java.lang.Object existing, java.lang.Object replacement)
          Replaces a given object in the list.
(package private)  void setObject(int index, java.lang.Object o)
          Sets the object for an existing slot index.
(package private)  void setOffset(int index, int offset)
          Sets the offset for an existing slot index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRI_KEY_VISITED_OFFSET

static final int PRI_KEY_VISITED_OFFSET
See Also:
Constant Field Values

PROHIBIT_REF_OFFSET

static final int PROHIBIT_REF_OFFSET
See Also:
Constant Field Values

PROHIBIT_REF_OBJECT

static final java.lang.Object PROHIBIT_REF_OBJECT

PROHIBIT_NESTED_REF_MSG

static final java.lang.String PROHIBIT_NESTED_REF_MSG
See Also:
Constant Field Values
Constructor Detail

VisitedObjects

VisitedObjects()
Creates an empty set.

Method Detail

add

int add(java.lang.Object o,
        int offset)
Adds a visited object and offset, growing the visited arrays as needed.

Returns:
the index of the new slot.

setObject

void setObject(int index,
               java.lang.Object o)
Sets the object for an existing slot index.


setOffset

void setOffset(int index,
               int offset)
Sets the offset for an existing slot index.


getOffset

int getOffset(java.lang.Object o)
Returns the offset for a visited object, or -1 if never visited.


getObject

java.lang.Object getObject(int offset)
Returns the visited object for a given offset, or null if never visited.


replaceObject

void replaceObject(java.lang.Object existing,
                   java.lang.Object replacement)
Replaces a given object in the list. Used when an object is converted after adding it to the list.



Copyright 2004,2008 Oracle. All rights reserved.