public final class CmsUUID extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<CmsUUID>
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.
构造器和说明 |
---|
CmsUUID()
Creates a new UUID.
|
CmsUUID(byte[] data)
Create a UUID based on a binary data array.
|
CmsUUID(java.lang.String uuid)
Create a UUID based on a String.
|
限定符和类型 | 方法和说明 |
---|---|
static void |
checkId(CmsUUID id,
boolean canBeNull)
Check that the given id is not the null id.
|
java.lang.Object |
clone()
Creates a clone of this CmsUUID.
|
int |
compareTo(CmsUUID obj) |
boolean |
equals(java.lang.Object obj) |
static CmsUUID |
getConstantUUID(java.lang.String name)
Returns a constant (name based) UUID,
based on the given name in the OpenCms name space.
|
static java.lang.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.
|
java.lang.String |
getStringValue()
Returns the String representation of this UUID, same as
toString() . |
int |
hashCode()
Optimized hashCode implementation for UUID's.
|
static void |
init(java.lang.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(java.lang.String uuid)
Returns
true if the given UUID is valid. |
byte[] |
toByteArray()
Returns the UUID as a 16-byte byte array.
|
java.lang.String |
toString() |
static CmsUUID |
valueOf(java.lang.String uuid)
Returns the given String transformed to a UUID in case the String is a valid UUID.
|
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 UUIDpublic CmsUUID(java.lang.String uuid) throws java.lang.NumberFormatException
uuid
- a String representing a UUIDjava.lang.NumberFormatException
- in case uuid is not a valid UUIDpublic static void checkId(CmsUUID id, boolean canBeNull)
id
- the id to checkcanBeNull
- only if flag is set, null
is acceptedisNullUUID()
public static CmsUUID getConstantUUID(java.lang.String name)
name
- the name to derive the uuid frompublic static java.lang.String getDummyEthernetAddress()
public static CmsUUID getNullUUID()
public static CmsUUID getOpenCmsUUID()
public static void init(java.lang.String ethernetAddress) throws java.lang.IllegalStateException
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 machinejava.lang.IllegalStateException
- in case the ethernetAddress String is not a valid ethernet addresspublic static boolean isValidUUID(java.lang.String uuid)
true
if the given UUID is valid.uuid
- the UUID to checktrue
if the given UUID is validpublic static CmsUUID valueOf(java.lang.String uuid) throws java.lang.NumberFormatException
uuid
- the String to transform to a UUIDjava.lang.NumberFormatException
- in case the String is no valid UUIDpublic java.lang.Object clone()
clone
在类中 java.lang.Object
public int compareTo(CmsUUID obj)
compareTo
在接口中 java.lang.Comparable<CmsUUID>
Comparable.compareTo(Object)
public boolean equals(java.lang.Object obj)
equals
在类中 java.lang.Object
Object.equals(java.lang.Object)
public java.lang.String getStringValue()
toString()
.This method is useful if bean like access to the UUID String is required.
public int hashCode()
hashCode
在类中 java.lang.Object
Object.hashCode()
public boolean isNullUUID()
public byte[] toByteArray()
public java.lang.String toString()
toString
在类中 java.lang.Object
Object.toString()