com.prowidesoftware.swift.model
Class IBAN

java.lang.Object
  extended by com.prowidesoftware.swift.model.IBAN

public class IBAN
extends java.lang.Object

Utility class to validate IBAN codes. The IBAN consists of a ISO 3166-1 alpha-2 country code, followed by two check digits (represented by kk in the examples below), and up to thirty alphanumeric characters for the domestic bank account number, called the BBAN (Basic Bank Account Number).

Exampe usage scenario

IBAN iban = new IBAN("ES2153893489");
 if (iban.isValid())
                System.out.println("ok");
 else
                System.out.println("problem with iban: "+iban.getInvalidCause());
 

Since:
3.3
Version:
$Id: IBAN.java,v 1.1.1.1 2013/04/10 17:04:50 mgriffa Exp $
Author:
www.prowidesoftware.com

Constructor Summary
IBAN(java.lang.String iban)
          Create an IBAN object with the given iban code.
 
Method Summary
 java.lang.String getIban()
          Get the IBAN
 java.lang.String getInvalidCause()
          Get a string with information about why the IBAN was found invalid
 boolean isValid()
          Completely validate an IBAN Currently validation checks that the length is at least 5 chars: (2 country code, 2 verifying digits, and 1 BBAN) checks the country code to be valid an the BBAN to match the verifying digits
 java.lang.String removeNonAlpha(java.lang.String iban)
           
 void setIban(java.lang.String iban)
          Set the IBAN
 java.lang.String translateChars(java.lang.StringBuffer bban)
          Translate letters to numbers, also ignoring non alphanumeric characters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IBAN

public IBAN(java.lang.String iban)
Create an IBAN object with the given iban code. This constructor does not perform any validation on the iban, only

Parameters:
iban -
Method Detail

getIban

public java.lang.String getIban()
Get the IBAN

Returns:
a string with the IBAN

setIban

public void setIban(java.lang.String iban)
Set the IBAN

Parameters:
iban - the IBAN to set

isValid

public boolean isValid()
Completely validate an IBAN Currently validation checks that the length is at least 5 chars: (2 country code, 2 verifying digits, and 1 BBAN) checks the country code to be valid an the BBAN to match the verifying digits

Returns:
true if the IBAN is found to be valid and false in other case
Throws:
java.lang.IllegalStateException - if iban is null

translateChars

public java.lang.String translateChars(java.lang.StringBuffer bban)
Translate letters to numbers, also ignoring non alphanumeric characters

Parameters:
bban -
Returns:
the translated value

removeNonAlpha

public java.lang.String removeNonAlpha(java.lang.String iban)
Parameters:
iban -
Returns:
the resulting IBAN

getInvalidCause

public java.lang.String getInvalidCause()
Get a string with information about why the IBAN was found invalid

Returns:
a human readable (english) string