org.mobicents.protocols.smpp.util
Class DefaultSequenceScheme

java.lang.Object
  extended by org.mobicents.protocols.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.

This implementation uses an AtomicInteger internally to track the next sequence number.

Version:
$Id: DefaultSequenceScheme.java 452 2009-01-15 16:56:36Z orank $

Field Summary
static long MAX_VALUE
          Maximum this sequence can go to (a 32-bit unsigned integer).
 
Fields inherited from interface org.mobicents.protocols.smpp.util.SequenceNumberScheme
PEEK_UNSUPPORTED
 
Constructor Summary
DefaultSequenceScheme()
           
DefaultSequenceScheme(long start)
          Construct a new DefaultSequenceScheme that starts the sequence from start.
 
Method Summary
 long nextNumber()
          Get the next number in this sequence's scheme.
 long peek()
          Get the next number in this sequence's scheme without causing it to move to the next-in-sequence.
 long peek(long 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
 

Field Detail

MAX_VALUE

public static final long MAX_VALUE
Maximum this sequence can go to (a 32-bit unsigned integer).

See Also:
Constant Field Values
Constructor Detail

DefaultSequenceScheme

public DefaultSequenceScheme()

DefaultSequenceScheme

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

Method Detail

nextNumber

public long 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 long 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 long peek(long 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_UNSUPPORTED to 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 Mobicents. All Rights Reserved.