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

java.lang.Object
  extended by org.apache.commons.betwixt.io.id.AbstractIDGenerator
All Implemented Interfaces:
IDGenerator
Direct Known Subclasses:
RandomIDGenerator, SequentialIDGenerator

public abstract class AbstractIDGenerator
extends java.lang.Object
implements IDGenerator

Abstract superclass for IDGenerator implementations.

It implements the entire IDGenerator interface. When nextId is called, this class sets the LastId property (as well as returning the value). Subclasses should override nextIdImpl().

Version:
$Revision: 438373 $
Author:
Robert Burrell Donkin

Constructor Summary
AbstractIDGenerator()
           
 
Method Summary
 java.lang.String getLastId()
          Gets last ID returned.
 java.lang.String nextId()
          Generate next ID.
protected abstract  java.lang.String nextIdImpl()
          Subclasses should provide an implementation for this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractIDGenerator

public AbstractIDGenerator()
Method Detail

getLastId

public final java.lang.String getLastId()
Gets last ID returned.

Specified by:
getLastId in interface IDGenerator
Returns:
the last id created by the generated

nextId

public final java.lang.String nextId()

Generate next ID.

This method obtains the next ID from subclass and then uses this to set the LastId property.

Specified by:
nextId in interface IDGenerator
Returns:
the next id generated

nextIdImpl

protected abstract java.lang.String nextIdImpl()
Subclasses should provide an implementation for this method. This implementation needs only provide the next ID value (according to it's algorithm). Setting the LastId property can be left to this class.

Returns:
the next id generated


Copyright 2002-2008 The Apache Software Foundation. All Rights Reserved.