org.apache.turbine.util.db
Class UUIdGenerator
java.lang.Object
|
+--org.apache.turbine.util.db.UUIdGenerator
- public class UUIdGenerator
- extends java.lang.Object
This class generates universally unique id's in the form of a String.
The id has three parts. The first is supposed to be location dependent.
The preferred location parameter is an ethernet (MAC) address, but an IP
can be used as well. if none is supplied a Math.random generated number
will be used. This part of the key will be 48 bits in length.
The second part of the key is time related and will be the lower 48 bits
of the long used to signify the time since Jan. 1, 1970. This will
cause key rollover in the year 6429.
The preceding 12 bytes are Base64 encoded with the characters / and *
replaced by _ (underscore) and - (dash). Resulting in 16 characters.
Finally a counter is used to hand out 4095 keys in between each
timestamp.
The resulting id is a String of 18 characters including:
a-z,A-Z,0-9, and the previously mentioned - and _.
Note this class does not save any state information, so it is important
that time only moves forward to keep the integrity of the ids. We
might want to consider saving some state info.
To specify the MAC/Ethernet address, add a uuid.address= property to the
TurbineResources.properties file.
- Version:
- $Id: UUIdGenerator.java,v 1.4 2002/07/11 16:53:21 mpoeschl Exp $
- Author:
- John D. McNally
Method Summary |
java.lang.String |
getId()
Gets the id |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UUIdGenerator
public UUIdGenerator()
throws TurbineException
- Constructor
getId
public java.lang.String getId()
throws java.lang.Exception
- Gets the id
- Returns:
- the 18 character id
Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.