org.openmrs.patient.impl
Class BaseHyphenatedIdentifierValidator
java.lang.Object
org.openmrs.patient.impl.BaseHyphenatedIdentifierValidator
- All Implemented Interfaces:
- IdentifierValidator
- Direct Known Subclasses:
- LuhnIdentifierValidator, VerhoeffIdentifierValidator
public abstract class BaseHyphenatedIdentifierValidator
- extends java.lang.Object
- implements IdentifierValidator
An abstract class for identifier validators for identifiers that have a hyphen before a single
check digit. Identifiers can not be null, must have at least one character before the check
digit, and can not contain white space. Integers 0-9 or characters A-J are allowed for the check
digit. A character is used by default.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BaseHyphenatedIdentifierValidator
public BaseHyphenatedIdentifierValidator()
getCheckDigit
protected abstract int getCheckDigit(java.lang.String undecoratedIdentifier)
getAllowedCharacters
public abstract java.lang.String getAllowedCharacters()
- Specified by:
getAllowedCharacters
in interface IdentifierValidator
- Returns:
- A string containing all the characters allowed in this type of identifier validation.
- See Also:
IdentifierValidator.getAllowedCharacters()
getName
public abstract java.lang.String getName()
- Specified by:
getName
in interface IdentifierValidator
- Returns:
- The name of this validator. E.g. "Luhn Algorithm"
- See Also:
IdentifierValidator.getName()
getValidIdentifier
public java.lang.String getValidIdentifier(java.lang.String undecoratedIdentifier)
throws UnallowedIdentifierException
- Specified by:
getValidIdentifier
in interface IdentifierValidator
- Parameters:
undecoratedIdentifier
- The identifier prior to being given a check digit or other form
of validation.
- Returns:
- The identifier after the check digit or other form of validation has been applied.
- Throws:
UnallowedIdentifierException
- if the identifier contains unallowed characters or is
otherwise not appropriate for this validator.- See Also:
IdentifierValidator.getValidIdentifier(java.lang.String)
isValid
public boolean isValid(java.lang.String identifier)
throws UnallowedIdentifierException
- Specified by:
isValid
in interface IdentifierValidator
- Parameters:
identifier
- The Identifier to check.
- Returns:
- Whether this identifier is valid according to the validator.
- Throws:
UnallowedIdentifierException
- if the identifier contains unallowed characters or is
otherwise not appropriate for this validator.- See Also:
IdentifierValidator.isValid(java.lang.String)
checkAllowedIdentifier
protected void checkAllowedIdentifier(java.lang.String undecoratedIdentifier)
throws UnallowedIdentifierException
- Parameters:
undecoratedIdentifier
-
- Throws:
UnallowedIdentifierException
- if identifier contains unallowed characters or is
otherwise invalid.
Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change