com.notuvy.util
Class UniqueId
java.lang.Object
com.notuvy.util.UniqueId
public class UniqueId
- extends Object
System clock based unique ID generator. The ID is an 8-character
alphanumeric string.
Each time it is called, it will return a guaranteed different value.
Because it is system clock based, and because the result is uniformly
an 8-character string, the guarantee only applies over the time period
[01-Jan-2010, 25-May-2099].
After that period, the logic still works. There will be unique values
for the new epoch, but there is a potential reuse of values from the
prior epoch.
Note that sequential values almost always differ by multiple characters
(and often by ALL characters). Because of the encoding, it is not
apparent how far apart in time two different values were generated.
Note that the result is case-INsensitive. (This is meaningful really
only for the reverse computation of coded string to system time.)
- Author:
- murali
Field Summary |
protected static long |
BASE_VALUE
|
protected static org.apache.log4j.Logger |
LOG
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
protected static final org.apache.log4j.Logger LOG
BASE_VALUE
protected static final long BASE_VALUE
- See Also:
- Constant Field Values
UniqueId
public UniqueId()
next
public static String next()
scramble
protected static void scramble(char[] buffer)
unscramble
protected static void unscramble(char[] buffer)
toHash
protected static char[] toHash(long value)
fromHash
protected static long fromHash(char[] buffer)
toTime
public static long toTime(String pHash)
getLast
protected long getLast()
setLast
protected void setLast(long pLast)
nextHashArray
public char[] nextHashArray()
nextHash
public String nextHash()
main
public static void main(String[] args)
Copyright © 2013. All Rights Reserved.