|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplanet.commonapi.Id
planet.symphony.SymphonyId
This Id is backed up a double value. This value always must to be between 0.0 and 1.0, as Symphony establish.
Field Summary | |
protected static Id |
MAX
Inform the maximum value for this SymphonyId (1.0). |
static double |
MAX_SYMPHONY
Symphony specific constant: Maximum value for the internal value of Id. |
Constructor Summary | |
SymphonyId()
Must be initialized to initial value, in this case to [0.00]. |
Method Summary | |
Id |
add(Id offset)
Returns an Id corresponding to this Id plus a given distance |
boolean |
between(Id ccw,
Id cw)
Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle |
static double |
buildIdFrom(byte[] data)
Builds the double Id from a byte[]. |
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)
|
static Id |
divide(int num)
Overwrite the static method to return the required Id. |
Id |
divideOn(int divisor)
This method returns the arithmetical result of this division: thisId/divisor |
boolean |
equals(java.lang.Object o)
|
protected static double |
getDecimals(double value)
Gives back the value between 0.0 and 1.0 of the value, using only the decimals of the argument. |
double |
getDoubleValue()
|
static Id |
getMaximum()
This method returns the maximum value for a SymphonyId that is possible to build. |
java.lang.Object |
getValue()
Returns the internal representation value of this Id. |
int |
hashCode()
|
void |
setValue(double id)
|
void |
setValue(java.lang.Object newValue)
Sets the new value for this SymphonyId. |
Id |
setValues(java.math.BigInteger newValue)
Always throws a NoSuchMethodError error. |
Id |
setValues(byte[] newValue)
Sets the internal double value from the byte[] newValue. |
Id |
setValues(double newValue)
Sets the internal double value from the newValue |
Id |
setValues(int newValue)
Always throws a NoSuchMethodError error. |
Id |
setValues(int[] newValue)
Always throws a NoSuchMethodError error. |
Id |
setValues(java.util.Random valueGenerator)
Uses the valueGenerator to radomly build a new value. |
Id |
setValues(java.lang.String newValue)
Copies the string representation of a number to the internal double. |
Id |
shift(int cnt,
int fill)
Shift operator. shift(-1,0) multiplies value of this by two, shift(1,0) divides by 2 |
Id |
subtract(Id offset)
Returns an Id corresponding to this Id minus a given distance |
byte[] |
toByteArray()
Returns a (mutable) byte array representing this Id |
java.lang.String |
toString()
|
java.lang.String |
toStringFull()
Returns a string representing the full length of this Id. |
Methods inherited from class planet.commonapi.Id |
betweenE, Ebetween, setValue, setValues |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final double MAX_SYMPHONY
protected static Id MAX
Constructor Detail |
public SymphonyId()
Method Detail |
public static double buildIdFrom(byte[] data)
data
- Byte array get from a hashing function, like SHA-1 or MD5.
protected static double getDecimals(double value)
value
- Double which gives back its decimals.
public java.lang.Object getValue()
Id
getValue
in class Id
public double getDoubleValue()
public void setValue(double id)
public boolean between(Id ccw, Id cw)
Id
between
in class Id
ccw
- the counterclockwise idcw
- the clockwise id
public boolean clockwise(Id nid)
Id
clockwise
in class Id
nid
- The id to compare to
public Id add(Id offset)
Id
add
in class Id
offset
- the distance to add
public Id subtract(Id offset)
Id
subtract
in class Id
offset
- the distance to subtract
public Id shift(int cnt, int fill)
Id
shift
in class Id
cnt
- the number of bits to shift, negative shifts left, positive shifts rightfill
- value of bit shifted in (0 if fill == 0, 1 otherwise)
public byte[] toByteArray()
Id
toByteArray
in class Id
public java.lang.String toStringFull()
Id
toStringFull
in class Id
public boolean equals(java.lang.Object o)
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public int hashCode()
public java.lang.String toString()
public void setValue(java.lang.Object newValue)
setValue
in class Id
newValue
- New double value for this Id, wrapped
by a Double.Id.setValue(java.lang.Object)
public static Id getMaximum()
Id.getMaximum()
public static Id divide(int num)
num
- Total number of nodes in the network.
Id.divide(int)
public Id divideOn(int divisor)
divideOn
in class Id
divisor
- The number of parts to divide this Id.
public Id setValues(java.math.BigInteger newValue)
setValues
in class Id
newValue
- The new value
Id.setValues(java.math.BigInteger)
public Id setValues(byte[] newValue)
setValues
in class Id
newValue
- The new value
Id.setValues(byte[])
public Id setValues(double newValue)
setValues
in class Id
newValue
- The new value
Id.setValues(double)
public Id setValues(int newValue)
setValues
in class Id
newValue
- The new value.
Id.setValues(int)
public Id setValues(int[] newValue)
setValues
in class Id
newValue
- The new value
Id.setValues(int[])
public Id setValues(java.util.Random valueGenerator)
setValues
in class Id
valueGenerator
- A Random number generator.
Id.setValues(java.util.Random)
public Id setValues(java.lang.String newValue)
setValues
in class Id
newValue
- The new value.
An
- Error if the newValue is not a double value.Id.setValues(java.lang.String)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |