com.boylesoftware.cb2.util
Class UniqueIdGenerator

java.lang.Object
  extended bycom.boylesoftware.cb2.util.UniqueIdGenerator

public class UniqueIdGenerator
extends java.lang.Object

Generates sequence of unique ids, which can be used, for example, as session ids.

This implementation is thread-safe.

Version:
$Id: UniqueIdGenerator.java,v 1.1 2003/05/06 14:17:05 levahim Exp $
Author:
Lev Himmelfarb

Field Summary
protected  java.security.MessageDigest digest
          Digest used to postprocess new ids.
protected  int nBytes
          Number of bytes in the generated ids.
protected  java.util.Random random
          Random number generator.
 
Constructor Summary
UniqueIdGenerator()
          Constructs and initializes a new generator for 16 bytes in the generated ids.
UniqueIdGenerator(int nBytes)
          Constructs and initializes a new generator.
 
Method Summary
 java.lang.String next()
          Generates next id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nBytes

protected final int nBytes
Number of bytes in the generated ids.


random

protected final java.util.Random random
Random number generator.


digest

protected final java.security.MessageDigest digest
Digest used to postprocess new ids.

Constructor Detail

UniqueIdGenerator

public UniqueIdGenerator(int nBytes)
Constructs and initializes a new generator.

Parameters:
nBytes - number of bytes in the ids.

UniqueIdGenerator

public UniqueIdGenerator()
Constructs and initializes a new generator for 16 bytes in the generated ids.

Method Detail

next

public java.lang.String next()
Generates next id.

Returns:
the id.


Copyright © 2002,2003,2004 - Boyle Software, Inc.