|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.uniba.wiai.lspi.chord.data.ID
public final class ID
Identifier for nodes and user-defined objects. New instances of this class are created either when a node joins the network, or by the local node inserting a user-defined object. Once created, an ID instance is unmodifiable. IDs of same length can be compared as this class implements java.lang.Comparable. IDs of different length cannot be compared.
Constructor Summary | |
---|---|
ID(byte[] id1)
Creates a new ID consisting of the given byte[] array. |
Method Summary | |
---|---|
ID |
addPowerOfTwo(int powerOfTwo)
Calculates the ID which is 2^powerOfTwo bits greater than the current ID modulo the maximum ID and returns it. |
int |
compareTo(ID otherKey)
Compare current ID with the given object. |
boolean |
equals(java.lang.Object equalsTo)
Checks the given object for equality with this ID . |
int |
getLength()
Returns length of this ID measured in bits. |
int |
hashCode()
|
boolean |
isInInterval(ID fromID,
ID toID)
Checks if this ID is in the interval determined by the two given IDs. |
java.lang.String |
toBinaryString()
Returns a string of the binary representation of this ID, including leading zeros. |
java.lang.String |
toBinaryString(int numberOfBytes)
Returns a string of the binary representation of the first n
bytes of this ID, including leading zeros. |
java.lang.String |
toDecimalString()
Returns a string of the decimal representation of this ID, including leading zeros. |
java.lang.String |
toDecimalString(int numberOfBytes)
Returns a string of the decimal representation of the first n bytes of this ID, including leading zeros. |
java.lang.String |
toHexString()
Returns a string of the hexadecimal representation of this ID, including leading zeros. |
java.lang.String |
toHexString(int numberOfBytes)
Returns a string of the hexadecimal representation of the first n bytes of this ID, including leading zeros. |
java.lang.String |
toString()
Returns a string of the decimal representation of this ID, including leading zeros. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ID(byte[] id1)
id1
- Byte array containing the ID.Method Detail |
---|
public final java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String toHexString(int numberOfBytes)
n
bytes of this ID, including leading zeros.
numberOfBytes
-
public final java.lang.String toHexString()
public final java.lang.String toDecimalString(int numberOfBytes)
n
bytes of this ID, including leading zeros.
numberOfBytes
-
public final java.lang.String toDecimalString()
public final java.lang.String toBinaryString(int numberOfBytes)
n
bytes of this ID, including leading zeros.
numberOfBytes
-
public final java.lang.String toBinaryString()
public final int getLength()
public final ID addPowerOfTwo(int powerOfTwo)
powerOfTwo
- Power of two which is added to the current ID. Must be a value
of the interval [0, length-1], including both extremes.
public final boolean equals(java.lang.Object equalsTo)
ID
.
equals
in class java.lang.Object
equalsTo
- Object to check equality with this ID
.public final int compareTo(ID otherKey) throws java.lang.ClassCastException
compareTo
in interface java.lang.Comparable<ID>
java.lang.ClassCastException
public final int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public final boolean isInInterval(ID fromID, ID toID)
fromID
- Lower bound of interval.toID
- Upper bound of interval.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |