|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.id.AbstractStringIdentifierGenerator org.apache.commons.id.serial.PrefixedLeftPaddedNumericGenerator
public class PrefixedLeftPaddedNumericGenerator
PrefixedLeftPaddedNumericGenerator
is an Identifier Generator
that generates a left-padded incrementing number with a prefix as a String object.
All generated ids have the same length (prefixed and padded with 0's
on the left), which is determined by the size
parameter passed
to the constructor.
The wrap
property determines whether or not the sequence wraps
when it reaches the largest value that can be represented in size
base 10 digits. If wrap
is false and the the maximum representable
value is exceeded, an IllegalStateException
is thrown.
Field Summary |
---|
Fields inherited from class org.apache.commons.id.AbstractStringIdentifierGenerator |
---|
ALPHA_NUMERIC_CHARSET_SIZE, DEFAULT_ALPHANUMERIC_IDENTIFIER_SIZE, MAX_INT_ALPHANUMERIC_VALUE_LENGTH, MAX_INT_NUMERIC_VALUE_LENGTH, MAX_LONG_ALPHANUMERIC_VALUE_LENGTH, MAX_LONG_NUMERIC_VALUE_LENGTH |
Fields inherited from interface org.apache.commons.id.StringIdentifierGenerator |
---|
INFINITE_MAX_LENGTH |
Constructor Summary | |
---|---|
PrefixedLeftPaddedNumericGenerator(java.lang.String prefix,
boolean wrap,
int size)
Create a new prefixed left-padded numeric generator with the specified prefix. |
Method Summary | |
---|---|
java.lang.String |
getPrefix()
Return the prefix for this prefixed numeric generator. |
int |
getSize()
Returns the (constant) size of the strings generated by this generator. |
boolean |
isWrap()
Getter for property wrap. |
long |
maxLength()
Returns the maximum length (number or characters) for an identifier from this sequence. |
long |
minLength()
Returns the minimum length (number of characters) for an identifier from this sequence. |
java.lang.String |
nextStringIdentifier()
Gets the next identifier in the sequence. |
void |
setWrap(boolean wrap)
Setter for property wrap. |
Methods inherited from class org.apache.commons.id.AbstractStringIdentifierGenerator |
---|
nextIdentifier |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PrefixedLeftPaddedNumericGenerator(java.lang.String prefix, boolean wrap, int size)
prefix
- prefix, must not be null or emptywrap
- should the factory wrap when it reaches the maximum
value that can be represented in size
base 10 digits
(or throw an exception)size
- the size of the identifier, including prefix length
java.lang.IllegalArgumentException
- if size less prefix length is not at least one
java.lang.NullPointerException
- if prefix is null
Method Detail |
---|
public java.lang.String getPrefix()
public long maxLength()
AbstractStringIdentifierGenerator
The default implementation returns StringIdentifierGenerator.INFINITE_MAX_LENGTH
. Implementations
with bounded length identifiers should override this method to
return the maximum length of a generated identifier.
maxLength
in interface StringIdentifierGenerator
maxLength
in class AbstractStringIdentifierGenerator
StringIdentifierGenerator.INFINITE_MAX_LENGTH
if there is no upper boundpublic long minLength()
AbstractStringIdentifierGenerator
The default implementation returns 0. Implementations with identifiers having a postive minimum length should override this method to return the maximum length of a generated identifier.
minLength
in interface StringIdentifierGenerator
minLength
in class AbstractStringIdentifierGenerator
public int getSize()
public boolean isWrap()
true
if this generator is set up to wrappublic void setWrap(boolean wrap)
wrap
- should the factory wrap when it reaches the maximum
value that can be represented in size
base 10 digits
(or throw an exception)public java.lang.String nextStringIdentifier()
StringIdentifierGenerator
nextStringIdentifier
in interface StringIdentifierGenerator
nextStringIdentifier
in class AbstractStringIdentifierGenerator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |