messif.objects.keys
Class DoubleKey

java.lang.Object
  extended by messif.objects.keys.AbstractObjectKey
      extended by messif.objects.keys.DoubleKey
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<AbstractObjectKey>, BinarySerializable

public class DoubleKey
extends AbstractObjectKey

The object key that contains a double value and a locator URI.

See Also:
Serialized Form

Field Summary
 double key
          The double key
 
Constructor Summary
protected DoubleKey(BinaryInput input, BinarySerializator serializator)
          Creates a new instance of DoubleKey loaded from binary input.
  DoubleKey(java.lang.String keyString)
          Creates a new instance of AbstractObjectKey given a buffered reader with the first line of the following format: "doubleKey locatorUri"
  DoubleKey(java.lang.String locatorURI, double key)
          Creates a new instance of DoubleKey
 
Method Summary
 int binarySerialize(BinaryOutput output, BinarySerializator serializator)
          Binary-serialize this object into the output.
 int compareTo(AbstractObjectKey o)
          Compare the keys according to the double key
 boolean equals(java.lang.Object obj)
          Equals according to the double key.
 int getBinarySize(BinarySerializator serializator)
          Returns the exact size of the binary-serialized version of this object in bytes.
 int hashCode()
          Return the double key converted to int.
 java.lang.String toString()
          Returns the URI string.
protected  void writeData(java.io.OutputStream stream)
          Store this key's data to a text stream.
 
Methods inherited from class messif.objects.keys.AbstractObjectKey
create, getLocatorURI, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

key

public final double key
The double key

Constructor Detail

DoubleKey

public DoubleKey(java.lang.String locatorURI,
                 double key)
Creates a new instance of DoubleKey

Parameters:
locatorURI - the URI locator
key - the double key of the object - it musn't be null

DoubleKey

public DoubleKey(java.lang.String keyString)
          throws java.lang.IllegalArgumentException
Creates a new instance of AbstractObjectKey given a buffered reader with the first line of the following format: "doubleKey locatorUri"

Parameters:
keyString - the text stream to read an object from
Throws:
java.lang.IllegalArgumentException - if the string is not of format "doubleKey locatorUri"

DoubleKey

protected DoubleKey(BinaryInput input,
                    BinarySerializator serializator)
             throws java.io.IOException
Creates a new instance of DoubleKey loaded from binary input.

Parameters:
input - the input to read the DoubleKey from
serializator - the serializator used to write objects
Throws:
java.io.IOException - if there was an I/O error reading from the input
Method Detail

writeData

protected void writeData(java.io.OutputStream stream)
                  throws java.io.IOException
Description copied from class: AbstractObjectKey
Store this key's data to a text stream. This method should have the opposite deserialization in constructor. Note that this method should not write a line separator (\n).

Overrides:
writeData in class AbstractObjectKey
Parameters:
stream - the stream to store this object to
Throws:
java.io.IOException - if there was an error while writing to stream

compareTo

public int compareTo(AbstractObjectKey o)
Compare the keys according to the double key

Specified by:
compareTo in interface java.lang.Comparable<AbstractObjectKey>
Overrides:
compareTo in class AbstractObjectKey
Parameters:
o - the key to compare this key with
Returns:
a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object

hashCode

public int hashCode()
Return the double key converted to int.

Overrides:
hashCode in class AbstractObjectKey
Returns:
the double key converted to int

equals

public boolean equals(java.lang.Object obj)
Equals according to the double key. If the parameter is not of the DoubleKey class or subclass then return false.

Overrides:
equals in class AbstractObjectKey
Parameters:
obj - object to compare this object to
Returns:
true if this object is the same as the obj argument; false otherwise

toString

public java.lang.String toString()
Description copied from class: AbstractObjectKey
Returns the URI string.

Overrides:
toString in class AbstractObjectKey
Returns:
the URI string

binarySerialize

public int binarySerialize(BinaryOutput output,
                           BinarySerializator serializator)
                    throws java.io.IOException
Binary-serialize this object into the output.

Specified by:
binarySerialize in interface BinarySerializable
Overrides:
binarySerialize in class AbstractObjectKey
Parameters:
output - the output that this object is binary-serialized into
serializator - the serializator used to write objects
Returns:
the number of bytes actually written
Throws:
java.io.IOException - if there was an I/O error during serialization

getBinarySize

public int getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.

Specified by:
getBinarySize in interface BinarySerializable
Overrides:
getBinarySize in class AbstractObjectKey
Parameters:
serializator - the serializator used to write objects
Returns:
size of the binary-serialized version of this object