Package com.tangosol.util
Class UUID
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.UUID
- All Implemented Interfaces:
- ExternalizableLite,- PortableObject,- Externalizable,- Serializable,- Comparable
public final class UUID
extends Base
implements Comparable, Externalizable, ExternalizableLite, PortableObject
A UUID is a 256-bit identifier that, if it is generated, is statistically
 guaranteed to be unique.
- Author:
- cp 2004.06.24
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class com.tangosol.util.BaseBase.LoggingWriter
- 
Field Summary
- 
Constructor SummaryConstructorsConstructorDescriptionUUID()Generate a UUID.UUID(byte[] ab) Construct a UUID from a byte array.UUID(long lDatetime, byte[] abIP, int nPort, int nCount) Build a UUID from its constituent members (advanced constructor).UUID(long lDatetime, InetAddress addr, int nPort, int nCount) Build a UUID from its constituent members (advanced constructor).Construct a UUID from a stream.Construct a UUID from a String.
- 
Method SummaryModifier and TypeMethodDescriptionintCompares this object with the specified object for order.booleanDetermine if two UUIDs are equal.byte[]Determine the internet address of the host that generated the UUID instance.intgetCount()Determine the "counter" portion of the UUID that ensures that two UUIDs generated at the same exact time by the same process are unique.intgetPort()Determine the port portion of the UUID.longDetermine the date/time value that the UUID instance was generated.inthashCode()Determine a hash code for the UUID object.booleanThis is true if the IP address is a real IP address.booleanThis is true if the UUID was generated, and false if it was built.static voidAllow UUID identifiers to be generated or parsed at the command line.voidRestore the contents of a user type instance by reading its state using the specified PofReader object.voidRestore the contents of this object by loading the object's state from the passed DataInput object.voidRead this object from an ObjectInputStream.byte[]Convert the UUID to a byte array of 32 bytes.toString()Convert the UUID to a printable String.voidwriteExternal(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.voidwriteExternal(DataOutput out) Save the contents of this object by storing the object's state into the passed DataOutput object.voidWrite this object to an ObjectOutputStream.Methods inherited from class com.tangosol.util.Baseazzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
- 
Constructor Details- 
UUIDpublic UUID()Generate a UUID.
- 
UUIDBuild a UUID from its constituent members (advanced constructor).It is guaranteed that a generated UUID will never equal a built UUID. - Parameters:
- lDatetime- the creation date/time millis portion of the UUID
- addr- the InetAddress portion of the UUID
- nPort- the port number portion of the UUID; a port number is 16 bits, but up to 28 bits of data from this value will be maintained by the UUID
- nCount- the counter portion of the UUID
 
- 
UUIDpublic UUID(long lDatetime, byte[] abIP, int nPort, int nCount) Build a UUID from its constituent members (advanced constructor).It is guaranteed that a generated UUID will never equal a built UUID. - Parameters:
- lDatetime- the creation date/time millis portion of the UUID
- abIP- the InetAddress portion of the UUID
- nPort- the port number portion of the UUID; a port number is 16 bits, but up to 28 bits of data from this value will be maintained by the UUID
- nCount- the counter portion of the UUID
 
- 
UUIDConstruct a UUID from a String.- Parameters:
- s- a String as would be returned from UUID.toString()
 
- 
UUIDpublic UUID(byte[] ab) Construct a UUID from a byte array.- Parameters:
- ab- a byte array as would be returned from UUID.toByteArray()
 
- 
UUIDConstruct a UUID from a stream.This is a helper constructor that is just a shorthand for a sequence: UUID uid = new UUID(); uid.readExternal(stream); - Parameters:
- stream- an object implementing java.io.DataInput that contains the internal information that a previous UID wrote
- Throws:
- IOException- if an error occurs reading from the stream
 
 
- 
- 
Method Details- 
mainAllow UUID identifiers to be generated or parsed at the command line. For example, to generate 10 identifiers: java com.tangosol.util.UUID 10
- 
isGeneratedpublic boolean isGenerated()This is true if the UUID was generated, and false if it was built. A generated UUID is universally unique. Note that the port number is random if the UUID is generated.- Returns:
- true if the UUID was generated
 
- 
getTimestamppublic long getTimestamp()Determine the date/time value that the UUID instance was generated.- Returns:
- date/time value in millis that the UUID instance was generated
 
- 
isAddressIncludedpublic boolean isAddressIncluded()This is true if the IP address is a real IP address. This is only false if two conditions are met: The UUID is generated, and it could not get an IP address (or one that is not a loopback/localhost address) from the VM.- Returns:
- true if the UUID has IP address information
 
- 
getAddresspublic byte[] getAddress()Determine the internet address of the host that generated the UUID instance.- Returns:
- an array of bytes containing the IP address information; the array can be zero bytes (no address,) four bytes (IPv4) or 16 bytes (IPv6)
 
- 
getPortpublic int getPort()Determine the port portion of the UUID. Note that the port is a 28-bit value; the first nibble is always 0x0.- Returns:
- the port portion of the UID
 
- 
getCountpublic int getCount()Determine the "counter" portion of the UUID that ensures that two UUIDs generated at the same exact time by the same process are unique.- Returns:
- a number that helps to make the UUID unique
 
- 
toByteArraypublic byte[] toByteArray()Convert the UUID to a byte array of 32 bytes.- Returns:
- the UUID data as a byte array of 32 bytes
 
- 
toStringConvert the UUID to a printable String.
- 
equalsDetermine if two UUIDs are equal.
- 
compareToCompares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
- compareToin interface- Comparable
- Parameters:
- o- the Object to be compared.
- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
- Throws:
- ClassCastException- if the specified object's type prevents it from being compared to this Object
 
- 
hashCodepublic int hashCode()Determine a hash code for the UUID object.
- 
readExternalRead this object from an ObjectInputStream.- Specified by:
- readExternalin interface- Externalizable
- Parameters:
- in- the ObjectInputStream to read this object from
- Throws:
- IOException- if an exception occurs reading this object
 
- 
writeExternalWrite this object to an ObjectOutputStream.- Specified by:
- writeExternalin interface- Externalizable
- Parameters:
- out- the ObjectOutputStream to write this object to
- Throws:
- IOException- thrown if an exception occurs writing this object
 
- 
readExternalRestore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
- readExternalin interface- ExternalizableLite
- Parameters:
- in- the DataInput stream to read data from in order to restore the state of this object
- Throws:
- IOException- if an I/O exception occurs
 
- 
writeExternalSave the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
- writeExternalin interface- ExternalizableLite
- Parameters:
- out- the DataOutput stream to write the state of this object to
- Throws:
- IOException- if an I/O exception occurs
 
- 
readExternalRestore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
- readExternalin interface- PortableObject
- Parameters:
- in- the PofReader from which to read the object's state
- Throws:
- IOException- if an I/O error occurs
 
- 
writeExternalSave the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
- writeExternalin interface- PortableObject
- Parameters:
- out- the PofWriter to which to write the object's state
- Throws:
- IOException- if an I/O error occurs
 
 
-