org.apache.commons.betwixt.io.id
Class SequentialIDGenerator
java.lang.Object
|
+--org.apache.commons.betwixt.io.id.AbstractIDGenerator
|
+--org.apache.commons.betwixt.io.id.SequentialIDGenerator
- All Implemented Interfaces:
- IDGenerator
- public final class SequentialIDGenerator
- extends AbstractIDGenerator
Generates ID's in numeric sequence.
A simple counter is used.
Every time that nextIdImpl() is called,
this counter is incremented.
By default, the counter starts at zero.
A user can set the initial value by using the
SequentialIDGenerator(int start) constructor.
- Version:
- $Revision: 1.4 $
- Author:
- Robert Burrell Donkin
|
Method Summary |
int |
getCount()
Gets the current counter value |
java.lang.String |
nextIdImpl()
Increment counter and then return value. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SequentialIDGenerator
public SequentialIDGenerator()
- Base constructor.
Counter starts at zero.
SequentialIDGenerator
public SequentialIDGenerator(int start)
- Constructor sets the start value for the counter.
Note since the counter increments
before returning the next value,
first ID generated will be one more
than the given start parameter.
- Parameters:
start - start the counting at this value
nextIdImpl
public java.lang.String nextIdImpl()
- Increment counter and then return value.
- Overrides:
nextIdImpl in class AbstractIDGenerator
- Returns:
- one more than the current counter (converted to a string)
getCount
public int getCount()
- Gets the current counter value
- Returns:
- the last ID in the sequence
Copyright © 2002-2003 Apache Software Foundation. All Rights Reserved.