Show / Hide Table of Contents

Class UUID

A UUID is a 256-bit identifier that, if it is generated, is statistically guaranteed to be unique.

Inheritance
object
UUID
Implements
IPortableObject
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: Tangosol.Util
Assembly: Coherence.dll
Syntax
[Serializable]
public sealed class UUID : IPortableObject

Constructors

UUID()

Generate a UUID.

Declaration
public UUID()

UUID(byte[])

Construct a UUID from a byte array.

Declaration
public UUID(byte[] array)
Parameters
Type Name Description
byte[] array

A byte array as would be returned from UUID.ToByteArray()

UUID(long, byte[], int, int)

Build a UUID from its constituent members (advanced constructor).

Declaration
public UUID(long datetime, byte[] ip, int port, int counter)
Parameters
Type Name Description
long datetime

The creation date/time millis portion of the UUID.

byte[] ip

The IPAddress portion of the UUID.

int port

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.

int counter

The counter portion of the UUID.

Remarks

It is guaranteed that a generated UUID will never equal a built UUID.

UUID(long, IPAddress, int, int)

Build a UUID from its constituent members (advanced constructor).

Declaration
public UUID(long datetime, IPAddress address, int port, int counter)
Parameters
Type Name Description
long datetime

The creation date/time millis portion of the UUID.

IPAddress address

The IPAddress portion of the UUID.

int port

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.

int counter

The counter portion of the UUID.

Remarks

It is guaranteed that a generated UUID will never equal a built UUID.

UUID(string)

Construct a UUID from a string.

Declaration
public UUID(string s)
Parameters
Type Name Description
string s

A string as would be returned from UUID.ToString()

Properties

Address

Determine the internet address of the host that generated the UUID instance.

Declaration
public byte[] Address { get; }
Property Value
Type Description
byte[]

An array of bytes containing the IP address information; the array can be zero bytes (no address,) four bytes (IPv4) or 16 bytes (IPv6).

Count

Determine the "counter" portion of the UUID that ensures that two UUIDs generated at the same exact time by the same process are unique.

Declaration
public int Count { get; }
Property Value
Type Description
int

A number that helps to make the UUID unique.

IsAddressIncluded

This is true if the IP address is a real IP address.

Declaration
public bool IsAddressIncluded { get; }
Property Value
Type Description
bool

true if the UUID has IP address information.

Remarks

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).

IsGenerated

This is true if the UUID was generated, and false if it was built.

Declaration
public bool IsGenerated { get; }
Property Value
Type Description
bool

true if the UUID was generated.

Remarks

A generated UUID is universally unique. Note that the port number is random if the UUID is generated.

Port

Determine the port portion of the UUID. Note that the port is a 28-bit value; the first nibble is always 0x0.

Declaration
public int Port { get; }
Property Value
Type Description
int

The port portion of the UID.

Timestamp

Determine the date/time value that the UUID instance was generated.

Declaration
public long Timestamp { get; }
Property Value
Type Description
long

Date/time value in millis that the UUID instance was generated.

Methods

CompareTo(object)

Compares this object with the specified object for order.

Declaration
public int CompareTo(object o)
Parameters
Type Name Description
object o

The Object to be compared.

Returns
Type Description
int

A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Remarks

Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Exceptions
Type Condition
InvalidCastException

If the specified object's type prevents it.

Equals(object)

Determine if two UUIDs are equal.

Declaration
public override bool Equals(object o)
Parameters
Type Name Description
object o

The other UUID.

Returns
Type Description
bool

true if the passed object is equal to this.

Overrides
object.Equals(object)

GetHashCode()

Determine a hash code for the UUID object.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code reflecting the UUID's data.

Overrides
object.GetHashCode()

ReadExternal(IPofReader)

Restore the contents of a user type instance by reading its state using the specified IPofReader object.

Declaration
public void ReadExternal(IPofReader reader)
Parameters
Type Name Description
IPofReader reader

The IPofReader from which to read the object's state.

Exceptions
Type Condition
IOException

If an I/O error occurs.

ToByteArray()

Convert the UUID to a byte array of 32 bytes.

Declaration
public byte[] ToByteArray()
Returns
Type Description
byte[]

The UUID data as a byte array of 32 bytes.

ToString()

Convert the UUID to a printable String.

Declaration
public override string ToString()
Returns
Type Description
string

The UUID data as a 0x-prefixed hex string.

Overrides
object.ToString()

WriteExternal(IPofWriter)

Save the contents of a POF user type instance by writing its state using the specified IPofWriter object.

Declaration
public void WriteExternal(IPofWriter writer)
Parameters
Type Name Description
IPofWriter writer

The IPofWriter to which to write the object's state.

Exceptions
Type Condition
IOException

If an I/O error occurs.

Implements

IPortableObject
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.