com.amazon.carbonado.sequence
Class AbstractSequenceValueProducer

java.lang.Object
  extended by com.amazon.carbonado.sequence.AbstractSequenceValueProducer
All Implemented Interfaces:
SequenceValueProducer
Direct Known Subclasses:
SequenceValueGenerator

public abstract class AbstractSequenceValueProducer
extends Object
implements SequenceValueProducer

Since:
1.2
Author:
Brian S O'Neill

Constructor Summary
protected AbstractSequenceValueProducer()
           
 
Method Summary
 String nextDecimalValue()
          Returns the next decimal string value from the sequence, which remains positive.
 int nextIntValue()
          Returns the next value from the sequence, which may wrap negative if all positive values are exhausted.
 String nextNumericalValue(int radix, int minLength)
          Returns the next numerical string value from the sequence, which remains positive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.amazon.carbonado.sequence.SequenceValueProducer
nextLongValue, returnReservedValues
 

Constructor Detail

AbstractSequenceValueProducer

protected AbstractSequenceValueProducer()
Method Detail

nextIntValue

public int nextIntValue()
                 throws PersistException
Description copied from interface: SequenceValueProducer
Returns the next value from the sequence, which may wrap negative if all positive values are exhausted. When sequence wraps back to initial value, the sequence is fully exhausted, and an exception is thrown to indicate this.

Note: this method throws PersistException even for fetch failures since this method is called by insert operations. Insert operations can only throw a PersistException.

Specified by:
nextIntValue in interface SequenceValueProducer
Throws:
PersistException - for fetch/persist failure or if sequence is exhausted for int values.

nextDecimalValue

public String nextDecimalValue()
                        throws PersistException
Description copied from interface: SequenceValueProducer
Returns the next decimal string value from the sequence, which remains positive. When sequence wraps back to initial value, the sequence is fully exhausted, and an exception is thrown to indicate this.

Note: this method throws PersistException even for fetch failures since this method is called by insert operations. Insert operations can only throw a PersistException.

Specified by:
nextDecimalValue in interface SequenceValueProducer
Throws:
PersistException - for fetch/persist failure or if sequence is exhausted.

nextNumericalValue

public String nextNumericalValue(int radix,
                                 int minLength)
                          throws PersistException
Description copied from interface: SequenceValueProducer
Returns the next numerical string value from the sequence, which remains positive. When sequence wraps back to initial value, the sequence is fully exhausted, and an exception is thrown to indicate this.

Note: this method throws PersistException even for fetch failures since this method is called by insert operations. Insert operations can only throw a PersistException.

Specified by:
nextNumericalValue in interface SequenceValueProducer
Parameters:
radix - use 2 for binary, 10 for decimal, 16 for hex. Max is 36.
minLength - ensure string is at least this long (padded with zeros if necessary) to ensure proper string sort
Throws:
PersistException - for fetch/persist failure or if sequence is exhausted.


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.