com.metamatrix.common.id.dbid
Class ReservedIDBlock

java.lang.Object
  extended by com.metamatrix.common.id.dbid.ReservedIDBlock
All Implemented Interfaces:
java.io.Serializable

public class ReservedIDBlock
extends java.lang.Object
implements java.io.Serializable

Used by DBIDGenerator to reserve a block of uniqueIDs used to create ID objects.

See Also:
Serialized Form

Field Summary
static long NO_ID_AVAILABLE
          Indicates that all the id's have been used up for this block
 
Constructor Summary
ReservedIDBlock(java.lang.String context, long first, long last, long max)
          Construct a new instance with the first ID and last ID in the block.
 
Method Summary
 java.lang.String getContext()
          Return the context for this ID block;
 long getLast()
          Return the last ID that will be used in the block;
 long getMax()
          Return the maximum number allowed for this context
 long getNextID()
          Return the next ID in the block.
 boolean isAtMaximum()
           
 boolean isDepleted()
          Returns boolean indicating if block is all used up.
 boolean isWrappable()
          Returns boolean indicating if the numbers can be reused when the maximum number is reached.
 void setIsWrappable(boolean enableWrapping)
          Call to enable this context to reuse its numbers when the maximum number is reached.
 java.lang.String toString()
          Return String representation of this instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_ID_AVAILABLE

public static final long NO_ID_AVAILABLE
Indicates that all the id's have been used up for this block

See Also:
Constant Field Values
Constructor Detail

ReservedIDBlock

public ReservedIDBlock(java.lang.String context,
                       long first,
                       long last,
                       long max)
Construct a new instance with the first ID and last ID in the block.

Parameters:
first - Defines the first id in this block.
last - Defines the last id in the block.
Throws:
java.lang.IllegalArgumentException - if first > last
Method Detail

getNextID

public long getNextID()
Return the next ID in the block. If no id is available then return NO_ID_AVAILABLE

Returns:
long nextID in block

getLast

public long getLast()
Return the last ID that will be used in the block;

Returns:
long lastID in block

getContext

public java.lang.String getContext()
Return the context for this ID block;

Returns:
String context

isDepleted

public boolean isDepleted()
Returns boolean indicating if block is all used up.

Returns:
true if block is depleted.

isAtMaximum

public boolean isAtMaximum()

setIsWrappable

public void setIsWrappable(boolean enableWrapping)
Call to enable this context to reuse its numbers when the maximum number is reached.


isWrappable

public boolean isWrappable()
Returns boolean indicating if the numbers can be reused when the maximum number is reached.

Returns:
true if block is wrappable

getMax

public long getMax()
Return the maximum number allowed for this context

Returns:
long maximum number

toString

public java.lang.String toString()
Return String representation of this instance

Overrides:
toString in class java.lang.Object
Returns:
String representation


Copyright © 2009. All Rights Reserved.