ie.omk.smpp.util
Class DefaultSequenceScheme

java.lang.Object
  extended by ie.omk.smpp.util.DefaultSequenceScheme
All Implemented Interfaces:
SequenceNumberScheme

public class DefaultSequenceScheme
extends Object
implements SequenceNumberScheme

The default sequence numbering scheme. This implementation starts at sequence number 1 and increments by 1 for each number requested, resulting in the sequence numbers 1..2..3..4..5..6..7..8..n. If the sequence number reaches as far as Integer.MAX_VALUE, it will wrap back around to 1.

Version:
1.0
Author:
Oran Kelly

Field Summary
 
Fields inherited from interface ie.omk.smpp.util.SequenceNumberScheme
PEEK_UNSUPPORTED
 
Constructor Summary
DefaultSequenceScheme()
           
DefaultSequenceScheme(int start)
          Construct a new DefaultSequenceScheme that starts the sequence from start.
 
Method Summary
 int nextNumber()
          Get the next number in this sequence's scheme.
 int peek()
          Get the next number in this sequence's scheme without causing it to move to the next-in-sequence.
 int peek(int nth)
          Get the nth next number in this sequence's scheme without causing it to move to the next-in-sequence.
 void reset()
          Reset the sequence scheme to the beginning of the sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSequenceScheme

public DefaultSequenceScheme()

DefaultSequenceScheme

public DefaultSequenceScheme(int start)
Construct a new DefaultSequenceScheme that starts the sequence from start.

Method Detail

nextNumber

public int nextNumber()
Description copied from interface: SequenceNumberScheme
Get the next number in this sequence's scheme. An implementation of this interface must guard against multi-threaded access to this method to prevent more than one thread getting the same sequence number.

Specified by:
nextNumber in interface SequenceNumberScheme

peek

public int peek()
Description copied from interface: SequenceNumberScheme
Get the next number in this sequence's scheme without causing it to move to the next-in-sequence. This method returns the number that will be returned by the next call to nextNumber without actually increasing the sequence. Multiple calls to peek will return the same number until a call to nextNumber is made.

Specified by:
peek in interface SequenceNumberScheme

peek

public int peek(int nth)
Description copied from interface: SequenceNumberScheme
Get the nth next number in this sequence's scheme without causing it to move to the next-in-sequence. This method returns the nth next number in the sequence. This is an optional operation. If a sequence numbering scheme does not support this operation, it should always return SequenceNumberScheme.PEEK_UNSUPPORTEDto the caller.

Specified by:
peek in interface SequenceNumberScheme

reset

public void reset()
Description copied from interface: SequenceNumberScheme
Reset the sequence scheme to the beginning of the sequence.

Specified by:
reset in interface SequenceNumberScheme


Copyright © 2011 smppapi at Sourceforge. All Rights Reserved.