ePOST API

rice.p2p.past.gc
Class GCId

java.lang.Object
  extended by rice.p2p.past.gc.GCId
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, Id

public class GCId
extends java.lang.Object
implements Id

Version:
$Id: GCId.java 2302 2005-03-11 00:58:26Z jeffh $
Author:
Alan Mislove
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface rice.p2p.commonapi.Id
Id.Distance
 
Field Summary
protected  long expiration
          The ringId which this ringId represents
protected  Id id
          The id which this ringId represents
 
Constructor Summary
GCId(Id id, long expiration)
          Constructor
 
Method Summary
 Id addToId(Id.Distance offset)
          Returns an Id corresponding to this Id plus a given distance
 boolean clockwise(Id nid)
          Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring.
 int compareTo(java.lang.Object o)
          Returns this id compared to the target
 Id.Distance distanceFromId(Id nid)
          Returns the shorter numerical distance on the ring between a pair of Ids.
 boolean equals(java.lang.Object o)
          Returns whether or not this object is equal to the provided one
 int getByteArrayLength()
          Returns the length of the byte[] representing this Id
 long getExpiration()
          Returns this gcid's expiration time
 Id getId()
          Returns this gcid's id
 int hashCode()
          Returns the hashCode
 boolean isBetween(Id ccw, Id cw)
          Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle
 Id.Distance longDistanceFromId(Id nid)
          Returns the longer numerical distance on the ring between a pair of Ids.
 byte[] toByteArray()
          Returns a (mutable) byte array representing this Id
 void toByteArray(byte[] array, int offset)
          Stores the byte[] value of this Id in the provided byte array
 java.lang.String toString()
          Returns a string representing this ring Id.
 java.lang.String toStringFull()
          Returns a string representing the full length of this Id.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected Id id
The id which this ringId represents


expiration

protected long expiration
The ringId which this ringId represents

Constructor Detail

GCId

public GCId(Id id,
            long expiration)
Constructor

Parameters:
node - The node to base this node off of
Method Detail

getId

public Id getId()
Returns this gcid's id

Returns:
The id of this ringid

getExpiration

public long getExpiration()
Returns this gcid's expiration time

Returns:
The expiration time of this gcid

isBetween

public boolean isBetween(Id ccw,
                         Id cw)
Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle

Specified by:
isBetween in interface Id
Parameters:
ccw - the counterclockwise id
cw - the clockwise id
Returns:
true if this is between ccw (inclusive) and cw (exclusive), false otherwise

clockwise

public boolean clockwise(Id nid)
Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring. An Id is clockwise if it is within the half circle clockwise from this on the ring. An Id is considered counter-clockwise from itself.

Specified by:
clockwise in interface Id
Parameters:
nid - The id to compare to
Returns:
true if clockwise, false otherwise.

addToId

public Id addToId(Id.Distance offset)
Returns an Id corresponding to this Id plus a given distance

Specified by:
addToId in interface Id
Parameters:
offset - the distance to add
Returns:
the new Id

distanceFromId

public Id.Distance distanceFromId(Id nid)
Returns the shorter numerical distance on the ring between a pair of Ids.

Specified by:
distanceFromId in interface Id
Parameters:
nid - the other node id.
Returns:
the distance between this and nid.

longDistanceFromId

public Id.Distance longDistanceFromId(Id nid)
Returns the longer numerical distance on the ring between a pair of Ids.

Specified by:
longDistanceFromId in interface Id
Parameters:
nid - the other node id.
Returns:
the distance between this and nid.

toByteArray

public byte[] toByteArray()
Returns a (mutable) byte array representing this Id

Specified by:
toByteArray in interface Id
Returns:
A byte[] representing this Id

toByteArray

public void toByteArray(byte[] array,
                        int offset)
Stores the byte[] value of this Id in the provided byte array

Specified by:
toByteArray in interface Id

getByteArrayLength

public int getByteArrayLength()
Returns the length of the byte[] representing this Id

Specified by:
getByteArrayLength in interface Id
Returns:
The length of the byte[] representing this Id

equals

public boolean equals(java.lang.Object o)
Returns whether or not this object is equal to the provided one

Overrides:
equals in class java.lang.Object
Parameters:
o - The object to compare to
Returns:
Whether or not this is object is equal

hashCode

public int hashCode()
Returns the hashCode

Overrides:
hashCode in class java.lang.Object
Returns:
hashCode

toString

public java.lang.String toString()
Returns a string representing this ring Id.

Overrides:
toString in class java.lang.Object
Returns:
A string with all of this Id

toStringFull

public java.lang.String toStringFull()
Returns a string representing the full length of this Id.

Specified by:
toStringFull in interface Id
Returns:
A string with all of this Id

compareTo

public int compareTo(java.lang.Object o)
Returns this id compared to the target

Specified by:
compareTo in interface java.lang.Comparable
Returns:
The comparison

ePOST API

Copyright © 2001-2005 - Rice Pastry.