uka.transport
Class LayeredObjectSpace

java.lang.Object
  extended byuka.util.IDConstants
      extended byuka.transport.ObjectSpaceAdapter
          extended byuka.transport.LayeredObjectSpace
All Implemented Interfaces:
ObjectSpace, java.io.Serializable

public class LayeredObjectSpace
extends ObjectSpaceAdapter

This class layers an overlay over some original object space. The layered object space behaves like the original space for identifiers that are part of the original object space at the time of the creation of the layerd object space. New identifier assignments are stored in the overlay space.

Note: It is not possible to stack multiple layered object spaces. The original object space must not be a layered object space. This restriction is necessary, because a layerd object space devides the available identifier range into a lower part for the original space and an upper part for the overlay.

See Also:
Serialized Form

Field Summary
private static int FIRST_OVERLAY_ID
           
protected  ObjectSpace overlay
           
 
Fields inherited from class uka.transport.ObjectSpaceAdapter
original
 
Fields inherited from class uka.util.IDConstants
FIRST_NEW_ID, FIRST_VALID_ID, INVALID_ID, UNUSED_ID
 
Constructor Summary
LayeredObjectSpace(ObjectSpace original)
           
LayeredObjectSpace(ObjectSpace original, ObjectSpace overlay)
           
 
Method Summary
 void clear()
          Clears the object space by removing all identifier assignments.
 int findID(java.lang.Object obj)
          Same as getID(java.lang.Object), but does not assign the object to this object space, if the object was not yet a member.
 int getID(java.lang.Object obj)
          Returns the identifier for a given object.
 java.lang.Object getObject(int id)
          Finds the object for a given identifier.
 ObjectSpace getOverlay()
           
 void includeID(int id)
          Make the object that corresponds to the given identifier part of this object space.
 boolean isAccepted(int id)
          Decides whether an object reference should be blocked during transmission through a MarshalStream/UnmarshalStream pair.
 boolean isIncluded(int id)
          Decides whether the obect that corresponds to the given identifier is part of this object space.
 boolean isShared(int id)
           
 boolean isUsed(int id)
          Checks whether this object space has an object assigned to the given identifier.
 void remove(int id)
          Removes the given identifer from this object space.
 void resetObject(int id, java.lang.Object obj)
          Reassigns a new object to an existing identifier.
 ObjectSpace resetOverlay()
           
 void setObject(int id, java.lang.Object obj)
          Assigns the given object to an application provided identifier and includes the given object to this object space.
 void setOverlay(ObjectSpace overlay)
           
 
Methods inherited from class uka.transport.ObjectSpaceAdapter
getOriginal, getUsedIDs
 
Methods inherited from class uka.util.IDConstants
isNew, isValid, normalizeID, toggleNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST_OVERLAY_ID

private static final int FIRST_OVERLAY_ID
See Also:
Constant Field Values

overlay

protected ObjectSpace overlay
Constructor Detail

LayeredObjectSpace

public LayeredObjectSpace(ObjectSpace original)

LayeredObjectSpace

public LayeredObjectSpace(ObjectSpace original,
                          ObjectSpace overlay)
Method Detail

setOverlay

public final void setOverlay(ObjectSpace overlay)

resetOverlay

public final ObjectSpace resetOverlay()

getOverlay

public final ObjectSpace getOverlay()

getID

public int getID(java.lang.Object obj)
Description copied from interface: ObjectSpace
Returns the identifier for a given object. If the object was presented to the ObjectSpace the first time, the #isNew method returns true for the resulting identifier.

Specified by:
getID in interface ObjectSpace
Overrides:
getID in class ObjectSpaceAdapter

findID

public int findID(java.lang.Object obj)
Description copied from interface: ObjectSpace
Same as ObjectSpace.getID(java.lang.Object), but does not assign the object to this object space, if the object was not yet a member.

Specified by:
findID in interface ObjectSpace
Overrides:
findID in class ObjectSpaceAdapter

getObject

public java.lang.Object getObject(int id)
Description copied from interface: ObjectSpace
Finds the object for a given identifier.

Specified by:
getObject in interface ObjectSpace
Overrides:
getObject in class ObjectSpaceAdapter

isUsed

public boolean isUsed(int id)
Description copied from interface: ObjectSpace
Checks whether this object space has an object assigned to the given identifier. This is most useful, for traversing a non-contiguous identifier space. ObjectSpace.isUsed(int) returns true for identifier returned from ObjectSpace.getID(java.lang.Object).

Specified by:
isUsed in interface ObjectSpace
Overrides:
isUsed in class ObjectSpaceAdapter

isShared

public boolean isShared(int id)
Specified by:
isShared in interface ObjectSpace
Overrides:
isShared in class ObjectSpaceAdapter

setObject

public void setObject(int id,
                      java.lang.Object obj)
Description copied from interface: ObjectSpace
Assigns the given object to an application provided identifier and includes the given object to this object space.

Specified by:
setObject in interface ObjectSpace
Overrides:
setObject in class ObjectSpaceAdapter

resetObject

public void resetObject(int id,
                        java.lang.Object obj)
Description copied from interface: ObjectSpace
Reassigns a new object to an existing identifier. The effect is the same as removing the identifier first and then reassigning it with ObjectSpace.setObject(int, java.lang.Object). Since ObjectSpace.setObject(int, java.lang.Object) may be overridden in subclasses to handle the first assignment of an identifier especially, ObjectSpace.resetObject(int, java.lang.Object) can be used to avoid additional calls to ObjectSpace.setObject(int, java.lang.Object).

Specified by:
resetObject in interface ObjectSpace
Overrides:
resetObject in class ObjectSpaceAdapter

remove

public void remove(int id)
Description copied from interface: ObjectSpace
Removes the given identifer from this object space. This operation removes the complete binding of the corresponding object to its identifier from this object space. A future call to ObjectSpace.getID(java.lang.Object) with the object corresponding to the given identifier as argument will result in a new identifier.

Specified by:
remove in interface ObjectSpace
Overrides:
remove in class ObjectSpaceAdapter

clear

public void clear()
Description copied from interface: ObjectSpace
Clears the object space by removing all identifier assignments.

Specified by:
clear in interface ObjectSpace
Overrides:
clear in class ObjectSpaceAdapter

includeID

public void includeID(int id)
Description copied from interface: ObjectSpace
Make the object that corresponds to the given identifier part of this object space. An object is part of an object space, if the ObjectSpace.isIncluded(int) method returns true for the corresponding identifier. An object can have an assigned identifier in some object space without being part of that object space.

Specified by:
includeID in interface ObjectSpace
Overrides:
includeID in class ObjectSpaceAdapter

isIncluded

public boolean isIncluded(int id)
Description copied from interface: ObjectSpace
Decides whether the obect that corresponds to the given identifier is part of this object space.

Specified by:
isIncluded in interface ObjectSpace
Overrides:
isIncluded in class ObjectSpaceAdapter

isAccepted

public boolean isAccepted(int id)
Description copied from interface: ObjectSpace
Decides whether an object reference should be blocked during transmission through a MarshalStream/UnmarshalStream pair. If a call to ObjectSpace.isAccepted(int) on the ObjectSpace of the sender-side stream returns false for an object identifier, a reference to the corresponding object is blocked (replaced with null).

Specified by:
isAccepted in interface ObjectSpace
Overrides:
isAccepted in class ObjectSpaceAdapter