com.pow2.dao
Class IdGenerator

java.lang.Object
  extended bycom.pow2.dao.AbstractDAO
      extended bycom.pow2.dao.IdGenerator

public class IdGenerator
extends AbstractDAO

IdGenerator class.
Use the HIGH/LOW approach to generate an uinque Id.
This method uses the app_identifier database table

field name field type is key ?
id integer not null y
high integer n


Initialize the unique table record with this SQL statement:
INSERT INTO "app_identifier" VALUES (0,1);

Author:
Luca Fossato

Field Summary
static int LOW_MAXVALUE
          low max value
 
Fields inherited from class com.pow2.dao.AbstractDAO
cat
 
Constructor Summary
protected IdGenerator()
          Protected default constructor.
 
Method Summary
 long getHigh()
          Gets the high attribute of the IdGenerator object
 long getId()
          Get a new unique identifier number.
 int getLow()
          Gets the low attribute of the IdGenerator object
static IdGenerator instance()
          Get the instance of the IdGenerator class.
 void setHigh(long high)
          Sets the high attribute of the IdGenerator object
 void setLow(int low)
          Sets the low attribute of the IdGenerator object
 
Methods inherited from class com.pow2.dao.AbstractDAO
assertion, closeResources, closeResources, closeResources, count, count, delete, delete, encode, getConnection, getConnection, getNewKey, isDebugEnabled, populate, setLike, setLike
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOW_MAXVALUE

public static final int LOW_MAXVALUE
low max value

See Also:
Constant Field Values
Constructor Detail

IdGenerator

protected IdGenerator()
Protected default constructor.
Initialize the high and low values.

Method Detail

instance

public static IdGenerator instance()
Get the instance of the IdGenerator class.

Returns:
the instance of the IdGenerator class

setLow

public void setLow(int low)
Sets the low attribute of the IdGenerator object

Parameters:
low - The new low value

getLow

public int getLow()
Gets the low attribute of the IdGenerator object

Returns:
The low value

setHigh

public void setHigh(long high)
Sets the high attribute of the IdGenerator object

Parameters:
high - The new high value

getHigh

public long getHigh()
Gets the high attribute of the IdGenerator object

Returns:
The high value

getId

public long getId()
           throws Exception
Get a new unique identifier number.

Returns:
a new unique identifier number
Throws:
Exception - Description of the Exception


Copyright © 2002-2004 Power Of Two S.R.L. All Rights Reserved.