com.xerox.amazonws.sdb
Class Counter

java.lang.Object
  extended by com.xerox.amazonws.sdb.Counter

public class Counter
extends Object

This class implements a thread-safe, persistent counter, backed by SimpleDB.

Author:
D. Kavanagh

Constructor Summary
Counter(Domain domain, String counterName)
          Constructs a counter, where a value may already be stored.
Counter(Domain domain, String counterName, long initValue)
          Constructs a counter with a specified initial value
 
Method Summary
 String getName()
          This method returns the counter name
 long nextValue()
          This method returns the next value, period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Counter

public Counter(Domain domain,
               String counterName)
        throws SDBException
Constructs a counter, where a value may already be stored. If no value is assigned, the counter is initialized to zero (the first counter value will be 1).

Parameters:
domain - the domain to use for the counter
counterName - the name of this counter, must be unique within this domain
Throws:
SDBException - wraps checked exceptions

Counter

public Counter(Domain domain,
               String counterName,
               long initValue)
        throws SDBException
Constructs a counter with a specified initial value

Parameters:
domain - the domain to use for the counter
counterName - the name of this counter, must be unique within this domain
initValue - the initial value for the counter
Throws:
SDBException - wraps checked exceptions
Method Detail

getName

public String getName()
This method returns the counter name

Returns:
the name of the counter

nextValue

public long nextValue()
               throws SDBException
This method returns the next value, period.

Returns:
the next counter value
Throws:
SDBException