be.ac.ulg.montefiore.run.totem.util
Class IdGenerator

java.lang.Object
  extended by be.ac.ulg.montefiore.run.totem.util.IdGenerator

public class IdGenerator
extends java.lang.Object

IdGenerator is a singleton used to generate unique id. It uses the java.util.Random random number generator.

Creation date: 02-Feb-2005 11:05:40

Author:
Fabian Skivee (skivee@run.montefiore.ulg.ac.be)

Method Summary
 int generateIntId()
          Return a int Id uniformely distributed between 0 and Integer.MAX_VALUE
 int generateIntId(int n)
          Return a int Id uniformely distributed between 0 and n (exclusive)
 java.lang.String generateStringId(java.lang.String prefix)
          Return a String id composed by the prefix given and a random number between 0 and Integer.MAX_VALUE
static IdGenerator getInstance()
          Get IdGenerator unique instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static IdGenerator getInstance()
Get IdGenerator unique instance

Returns:

generateIntId

public int generateIntId()
Return a int Id uniformely distributed between 0 and Integer.MAX_VALUE

Returns:

generateIntId

public int generateIntId(int n)
Return a int Id uniformely distributed between 0 and n (exclusive)

Parameters:
n - : max int Id
Returns:

generateStringId

public java.lang.String generateStringId(java.lang.String prefix)
Return a String id composed by the prefix given and a random number between 0 and Integer.MAX_VALUE

Returns:
String id


Copyright © 2004-2007 Research Unit in Networking, All Rights Reserved.