org.openbp.common.util
Class CheckedIdGenerator

java.lang.Object
  extended by org.openbp.common.util.CheckedIdGenerator

public class CheckedIdGenerator
extends java.lang.Object

This IDGenerator returns an ID unique across all Java virtual machines with a very high probability. The id is based on java.util.UUID (type 4 of http://www.ietf.org/rfc/rfc4122.txt) plus an appended checksum.
Note: jakarta commons id could be used to create other UID types of RFC 4122.

This class is a singleton. The methods of this class are thread-safe.

Author:
Dr. Achim Leubner

Method Summary
static boolean checksumOk(java.lang.String id)
          Returns true, if the checksum of this id is ok.
static byte getEmbeddedIdChecksum(java.lang.String id)
          Returns the checksum embedded in the id.
 java.lang.String getID()
          Returns a new ID (type 4 of http://www.ietf.org/rfc/rfc4122.txt with an additional checksum).
static CheckedIdGenerator getInstance()
          Gets the singleton instance of this class.
static int getMaxLength()
          Gets the maximum length of this type of id.
static byte getNewIdChecksum(java.lang.String ids)
          Returns the (newly calculated) checksum of the given id.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static CheckedIdGenerator getInstance()
Gets the singleton instance of this class.


getID

public java.lang.String getID()
Returns a new ID (type 4 of http://www.ietf.org/rfc/rfc4122.txt with an additional checksum).

Examples:

Returns:
The new id (36 + 1 byte '-' + 2 bytes check sum)

getMaxLength

public static final int getMaxLength()
Gets the maximum length of this type of id.

Returns:
The maximum length

checksumOk

public static boolean checksumOk(java.lang.String id)
Returns true, if the checksum of this id is ok.

Parameters:
id - Id to check
Returns:
true if the checksum of this id is ok

getEmbeddedIdChecksum

public static byte getEmbeddedIdChecksum(java.lang.String id)
Returns the checksum embedded in the id.

Parameters:
id - It to check
Returns:
The checksum

getNewIdChecksum

public static byte getNewIdChecksum(java.lang.String ids)
Returns the (newly calculated) checksum of the given id.

Parameters:
ids - UUID w/o checksum as string
Returns:
The checksum

main

public static void main(java.lang.String[] args)


Copyright © 2011. All Rights Reserved.