org.objectweb.carol.cmi
Class ClusterId

java.lang.Object
  extended byorg.objectweb.carol.cmi.ClusterId
All Implemented Interfaces:
java.lang.Comparable, java.io.Externalizable, java.io.Serializable

public class ClusterId
extends java.lang.Object
implements java.io.Externalizable, java.lang.Comparable

A universally unique identifier for a cluster

Author:
Simon Nieuviarts
See Also:
Serialized Form

Constructor Summary
ClusterId()
          Create a new identifier
ClusterId(byte[] id)
          Create a new identifier from an array of byte
 
Method Summary
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object o)
          Compare two identifier
 byte[] getBytes()
          get the identifier in array of bytes type
 int hashCode()
          get the hascode
static void main(java.lang.String[] args)
          Useful for tests only.
 boolean match(byte[] ar)
          Compare two identifiers
static ClusterId read(java.io.DataInput in)
          Read an identifier from an input stream (java.io.DataInput)
 void readExternal(java.io.ObjectInput in)
          Read an identifier from an input stream (java.io.ObjectInput)
 java.lang.String toString()
          Readable format.
 void write(java.io.DataOutput out)
          Write an identifier on the output stream (java.io.DataOutput)
 void writeExternal(java.io.ObjectOutput out)
          Write an identifier on the output stream (java.io.ObjectOutput)
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClusterId

public ClusterId()
Create a new identifier


ClusterId

public ClusterId(byte[] id)
Create a new identifier from an array of byte

Parameters:
id - array of byte
Method Detail

hashCode

public int hashCode()
get the hascode

Returns:
hashcode

match

public boolean match(byte[] ar)
Compare two identifiers

Parameters:
ar - array of bytes to compare with the identifier
Returns:
true is equals, else false

equals

public boolean equals(java.lang.Object o)
Compare two identifier

Parameters:
o - object to compare
Returns:
true is equals, else false

getBytes

public byte[] getBytes()
get the identifier in array of bytes type

Returns:
array of bytes

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(java.lang.Object)

toString

public java.lang.String toString()
Readable format.

Returns:
cluster id in a human readable format

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read an identifier from an input stream (java.io.ObjectInput)

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - the input stream
Throws:
java.io.IOException - if exception is encountered
java.lang.ClassNotFoundException - if exception is encountered

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Write an identifier on the output stream (java.io.ObjectOutput)

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - the output stream
Throws:
java.io.IOException - if exception is encountered

read

public static ClusterId read(java.io.DataInput in)
                      throws java.io.IOException
Read an identifier from an input stream (java.io.DataInput)

Parameters:
in - the input stream
Throws:
java.io.IOException - if exception is encountered

write

public void write(java.io.DataOutput out)
           throws java.io.IOException
Write an identifier on the output stream (java.io.DataOutput)

Parameters:
out - the output stream
Throws:
java.io.IOException - if exception is encountered

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Useful for tests only.

Parameters:
args - arguments list
Throws:
java.lang.Exception - if an error occurs