org.apache.commons.betwixt.io.id
Class SequentialIDGenerator

java.lang.Object
  extended by org.apache.commons.betwixt.io.id.AbstractIDGenerator
      extended by 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: 438373 $
Author:
Robert Burrell Donkin

Constructor Summary
SequentialIDGenerator()
          Base constructor.
SequentialIDGenerator(int start)
          Constructor sets the start value for the counter.
 
Method Summary
 int getCount()
          Gets the current counter value
 java.lang.String nextIdImpl()
          Increment counter and then return value.
 
Methods inherited from class org.apache.commons.betwixt.io.id.AbstractIDGenerator
getLastId, nextId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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
Method Detail

nextIdImpl

public java.lang.String nextIdImpl()
Increment counter and then return value.

Specified by:
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-2008 The Apache Software Foundation. All Rights Reserved.