public class ID
extends java.lang.Object
implements jadex.bridge.service.types.dht.IID
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG
Debug field.
|
protected byte[] |
id
The byte array containing the id information.
|
| Constructor and Description |
|---|
ID()
Constructor.
|
ID(byte[] id)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
ID |
addPowerOfTwo(int powerOfTwo)
Adds 2^powerOfTwo to the value of this ID and returns the result as new
ID.
|
int |
compareTo(jadex.bridge.service.types.dht.IID otherKey)
Compare this ID with another.
|
boolean |
equals(java.lang.Object obj) |
static jadex.bridge.service.types.dht.IID |
get(jadex.bridge.IComponentIdentifier cid)
Hashes the given CID and returns an ID containing the hash.
|
static jadex.bridge.service.types.dht.IID |
get(java.lang.String str)
Hashes the given string and returns an ID containing the hash.
|
byte[] |
getBytes()
Returns the bytes.
|
byte[] |
getId()
Returns the internal byte array.
|
int |
getLength()
Returns the length of this ID in bits.
|
int |
hashCode() |
boolean |
isInInterval(jadex.bridge.service.types.dht.IID start,
jadex.bridge.service.types.dht.IID end)
Check whether this ID is in the given closed interval.
|
boolean |
isInInterval(jadex.bridge.service.types.dht.IID start,
jadex.bridge.service.types.dht.IID end,
boolean leftOpen,
boolean rightOpen)
Check whether this ID is in the given interval.
|
void |
setId(byte[] id)
Sets the internal byte array.
|
ID |
subtractPowerOfTwo(int powerOfTwo)
Subtracts 2^powerOfTwo from the value of this ID and returns the result
as new ID.
|
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(int numberOfBytes)
Returns a string of the hexadecimal representation of the first
n bytes of this ID, including leading zeros. |
java.lang.String |
toString() |
public static boolean DEBUG
protected byte[] id
public byte[] getId()
public void setId(byte[] id)
id - public byte[] getBytes()
getBytes in interface jadex.bridge.service.types.dht.IIDpublic int getLength()
getLength in interface jadex.bridge.service.types.dht.IIDpublic final java.lang.String toDecimalString(int numberOfBytes)
n bytes of this ID, including leading zeros.numberOfBytes - public ID subtractPowerOfTwo(int powerOfTwo)
powerOfTwo - exponent to be used for subtraction.public ID addPowerOfTwo(int powerOfTwo)
addPowerOfTwo in interface jadex.bridge.service.types.dht.IIDpowerOfTwo - exponent to be used for subtraction.public boolean isInInterval(jadex.bridge.service.types.dht.IID start,
jadex.bridge.service.types.dht.IID end,
boolean leftOpen,
boolean rightOpen)
isInInterval in interface jadex.bridge.service.types.dht.IIDstart - Begin of interval.end - End of interval.leftOpen - If true, the start value is included in the interval.rightOpen - If true, the end value is included in the interval.public boolean isInInterval(jadex.bridge.service.types.dht.IID start,
jadex.bridge.service.types.dht.IID end)
isInInterval in interface jadex.bridge.service.types.dht.IIDstart - Begin of interval.end - End of interval.public static jadex.bridge.service.types.dht.IID get(jadex.bridge.IComponentIdentifier cid)
cid - CID to hash.public static jadex.bridge.service.types.dht.IID get(java.lang.String str)
str - String to hash.public final int compareTo(jadex.bridge.service.types.dht.IID otherKey)
throws java.lang.ClassCastException
compareTo in interface java.lang.Comparable<jadex.bridge.service.types.dht.IID>java.lang.ClassCastExceptionpublic final java.lang.String toHexString(int numberOfBytes)
n bytes of this ID, including leading zeros.numberOfBytes - public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object