Rice Pastry API

rice.p2p.commonapi
Interface Id

All Superinterfaces:
java.lang.Comparable<Id>, java.io.Serializable
All Known Implementing Classes:
FragmentKey, GCId, Id, MemoryStorageTest.VariableId, RingId, VersionKey

public interface Id
extends java.lang.Comparable<Id>, java.io.Serializable

Version:
$Id: Id.java 4654 2009-01-08 16:33:07Z jeffh $
Author:
Alan Mislove, Peter Druschel

Nested Class Summary
static interface Id.Distance
          A class for representing and manipulating the distance between two Ids on the circle.
 
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.
 Id.Distance distanceFromId(Id nid)
          Returns the shorter numerical distance on the ring between a pair of Ids.
 int getByteArrayLength()
          Returns the length of the byte[] representing this Id
 short getType()
           
 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.
 void serialize(OutputBuffer buf)
          Serialize
 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 toStringFull()
          Returns a string representing the full length of this Id.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

isBetween

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

Parameters:
ccw - the counterclockwise id
cw - the clockwise id
Returns:
true if this is between ccw (inclusive) and cw (exclusive), false otherwise

clockwise

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.

Parameters:
nid - The id to compare to
Returns:
true if clockwise, false otherwise.

addToId

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

Parameters:
offset - the distance to add
Returns:
the new Id

distanceFromId

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

Parameters:
nid - the other node id.
Returns:
the distance between this and nid.

longDistanceFromId

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

Parameters:
nid - the other node id.
Returns:
the distance between this and nid.

toByteArray

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

Returns:
A byte[] representing this Id

toByteArray

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


getByteArrayLength

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

Returns:
The length of the byte[] representing this Id

toStringFull

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

Returns:
A string with all of this Id

serialize

void serialize(OutputBuffer buf)
               throws java.io.IOException
Serialize

Parameters:
buf -
Throws:
java.io.IOException

getType

short getType()

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection