|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplanet.commonapi.Id
planet.symphony.SymphonyId
public class 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]. |
|
SymphonyId(java.math.BigInteger value)
Always throws an InitializationException because this constructor is nonapplicable to this type of Id. |
|
SymphonyId(byte[] data)
Builds an Id with the data in byte[] format. |
|
SymphonyId(double id)
Builds a new SymphonyId with the decimals that appear in id double argument. |
|
SymphonyId(int id)
Always throws an InitializationException, because this constructor is nonapplicable to this type of Id. |
|
SymphonyId(int[] data)
Always throws an InitializationException because this constructor is nonapplicable to this type of Id. |
|
SymphonyId(java.util.Random random)
Build a new random Id, based with the random number generator random. |
|
SymphonyId(java.lang.String sid)
Builds a new Id with the double value that appear in the argument as String value. |
|
SymphonyId(java.lang.String sid,
java.lang.String algorithm)
Builds a new Id from an arbitray string applying a one-way hashing algorithm such as SHA or MD5. |
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 |
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(long num)
Overwrite the static method to return the required Id. |
Id |
divideOn(long 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 |
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 |
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()
public SymphonyId(int id) throws InitializationException
id
- internal value as int argument.
InitializationException
- Alwayspublic SymphonyId(double id)
id
- double with the internal value to set to new Id.public SymphonyId(byte[] data) throws InitializationException
data
- A byte[] with the internal value.
InitializationException
- if an error occurs during
the initialization.toByteArray()
public SymphonyId(int[] data) throws InitializationException
data
- int[] with the internal value to set to new Id.
InitializationException
- Alwayspublic SymphonyId(java.lang.String sid) throws InitializationException
sid
- String representation of a double value.
InitializationException
- if an error occurs during the
initialization.public SymphonyId(java.lang.String sid, java.lang.String algorithm) throws InitializationException
sid
- An arbitray string.algorithm
- one-way hashing algorithm such as "SHA" or "MD5".
InitializationException
public SymphonyId(java.math.BigInteger value) throws InitializationException
value
- BigInteger with the internal value to the new Id.
InitializationException
- Always.public SymphonyId(java.util.Random random) throws InitializationException
random
- A java.util.Random instance.
InitializationException
- if any error has occurred during the initialization.Method Detail |
---|
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)
equals
in class java.lang.Object
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
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(long num)
num
- Total number of nodes in the network.
Id.divide(long)
public Id divideOn(long divisor)
divideOn
in class Id
divisor
- The number of parts to divide this Id.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |