public class UUIDCreator extends Object
Modifier and Type | Method and Description |
---|---|
static UUID |
from128(byte[] data)
Create a UUID instance from 128-bit UUID data (little endian).
|
static UUID |
from128(byte[] data,
int offset)
Create a UUID instance from 128-bit UUID data (little endian).
|
static UUID |
from128(byte[] data,
int offset,
boolean littleEndian)
Create a UUID instance from 128-bit UUID data.
|
static UUID |
from16(byte[] data)
Create a UUID instance from 16-bit UUID data (little endian).
|
static UUID |
from16(byte[] data,
int offset)
Create a UUID instance from 16-bit UUID data (little endian).
|
static UUID |
from16(byte[] data,
int offset,
boolean littleEndian)
Create a UUID instance from 16-bit UUID data.
|
static UUID |
from32(byte[] data)
Create a UUID instance from 32-bit UUID data (little endian).
|
static UUID |
from32(byte[] data,
int offset)
Create a UUID instance from 32-bit UUID data (little endian).
|
static UUID |
from32(byte[] data,
int offset,
boolean littleEndian)
Create a UUID instance from 32-bit UUID data.
|
public static UUID from16(byte[] data)
This method is an alias of from16(data, 0)
.
data
- A byte array containing 16-bit UUID data.null
is returned when data
is null
or offset
is not valid.public static UUID from16(byte[] data, int offset)
This method is an alias of from16(data, offset, true)
.
data
- A byte array containing 16-bit UUID data.offset
- The offset from which 16-bit UUID data should be read.null
is returned when data
is null
or offset
is not valid.public static UUID from16(byte[] data, int offset, boolean littleEndian)
// Prepare a byte array containing 32-bit UUID data (little endian).
byte[] data = new byte[] { (byte)0xAB, (byte)0xCD };
// Create a UUID instance from the byte array.
UUID uuid = UUIDCreator.from16
(data, 0, true);
// uuid represents 0000cdab-0000-1000-8000-00805f9b34fb.
// Prepare a byte array containing 32-bit UUID data (big endian).
byte[] data = new byte[] { (byte)0xCD, (byte)0xAB };
// Create a UUID instance from the byte array.
UUID uuid = UUIDCreator.from16
(data, 0, false);
// uuid represents 0000cdab-0000-1000-8000-00805f9b34fb.
data
- A byte array containing 16-bit UUID data.offset
- The offset from which 16-bit UUID data should be read.littleEndian
- true
if the 16-bit UUID data is stored in little endian.
false
for big endian.null
is returned when data
is null
or offset
is not valid.public static UUID from32(byte[] data)
This method is an alias of from32(data, 0)
.
data
- A byte array containing 32-bit UUID data.null
is returned when data
is null
or offset
is not valid.public static UUID from32(byte[] data, int offset)
This method is an alias of from32(data, offset, true)
.
data
- A byte array containing 32-bit UUID data.offset
- The offset from which 32-bit UUID data should be read.null
is returned when data
is null
or offset
is not valid.public static UUID from32(byte[] data, int offset, boolean littleEndian)
// Prepare a byte array containing 32-bit UUID data (little endian).
byte[] data = new byte[] { (byte)0x89, (byte)0xAB, (byte)0xCD, (byte)0xEF };
// Create a UUID instance from the byte array.
UUID uuid = UUIDCreator.from32
(data, 0, true);
// uuid represents efcdab89-0000-1000-8000-00805f9b34fb.
// Prepare a byte array containing 32-bit UUID data (big endian).
byte[] data = new byte[] { (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x89 };
// Create a UUID instance from the byte array.
UUID uuid = UUIDCreator.from32
(data, 0, false);
// uuid represents efcdab89-0000-1000-8000-00805f9b34fb.
data
- A byte array containing 32-bit UUID data.offset
- The offset from which 32-bit UUID data should be read.littleEndian
- true
if the 32-bit UUID data is stored in little endian.
false
for big endian.null
is returned when data
is null
or offset
is not valid.public static UUID from128(byte[] data)
This method is an alias of from128(data, 0)
.
data
- A byte array containing 128-bit UUID data.null
is returned when data
is null
or offset
is not valid.public static UUID from128(byte[] data, int offset)
This method is an alias of from128(data, 0, true)
.
data
- A byte array containing 128-bit UUID data.null
is returned when data
is null
or offset
is not valid.public static UUID from128(byte[] data, int offset, boolean littleEndian)
// Prepare a byte array containing 128-bit UUID data (little endian).
byte[] data = new byte[] {
(byte)0x10, (byte)0x32, (byte)0x54, (byte)0x76,
(byte)0x98, (byte)0xBA, (byte)0xDC, (byte)0xFE,
(byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x89,
(byte)0x67, (byte)0x45, (byte)0x23, (byte)0x01 };
// Create a UUID instance from the byte array.
UUID uuid = UUIDCreator.from128
(data, 0, true);
// uuid represents 01234567-89ab-cdef-fedc-ba9876543210.
// Prepare a byte array containing 128-bit UUID data (big endian).
byte[] data = new byte[] {
(byte)0x01, (byte)0x23, (byte)0x45, (byte)0x67,
(byte)0x89, (byte)0xAB, (byte)0xCD, (byte)0xEF,
(byte)0xFE, (byte)0xDC, (byte)0xBA, (byte)0x98,
(byte)0x76, (byte)0x54, (byte)0x32, (byte)0x10 };
// Create a UUID instance from the byte array.
UUID uuid = UUIDCreator.from128
(data, 0, false);
// uuid represents 01234567-89ab-cdef-fedc-ba9876543210.
data
- A byte array containing 128-bit UUID data.offset
- The offset from which 128-bit UUID data should be read.null
is returned when data
is null
or offset
is not valid.Copyright © 2016. All rights reserved.