public abstract class AbstractIdGenerator extends org.apache.avalon.framework.logger.AbstractLogEnabled implements IdGenerator, org.apache.avalon.framework.thread.ThreadSafe
| Modifier and Type | Field and Description |
|---|---|
private static java.math.BigDecimal |
BIG_DECIMAL_MAX_LONG |
private java.lang.Object |
m_semaphore
Used to manage internal synchronization.
|
private boolean |
m_useBigDecimals
Data type for the Id Pool.
|
ROLE| Constructor and Description |
|---|
AbstractIdGenerator() |
| Modifier and Type | Method and Description |
|---|---|
java.math.BigDecimal |
getNextBigDecimalId()
Returns the next Id from the pool.
|
protected abstract java.math.BigDecimal |
getNextBigDecimalIdInner()
Gets the next id as a Big Decimal.
|
byte |
getNextByteId()
Returns the next Id from the pool.
|
int |
getNextIntegerId()
Returns the next Id from the pool.
|
long |
getNextLongId()
Returns the next Id from the pool.
|
protected long |
getNextLongIdChecked(long maxId)
Gets the next Long Id constraining the value to be less than the specified maxId.
|
protected abstract long |
getNextLongIdInner()
Gets the next id as a long.
|
short |
getNextShortId()
Returns the next Id from the pool.
|
protected boolean |
isUsingBigDecimals()
Returns true if the internal data type is using BigDecimals, false if it is using longs.
|
protected void |
setUseBigDecimals(boolean useBigDecimals)
By default, the IdGenerator will operate using a backend datatype of type long.
|
private static final java.math.BigDecimal BIG_DECIMAL_MAX_LONG
private java.lang.Object m_semaphore
private boolean m_useBigDecimals
protected abstract java.math.BigDecimal getNextBigDecimalIdInner()
throws IdException
IdException - if an Id could not be allocated for any reason.protected abstract long getNextLongIdInner()
throws IdException
IdException - if an Id could not be allocated for any reason.protected final void setUseBigDecimals(boolean useBigDecimals)
useBigDecimals - True to set BigDecimal as the internal data type.protected final boolean isUsingBigDecimals()
protected final long getNextLongIdChecked(long maxId)
throws IdException
IdException - if the next id is larger than the specified maxId.public final java.math.BigDecimal getNextBigDecimalId()
throws IdException
getNextBigDecimalId in interface IdGeneratorIdExceptionpublic final long getNextLongId()
throws IdException
getNextLongId in interface IdGeneratorIdException - if the next id is outside of the range of valid longs.public final int getNextIntegerId()
throws IdException
getNextIntegerId in interface IdGeneratorIdException - if the next id is outside of the range of valid integers.public final short getNextShortId()
throws IdException
getNextShortId in interface IdGeneratorIdException - if the next id is outside of the range of valid shorts.public final byte getNextByteId()
throws IdException
getNextByteId in interface IdGeneratorIdException - if the next id is outside of the range of valid bytes.