public class IBAN
extends java.lang.Object
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());
Constructor and Description |
---|
IBAN(java.lang.String iban)
Create an IBAN object with the given iban code.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getBban()
Gets the BBAN (custom account number) part of the IBAN
|
static java.lang.String |
getBban(java.lang.String iban)
Gets the BBAN (custom account number) part of the given IBAN
|
java.lang.String |
getCheckDigits()
Gets the check digits part of the IBAN
|
static java.lang.String |
getCheckDigits(java.lang.String iban)
Gets the check digits part of the given IBAN.
|
java.lang.String |
getCountryCode()
Gets the country code part of the IBAN
|
static java.lang.String |
getCountryCode(java.lang.String iban)
Gets the country code part of the given IBAN.
|
java.lang.String |
getIban()
Get the IBAN
|
boolean |
isValid()
Checks if the IBAN number is valid.
|
java.lang.String |
removeNonAlpha(java.lang.String iban)
Removes all non alpha-numeric characters in the IBAN code
|
void |
setIban(java.lang.String iban)
Set the IBAN
|
java.lang.String |
translateChars(java.lang.StringBuilder str)
Translate letters to numbers, also ignoring non alphanumeric characters
|
IbanValidationResult |
validate()
Check an IBAN number throwing an exception with validation details if it is not valid.
|
public IBAN(java.lang.String iban)
iban
- the IBAN stringpublic static java.lang.String getBban(java.lang.String iban) throws java.lang.IndexOutOfBoundsException
iban
- a well-formed IBANjava.lang.IndexOutOfBoundsException
- if the IBAN length is wrongpublic static java.lang.String getCheckDigits(java.lang.String iban) throws java.lang.IndexOutOfBoundsException
iban
- a well-formed IBANjava.lang.IndexOutOfBoundsException
- if the IBAN length is wrongpublic static java.lang.String getCountryCode(java.lang.String iban) throws java.lang.IndexOutOfBoundsException
iban
- a well-formed IBANjava.lang.IndexOutOfBoundsException
- if the IBAN length is wrongpublic java.lang.String getIban()
public void setIban(java.lang.String iban)
iban
- the IBAN to setpublic boolean isValid()
true
if the IBAN is valid and false
in other casefor details regarding the validation checks or if you need structured details of the validation
problem found.
public IbanValidationResult validate()
Validates that the length is at least 5 chars: composed by a valid 2 letters ISO country code,
2 verifying digits, and 1 BBAN. The verification digits are also computed and verified.
For the BBAN validation the specific per country structure must be defined either in the
BbanStructureValidations.json file or by API in the BbanStructureValidations
instance.
Non alpha-numeric characters are removed from the code prior to validation. Meaning an IBAN such as "ES64 0049 6170 68 2810279951" will be considered valid.
public java.lang.String translateChars(java.lang.StringBuilder str)
str
- input stringpublic java.lang.String removeNonAlpha(java.lang.String iban)
iban
- IBAN stringpublic java.lang.String getBban()
public java.lang.String getCheckDigits()
public java.lang.String getCountryCode()