public abstract class StandardNumber
extends java.lang.Object
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 |
---|---|
java.lang.Object |
clone()
Returns a clone if the implementation is cloneable.
|
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.
|
static StandardNumber |
getInstance(java.lang.Package thePackage,
java.lang.ClassLoader classLoader,
java.lang.String type) |
static StandardNumber |
getInstance(java.lang.String type) |
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.
|
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()
public static StandardNumber getInstance(java.lang.String type) throws NoSuchStandardNumberException
NoSuchStandardNumberException
public static StandardNumber getInstance(java.lang.Package thePackage, java.lang.ClassLoader classLoader, java.lang.String type) throws NoSuchStandardNumberException
NoSuchStandardNumberException
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if this is called on an
implementation that does not support `Cloneable`