public class UUIDBasedOID
extends java.lang.Object
A class for creating and convertin UUID based OIDs.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
oid |
protected static java.lang.String |
OID_PREFIX |
protected static java.lang.String |
OID_PREFIX_REMOVAL_REGEX |
protected java.util.UUID |
uuid |
Constructor and Description |
---|
UUIDBasedOID()
Construct a new OID with a new random UUID.
|
UUIDBasedOID(java.lang.String oid)
Construct an OID from an existing string representation of an OID.
|
UUIDBasedOID(java.util.UUID nameSpace,
byte[] bName)
Construct a new OID with a Type 3 UUID (that is based on an MD5 hash of the supplied byte arrayss).
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
createOIDFromUUIDCanonicalHexString(java.lang.String hexString)
Create an OID from the canonical hex string form of a UUID.
|
static byte[] |
getByteArrayInNetworkByteOrderFromUUID(java.util.UUID uuid) |
java.lang.String |
getOID()
Get the string representation of the OID.
|
java.util.UUID |
getUUID()
Get the UUID of the OID.
|
static void |
main(java.lang.String[] args)
Convert OIDs to UUIDs and UUIDs to OIDs or create a new one.
|
static java.math.BigInteger |
makeBigIntegerFromUnsignedLong(long unsignedLongValue)
Convert an unsigned value in a long to a BigInteger.
|
static java.util.UUID |
parseUUIDFromDecimalString(java.lang.String decimalString)
Extract the UUID from its single integer value decimal string representation.
|
static java.util.UUID |
parseUUIDFromOID(java.lang.String oid)
Extract the UUID from a UUID-based OID.
|
protected java.lang.String oid
protected static final java.lang.String OID_PREFIX
protected static final java.lang.String OID_PREFIX_REMOVAL_REGEX
protected java.util.UUID uuid
public UUIDBasedOID()
Construct a new OID with a new random UUID.
public UUIDBasedOID(java.lang.String oid) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException
Construct an OID from an existing string representation of an OID.
oid
- a String of dotted numeric values in OID form {joint-iso-itu-t uuid(25) <uuid-single-integer-value>}java.lang.IllegalArgumentException
java.lang.NumberFormatException
public UUIDBasedOID(java.util.UUID nameSpace, byte[] bName)
Construct a new OID with a Type 3 UUID (that is based on an MD5 hash of the supplied byte arrayss).
Given the same bytes as input, the same OID will be returned every time.
The name space represents the entity, an instance of which is being uniquely identified.
The name bytes might, for example, be a UTF-8 encoding of a String that contains a bunch of attribute values separated by some delimiter like a "|"
nameSpace
- a non-null UUID defining the name spacebName
- a non-null non-zero length array of bytes containing the "name" (any values)public static java.lang.String createOIDFromUUIDCanonicalHexString(java.lang.String hexString) throws java.lang.IllegalArgumentException
Create an OID from the canonical hex string form of a UUID.
hexString
- canonical hex string form of a UUIDjava.lang.IllegalArgumentException
- if name does not conform to the string representationpublic static byte[] getByteArrayInNetworkByteOrderFromUUID(java.util.UUID uuid)
public java.lang.String getOID()
Get the string representation of the OID.
public java.util.UUID getUUID()
Get the UUID of the OID.
public static void main(java.lang.String[] args)
Convert OIDs to UUIDs and UUIDs to OIDs or create a new one.
args
- a list of OIDs or UUIDs or empty if a new OID is to be createdpublic static java.math.BigInteger makeBigIntegerFromUnsignedLong(long unsignedLongValue)
Convert an unsigned value in a long to a BigInteger.
unsignedLongValue
- an unsigned long value (i.e., the sign bit is treated as part of the value rather than a sign)public static java.util.UUID parseUUIDFromDecimalString(java.lang.String decimalString) throws java.lang.NumberFormatException
Extract the UUID from its single integer value decimal string representation.
decimalString
- single integer value decimal string representationjava.lang.NumberFormatException
- if the OID does not contain a uuid-single-integer-valuepublic static java.util.UUID parseUUIDFromOID(java.lang.String oid) throws java.lang.IllegalArgumentException, java.lang.NumberFormatException
Extract the UUID from a UUID-based OID.
oid
- a String of dotted numeric values in OID form {joint-iso-itu-t uuid(25) <uuid-single-integer-value>}java.lang.IllegalArgumentException
- if the OID is not in the {joint-iso-itu-t uuid(25)} arcjava.lang.NumberFormatException
- if the OID does not contain a uuid-single-integer-value