org.apache.jackrabbit.mk.model
Class Id

java.lang.Object
  extended by org.apache.jackrabbit.mk.model.Id
All Implemented Interfaces:
Comparable<Id>

public class Id
extends Object
implements Comparable<Id>

Represents an internal identifier, uniquely identifying a Node or a Commit.

This implementation aims at minimizing the in-memory footprint of an identifier instance. therefore it doesn't cash e.g. the hashCode or the string representation.

Important Note:

An Id is considered immutable. The byte[] passed to Id(byte[]) must not be reused or modified, the same applies for the byte[] returned by getBytes().


Constructor Summary
Id(byte[] raw)
          Creates a new instance based on the passed byte[].
 
Method Summary
 int compareTo(Id o)
           
 boolean equals(Object obj)
           
static Id fromLong(long value)
          Creates an Id instance from a long.
static Id fromString(String s)
          Creates an Id instance from its string representation as returned by toString().
 byte[] getBytes()
          Returns the raw byte representation of this identifier.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Id

public Id(byte[] raw)
Creates a new instance based on the passed byte[].

The passed byte[] mus not be reused, it's assumed to be owned by the new Id instance.

Parameters:
raw - the byte representation
Method Detail

fromString

public static Id fromString(String s)
Creates an Id instance from its string representation as returned by toString().

The following condition holds true:

 Id someId = ...;
 assert(Id.fromString(someId.toString()).equals(someId));
 

Parameters:
s - a string representation of an Id
Returns:
an Id instance

fromLong

public static Id fromLong(long value)
Creates an Id instance from a long.

Parameters:
l - a long
Returns:
an Id instance

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Id o)
Specified by:
compareTo in interface Comparable<Id>

getBytes

public byte[] getBytes()
Returns the raw byte representation of this identifier.

The returned byte[] MUST NOT be modified!

Returns:
the raw byte representation


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.