public class SequencePattern extends java.lang.Object implements Pattern
Pattern
interface.
A general sequence pattern definition is "S+startingNumber/Increment". The mask character "S" means the pattern is a sequence pattern. The length of the mask character represents the length of the codes. The "startingNumber" defines the start number of the sequence. The "Increment" defines the increment between two codes.
For example, [SSSS+100/20] represents a sequence starting at 0100 and incrementing by 20.
For example, [SSSS+100] represents a sequence starting at 0100 and incrementing by 1.
For example, [SSSS] represents a sequence starting at 0000 and incrementing by 1.
Pattern
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM Copyright notice field.
|
Constructor and Description |
---|
SequencePattern()
Constructor of the sequence pattern.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCode()
This method gets the generated sequence string
|
char |
getMaskCharacter()
This method gets the mask character "S"
|
java.lang.String |
getPatternDefinition()
This method gets the pattern definition string
|
java.math.BigDecimal |
getPatternSpace()
This method gets the size of the pattern space
|
void |
setPatternDefinition(java.lang.String patternDefIn)
This method sets the pattern definition string
|
boolean |
validatePattern()
Check whether the pattern definition is correct
|
public static final java.lang.String COPYRIGHT
public SequencePattern()
It sets the initial value of the start number, increments and current code.
public java.lang.String getCode()
getCode
in interface Pattern
Pattern.getCode()
public java.math.BigDecimal getPatternSpace()
It uses "Floor((Power(10, length of 'S') -1 - 'startingNumber')/'Increment')+1" to get the total size of possible codes numbers.
getPatternSpace
in interface Pattern
Pattern.getPatternSpace()
public java.lang.String getPatternDefinition()
getPatternDefinition
in interface Pattern
Pattern.getPatternDefinition()
public boolean validatePattern()
If the pattern has "/", then will check the "Increment" part is a positive integer.
If the pattern has "+", then will check the "startingNumber" is a non-negative integer.
At last, will check the mask string only contains "S".
This method will return false if above conditions are not satisfied.
validatePattern
in interface Pattern
Pattern.validatePattern()
public char getMaskCharacter()
getMaskCharacter
in interface Pattern
Pattern.getMaskCharacter()
public void setPatternDefinition(java.lang.String patternDefIn)
setPatternDefinition
in interface Pattern
patternDefIn
- The pattern definition stringPattern.setPatternDefinition(String)