Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.validator.routines.checkdigit
Class IBANCheckDigit

    java.lang.Object
      org.apache.commons.validator.routines.checkdigit.IBANCheckDigit

All Implemented Interfaces:
  Serializable, CheckDigit

    public final class IBANCheckDigit

extends Object
implements CheckDigit, Serializable

IBAN (International Bank Account Number) Check Digit calculation/validation.

This rountine is based on the ISO 7064 Mod 97,10 check digit caluclation routine.

The two check digit characters in a IBAN number are the third and fourth characters in the code. For check digit calculation/validation the first four characters are moved to the end of the code. So `CCDDnnnnnnn` becomes `nnnnnnnCCDD` (where `CC` is the country code and `DD` is the check digit). For check digit calcualtion the check digit value should be set to zero (i.e. `CC00nnnnnnn` in this example.

For further information see Wikipedia - IBAN number.

Since:
  Validator 1.4
Version:
  $Revision: 1227719 $ $Date: 2012-01-05 18:45:51 +0100 (Thu, 05 Jan 2012) $
See Also:
  Serialized Form

Field Summary
`static CheckDigit` | `IBAN_CHECK_DIGIT` Singleton IBAN Number Check Digit instance

Constructor Summary
`IBANCheckDigit()` Construct Check Digit routine for IBAN Numbers.

Method Summary
`String` | `calculate(String code)` Calculate the Check Digit for an IBAN code.
`boolean` | `isValid(String code)` Validate the check digit for an the IBAN code.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### IBAN_CHECK_DIGIT

    public static final CheckDigit IBAN_CHECK_DIGIT

  Singleton IBAN Number Check Digit instance

Constructor Detail

### IBANCheckDigit

    public IBANCheckDigit()

  Construct Check Digit routine for IBAN Numbers.

Method Detail

### isValid

    public boolean isValid(String code)

  Validate the check digit for an the IBAN code.

  Specified by:
    `isValid` in interface `CheckDigit`
  Parameters:
    `code` - The code to validate
  Returns:
    `true` if the check digit is valid, otherwise `false`

### calculate

    public String calculate(String code)
                     throws CheckDigitException

  Calculate the Check Digit for an IBAN code.

  Note: The check digit is the third and fourth characters and and should contain value "`00`".

  Specified by:
    `calculate` in interface `CheckDigit`
  Parameters:
    `code` - The code to calculate the Check Digit for
  Returns:
    The calculated Check Digit
  Throws:
    `CheckDigitException` - if an error occurs calculating the check digit for the specified code

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.