public abstract class StandardNumber extends StandardNumberSpi
Standard number implementation. A standard number is a number that
is backed by an international standard or a de-facto community use
can accept alphanumeric values (digits and letters and separator characters)
can be normalizedValue
can be verified and raise en error is verification fails
must have a createChecksum
can be formatted to a printable representation
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
type |
protected java.lang.String |
value |
Modifier | Constructor and Description |
---|---|
protected |
StandardNumber(java.lang.String type) |
Modifier and Type | Method and Description |
---|---|
abstract StandardNumber |
createChecksum(boolean withChecksum)
Indicate that a correct check sum should be computed.
|
abstract java.lang.String |
format()
Return a formatted value of this standard number
This is best for human-readable representation, but is
not necessarily a format for computation.
|
abstract java.util.Collection<java.lang.String> |
getTypedVariants() |
abstract boolean |
isValid()
Check this number for validity.
|
abstract StandardNumber |
normalize()
Normalize the value by removing all unwanted characters or
replacing characters with the ones required for verification.
|
abstract java.lang.String |
normalizedValue()
Return normalized value of this standard number.
|
abstract StandardNumber |
reset() |
StandardNumber |
set(java.lang.CharSequence value)
Set the input value of this standard number.
|
java.lang.String |
type()
Return the type of this standard number.
|
abstract StandardNumber |
verify()
Verify the number.
|
clone, getInstance, getInstance
public java.lang.String type()
Return the type of this standard number.
public StandardNumber set(java.lang.CharSequence value)
Set the input value of this standard number. The input must be normalized and verified before being accepted as valid.
value
- the raw input valuepublic abstract StandardNumber normalize()
Normalize the value by removing all unwanted characters or replacing characters with the ones required for verification.
public abstract boolean isValid()
Check this number for validity.
public abstract StandardNumber verify()
Verify the number.
java.lang.NumberFormatException
- if verification failedpublic abstract StandardNumber createChecksum(boolean withChecksum)
Indicate that a correct check sum should be computed.
withChecksum
- if checksum is includedpublic abstract java.lang.String normalizedValue()
Return normalized value of this standard number. In most cases, this is also the canonical form of the standard number. This is a representation without unneccessary characters, useful for computation purposes, like comparing for equivalence.
public abstract java.lang.String format()
Return a formatted value of this standard number This is best for human-readable representation, but is not necessarily a format for computation.
public abstract StandardNumber reset()
public abstract java.util.Collection<java.lang.String> getTypedVariants()