org.apache.commons.id.uuid.state
Class StateHelper

java.lang.Object
  extended by org.apache.commons.id.uuid.state.StateHelper
All Implemented Interfaces:
Constants

public final class StateHelper
extends java.lang.Object
implements Constants

StateHelper provides helper methods for the uuid state implementations.

Version:
$Id: StateHelper.java 480488 2006-11-29 08:57:26Z bayard $
Author:
Commons-Id team

Field Summary
static short BYTES_IN_SHORT
          Number of bytes in a short.
static short HOSTNAME_MAX_CHAR_LEN
          Number of postitions to shift when shifting by one byte.
static int NODE_ID_BYTE_LENGTH
          Array length of node bytes.
static short SHIFT_BY_BYTE
          Number of postitions to shift when shifting by one byte.
static java.lang.String UUID_CLOCK_IMPL_PROPERTY_KEY
          The key for the System.property containing the ClockImpl String.
static java.lang.String UUID_STATE_IMPL_PROPERTY_KEY
          The key for the System.property containing the StateImpl String.
protected static java.lang.String XML_DOC_END
          End of the XML document used to store state persistence in XML
protected static java.lang.String XML_DOC_START
          Start of the XML document used to store state persistence in XML
protected static java.lang.String XML_DOC_START_END
          End of document start
protected static java.lang.String XML_NODE_TAG_AFTER_CSEQ
          After clock sequence of XML node tag
protected static java.lang.String XML_NODE_TAG_AFTER_ID
          After id of XML node tag
protected static java.lang.String XML_NODE_TAG_END
          End of XML node tag
protected static java.lang.String XML_NODE_TAG_START
          Start of XML node tag
 
Fields inherited from interface org.apache.commons.id.uuid.Constants
CLOCK_SEQ_HI_AND_RESERVED_BYTE_8, FORMAT_POSITION1, FORMAT_POSITION2, FORMAT_POSITION3, FORMAT_POSITION4, MD5_ENCODING, SHA1_ENCODING, TIME_HI_AND_VERSION_BYTE_6, TIME_HI_BYTE_LEN, TIME_HI_START_POS, TIME_HI_TS_POS, TIME_LOW_BYTE_LEN, TIME_LOW_START_POS, TIME_LOW_TS_POS, TIME_MID_BYTE_LEN, TIME_MID_START_POS, TIME_MID_TS_POS, TOKEN_LENGTHS, TOKENS_IN_UUID, URN_PREFIX, UUID_BIT_LENGTH, UUID_BYTE_LENGTH, UUID_FORMATTED_LENGTH, UUID_UNFORMATTED_LENGTH, VARIANT_FUTURE, VARIANT_IETF_DRAFT, VARIANT_MS, VARIANT_NCS_COMPAT, VERSION_FIVE, VERSION_FOUR, VERSION_ONE, VERSION_THREE, VERSION_TWO, WRONG_VAR_VER_MSG
 
Method Summary
static byte[] decodeMACAddress(java.lang.String address)
          Utility method decodes a valid MAC address in the form of XX-XX-XX-XX-XX-XX where each XX represents a hexidecimal value.
static java.lang.String encodeMACAddress(byte[] address)
          Returns the node id / address byte array in it's hexidecimal string representation in the following format: XX-XX-XX-XX-XX-XX where each XX represents a hexidecimal value.
static Clock getClockImpl()
          Returns the Clock implementation using commons discovery.
static State getStateImpl()
          Returns the State implementation in use.
static short newClockSequence()
          Generates a new security quality random clock sequence.
static byte[] randomNodeIdentifier()
          Creates a Random node identifier as described in IEFT UUID URN specification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UUID_CLOCK_IMPL_PROPERTY_KEY

public static final java.lang.String UUID_CLOCK_IMPL_PROPERTY_KEY
The key for the System.property containing the ClockImpl String.


UUID_STATE_IMPL_PROPERTY_KEY

public static final java.lang.String UUID_STATE_IMPL_PROPERTY_KEY
The key for the System.property containing the StateImpl String.


NODE_ID_BYTE_LENGTH

public static final int NODE_ID_BYTE_LENGTH
Array length of node bytes.

See Also:
Constant Field Values

BYTES_IN_SHORT

public static final short BYTES_IN_SHORT
Number of bytes in a short.

See Also:
Constant Field Values

SHIFT_BY_BYTE

public static final short SHIFT_BY_BYTE
Number of postitions to shift when shifting by one byte.

See Also:
Constant Field Values

HOSTNAME_MAX_CHAR_LEN

public static final short HOSTNAME_MAX_CHAR_LEN
Number of postitions to shift when shifting by one byte.

See Also:
Constant Field Values

XML_DOC_START

protected static final java.lang.String XML_DOC_START
Start of the XML document used to store state persistence in XML

See Also:
Constant Field Values

XML_DOC_START_END

protected static final java.lang.String XML_DOC_START_END
End of document start

See Also:
Constant Field Values

XML_NODE_TAG_START

protected static final java.lang.String XML_NODE_TAG_START
Start of XML node tag

See Also:
Constant Field Values

XML_NODE_TAG_AFTER_ID

protected static final java.lang.String XML_NODE_TAG_AFTER_ID
After id of XML node tag

See Also:
Constant Field Values

XML_NODE_TAG_AFTER_CSEQ

protected static final java.lang.String XML_NODE_TAG_AFTER_CSEQ
After clock sequence of XML node tag

See Also:
Constant Field Values

XML_NODE_TAG_END

protected static final java.lang.String XML_NODE_TAG_END
End of XML node tag

See Also:
Constant Field Values

XML_DOC_END

protected static final java.lang.String XML_DOC_END
End of the XML document used to store state persistence in XML

See Also:
Constant Field Values
Method Detail

randomNodeIdentifier

public static byte[] randomNodeIdentifier()

Creates a Random node identifier as described in IEFT UUID URN specification.

Returns:
a random node idenfifier based on MD5 of system information.

newClockSequence

public static short newClockSequence()

Generates a new security quality random clock sequence.

Returns:
a new security quality random clock sequence.

getClockImpl

public static Clock getClockImpl()

Returns the Clock implementation using commons discovery.

Returns:
the Clock implementation using commons discovery.

getStateImpl

public static State getStateImpl()

Returns the State implementation in use.

Returns:
the State implementation in use.

decodeMACAddress

public static byte[] decodeMACAddress(java.lang.String address)

Utility method decodes a valid MAC address in the form of XX-XX-XX-XX-XX-XX where each XX represents a hexidecimal value.

Returns null if the address can not be decoded.

Parameters:
address - the String hexidecimal dash separated MAC address.
Returns:
a byte array representing the the address. Null if not a valid address.

encodeMACAddress

public static java.lang.String encodeMACAddress(byte[] address)
                                         throws java.io.IOException

Returns the node id / address byte array in it's hexidecimal string representation in the following format: XX-XX-XX-XX-XX-XX where each XX represents a hexidecimal value.

Parameters:
address - the 6 byte node id / address.
Returns:
the node id /address byte array in as hexidecimal with dash separating each octet.
Throws:
java.io.IOException - an Input Output Exception.


Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.