eaLib API Docs
Last Modified : January 7 2002

mss.ea.core
Class UniqueID

java.lang.Object
  |
  +--mss.ea.core.UniqueID

public class UniqueID
extends java.lang.Object

Class for generating unique identifiers. As identifier there can be either long integers or strings. Every request for an ID will increment an internal counter, so there is no way for getting an ID twice.

Since:
0.1
Version:
0.1 (01-19-2001)
Author:
Andreas Rummler

Field Summary
protected static long longID
          Internal long ID.
protected static long rangeCounter
          Counter for calculations in randomLong().
protected static long rangeExponent
          Exponent for range calculation in randomLong().
protected static java.lang.StringBuffer stringID
          Internal string ID.
 
Constructor Summary
UniqueID()
           
 
Method Summary
protected static void decrementString()
          Decrements a string.
static long getLong()
          Gets a new long ID.
static long getLongID()
          Deprecated. replaced by getLong()
static java.lang.Long getLongIntegerID()
          Deprecated. use new Integer( UniqueID.getLong() ) instead
static java.lang.String getString()
          Gets a new string ID.
static java.lang.String getStringID()
          Deprecated. replaced by getString()
protected static void incrementString()
          Increments a string.
protected static long pow10(long exp)
          Raises the exponent to the power of ten.
static long randomLong()
          Gets a random long ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

longID

protected static long longID
Internal long ID.

stringID

protected static java.lang.StringBuffer stringID
Internal string ID.

rangeExponent

protected static long rangeExponent
Exponent for range calculation in randomLong().

rangeCounter

protected static long rangeCounter
Counter for calculations in randomLong().
Constructor Detail

UniqueID

public UniqueID()
Method Detail

getLongID

public static long getLongID()
Deprecated. replaced by getLong()

Gets a new long ID.
Returns:
new ID

getLong

public static long getLong()
Gets a new long ID.
Returns:
new ID

getLongIntegerID

public static java.lang.Long getLongIntegerID()
Deprecated. use new Integer( UniqueID.getLong() ) instead

Gets a new long ID object.
Returns:
new ID object

randomLong

public static long randomLong()
Gets a random long ID. This method calculates an ID which could be unique. Called in a sequence it returns 1 ID from 1 to 9, 10 IDs from 10 to 99, 100 IDs from 100 to 999 and so on. So the propability to find an useful ID within a short time is rather high.
Returns:
new ID

pow10

protected static long pow10(long exp)
Raises the exponent to the power of ten. This is a little helper for calculating a random ID.
Parameters:
exp - exponent
Returns:
exponent raised to the power of ten

getStringID

public static java.lang.String getStringID()
Deprecated. replaced by getString()

Gets a new string ID.
Returns:
new string ID

getString

public static java.lang.String getString()
Gets a new string ID.
Returns:
new string ID

decrementString

protected static void decrementString()
Decrements a string. Decrementing a string means subtracting 1 on a character. Example: dec( k ) = j, dec( aa ) = z, and so on.

incrementString

protected static void incrementString()
Increments a string. Incrementing a string means adding 1 to a character. Example: inc( k ) = l, inc( z ) = aa, and so on.

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS