|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.opencms.util.CmsUUID
public final class CmsUUID
Generates a UUID using spatial and temporal uniqueness.
Spatial uniqueness is derived from ethernet address (MAC, 802.1); temporal from system clock.
For more information about the algorithm used, please see draft-leach-uuids-guids-01.txt.
Because Java is unable to read the MAC address of the machine
(without using JNI), the MAC address has to be provided first
by using the static init(String) method.
This class is just a facade wrapper for the "real" UUID implementation.
| Field Summary | |
|---|---|
static String |
UUID_REGEX
A regular expression for matching UUIDs. |
| Constructor Summary | |
|---|---|
CmsUUID()
Creates a new UUID. |
|
CmsUUID(byte[] data)
Create a UUID based on a binary data array. |
|
CmsUUID(String uuid)
Create a UUID based on a String. |
|
| Method Summary | |
|---|---|
static void |
checkId(CmsUUID id,
boolean canBeNull)
Check that the given id is not the null id. |
Object |
clone()
Creates a clone of this CmsUUID. |
int |
compareTo(CmsUUID obj)
|
boolean |
equals(Object obj)
|
static CmsUUID |
getConstantUUID(String name)
Returns a constant (name based) UUID, based on the given name in the OpenCms name space. |
static String |
getDummyEthernetAddress()
Returns a String representing a dummy (random based) ethernet address. |
static CmsUUID |
getNullUUID()
Returns a null UUID, use this null UUID to check if a UUID has been initialized or not. |
static CmsUUID |
getOpenCmsUUID()
Returns a constant (name based) UUID for OpenCms, based on "www.opencms.org" in the dns name space. |
String |
getStringValue()
Returns the String representation of this UUID, same as toString(). |
int |
hashCode()
Optimized hashCode implementation for UUID's. |
static void |
init(String ethernetAddress)
Initialize the UUID generator with the ethernet address of the server machine. |
boolean |
isNullUUID()
Returns true if this UUID is equal to the null UUID. |
static boolean |
isValidUUID(String uuid)
Returns true if the given UUID is valid. |
void |
readExternal(ObjectInput in)
|
byte[] |
toByteArray()
Returns the UUID as a 16-byte byte array. |
String |
toString()
|
static CmsUUID |
valueOf(String uuid)
Returns the given String transformed to a UUID in case the String is a valid UUID. |
void |
writeExternal(ObjectOutput out)
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String UUID_REGEX
| Constructor Detail |
|---|
public CmsUUID()
Please note that the static init() method has to be called first to initialize the internet address of the machine.
public CmsUUID(byte[] data)
data - a binary data array representing a UUID
public CmsUUID(String uuid)
throws NumberFormatException
uuid - a String representing a UUID
NumberFormatException - in case uuid is not a valid UUID| Method Detail |
|---|
public static void checkId(CmsUUID id,
boolean canBeNull)
id - the id to checkcanBeNull - only if flag is set, null is acceptedisNullUUID()public static CmsUUID getConstantUUID(String name)
name - the name to derive the uuid from
public static String getDummyEthernetAddress()
public static CmsUUID getNullUUID()
public static CmsUUID getOpenCmsUUID()
public static void init(String ethernetAddress)
throws CmsInitException
The ethernetAddress parameter must represent a 'standard' ethernet MAC address string (e.g. '00:C0:F0:3D:5B:7C').
ethernetAddress - the ethernet address of the server machine
CmsInitException - in case the ethernetAddress String is not a valid ethernet addresspublic static boolean isValidUUID(String uuid)
true if the given UUID is valid.
uuid - the UUID to check
true if the given UUID is valid
public static CmsUUID valueOf(String uuid)
throws NumberFormatException
uuid - the String to transform to a UUID
NumberFormatException - in case the String is no valid UUIDpublic Object clone()
clone in class Objectpublic int compareTo(CmsUUID obj)
compareTo in interface Comparable<CmsUUID>Comparable.compareTo(Object)public boolean equals(Object obj)
equals in class ObjectObject.equals(java.lang.Object)public String getStringValue()
toString().This method is useful if bean like access to the UUID String is required.
public int hashCode()
hashCode in class ObjectObject.hashCode()public boolean isNullUUID()
public void readExternal(ObjectInput in)
readExternal in interface ExternalizableExternalizable.readExternal(java.io.ObjectInput)public byte[] toByteArray()
public String toString()
toString in class ObjectObject.toString()
public void writeExternal(ObjectOutput out)
throws IOException
writeExternal in interface ExternalizableIOExceptionExternalizable.writeExternal(java.io.ObjectOutput)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||