Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rice.p2p.multiring
Class RingId

    java.lang.Object
      rice.p2p.multiring.RingId

All Implemented Interfaces:
  java.io.Serializable, java.lang.Comparable, Id

    public class RingId

extends java.lang.Object
implements Id

Version:
  $Id: RingId.java 3507 2006-12-21 13:18:37Z 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 Id` | `id` The id which this ringId represents
`protected Id` | `ringId` The ringId which this ringId represents
`static short` | `TYPE`

Constructor Summary
`RingId(InputBuffer buf, Endpoint endpoint)`

Method Summary
`Id` | `addToId(Id.Distance offset)` Returns an Id corresponding to this Id plus a given distance
`static RingId` | `build(Id ringId, Id id)` Constructor.
`static RingId` | `build(java.lang.String s)` Method which splits apart a ringid string and returns the RingID
`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
`Id` | `getId()` Returns this ringid's id
`Id` | `getRingId()` Returns this ringid's ring id
`short` | `getType()` Raw Serialization
`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.
`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` | `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

### TYPE

    public static short TYPE

### id

    protected Id id

  The id which this ringId represents

### ringId

    protected Id ringId

  The ringId which this ringId represents

Constructor Detail

### RingId

    public RingId(InputBuffer buf,
                  Endpoint endpoint)
           throws java.io.IOException

Throws:
  `java.io.IOException`

Method Detail

### build

    public static RingId build(Id ringId,
                               Id id)

  Constructor.

  Parameters:
    `material` - an array of length at least IdBitLength/32 containing raw Id material.

### build

    public static RingId build(java.lang.String s)

  Method which splits apart a ringid string and returns the RingID

  Parameters:
    `s` - The ring to parse
  Returns:
    The result

### getId

    public Id getId()

  Returns this ringid's id

  Returns:
    The id of this ringid

### getRingId

    public Id getRingId()

  Returns this ringid's ring id

  Returns:
    The ring id of this ringid

### 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

### getType

    public short getType()

  Raw Serialization

  Specified by:
    `getType` in interface `Id`

### serialize

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

  Description copied from interface: `Id`
  Serialize

  Specified by:
    `serialize` in interface `Id`
  Throws:
    `java.io.IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 - Rice Pastry.