org.openmrs.patient.impl
Class VerhoeffIdentifierValidator

java.lang.Object
  extended by org.openmrs.patient.impl.BaseHyphenatedIdentifierValidator
      extended by org.openmrs.patient.impl.VerhoeffIdentifierValidator
All Implemented Interfaces:
IdentifierValidator

public class VerhoeffIdentifierValidator
extends BaseHyphenatedIdentifierValidator

The Verhoeff Check Digit Validator catches all single errors and all adjacent transpositions. See: http://www.cs.utsa.edu/~wagner/laws/verhoeff.html and Wagner, Neal. "Verhoeff's Decimal Error Detection". The Laws of Cryptography with Java Code. p 54. San Antonio, TX: 2003. http://www.cs.utsa.edu/~wagner/lawsbookcolor/laws.pdf


Constructor Summary
VerhoeffIdentifierValidator()
           
 
Method Summary
 java.lang.String getAllowedCharacters()
           
protected  int getCheckDigit(java.lang.String undecoratedIdentifier)
           
 java.lang.String getName()
           
 java.lang.String getValidIdentifier(java.lang.String undecoratedIdentifier)
          Override to disallow identifiers that are not exactly VERHOEFF_UNDECORATED_ID_LENGTH long.
 boolean isValid(java.lang.String identifier)
          Override to disallow numeric check digits and identifiers that are not exactly VERHOEFF_ID_LENGTH long.
 
Methods inherited from class org.openmrs.patient.impl.BaseHyphenatedIdentifierValidator
checkAllowedIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VerhoeffIdentifierValidator

public VerhoeffIdentifierValidator()
Method Detail

getAllowedCharacters

public java.lang.String getAllowedCharacters()
Specified by:
getAllowedCharacters in interface IdentifierValidator
Specified by:
getAllowedCharacters in class BaseHyphenatedIdentifierValidator
Returns:
A string containing all the characters allowed in this type of identifier validation.
See Also:
BaseHyphenatedIdentifierValidator.getAllowedCharacters()

getName

public java.lang.String getName()
Specified by:
getName in interface IdentifierValidator
Specified by:
getName in class BaseHyphenatedIdentifierValidator
Returns:
The name of this validator. E.g. "Luhn Algorithm"
See Also:
BaseHyphenatedIdentifierValidator.getName()

getCheckDigit

protected int getCheckDigit(java.lang.String undecoratedIdentifier)
Specified by:
getCheckDigit in class BaseHyphenatedIdentifierValidator
See Also:
BaseHyphenatedIdentifierValidator.getCheckDigit(java.lang.String)

isValid

public boolean isValid(java.lang.String identifier)
                throws UnallowedIdentifierException
Override to disallow numeric check digits and identifiers that are not exactly VERHOEFF_ID_LENGTH long.

Specified by:
isValid in interface IdentifierValidator
Overrides:
isValid in class BaseHyphenatedIdentifierValidator
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:
BaseHyphenatedIdentifierValidator.isValid(java.lang.String)

getValidIdentifier

public java.lang.String getValidIdentifier(java.lang.String undecoratedIdentifier)
                                    throws UnallowedIdentifierException
Override to disallow identifiers that are not exactly VERHOEFF_UNDECORATED_ID_LENGTH long.

Specified by:
getValidIdentifier in interface IdentifierValidator
Overrides:
getValidIdentifier in class BaseHyphenatedIdentifierValidator
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:
BaseHyphenatedIdentifierValidator.getValidIdentifier(java.lang.String)
Expected behavior:
get valid identifier

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change