Class BIC
- java.lang.Object
-
- com.prowidesoftware.swift.model.BIC
-
- Direct Known Subclasses:
LogicalTerminalAddress
public class BIC extends java.lang.Object
Helper class to process BIC information.Bank Identifier Codes (also known as SWIFT-BIC, BIC, SWIFT ID or SWIFT code) is a unique identification code for both financial and non-financial institutions. When assigned to a non-financial institution, the code may also be known as a Business Entity Identifier or BEI.
It is composed by:
- 4 letters: institution code or bank code.
- 2 letters: ISO 3166-1 alpha-2 country code
- 2 letters or digits: location code
- 3 letters: branch code
- Since:
- 3.3
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
branch
static java.lang.String
PARTNER_PREFIX
Constant value with which all partner bics startstatic java.lang.String
TEST12
Fake Logical terminal address for testing, consisting of a fake "test & training" BIC of 12 chars (including the terminal identification)static java.lang.String
TEST8
Fake "test & training" BIC with 8 chars for testing
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BIC
asTestBic()
Returns a new BIC with second character of the location set to zero.java.lang.String
distinguishedName()
Returns the Distinguished Name (DN) for this BIC.java.lang.String
distinguishedName(boolean includeDefaultBranch)
Returns the Distinguished Name (DN) for this BIC.boolean
equals(java.lang.Object o)
java.lang.String
getBic11()
Returns the BIC code with 11 characters composed by institution code, country, location and branch.java.lang.String
getBic8()
Returns the first 8 characters of the BIC code, composed by the institution code, country and location.java.lang.String
getBranch()
It returns the last three that conform the branch or null if branch is not present.java.lang.String
getBranchOrDefault()
Returns the branch code or XXX as defaultjava.lang.String
getCountry()
java.lang.String
getInstitution()
java.lang.String
getLocation()
java.lang.String
getSubtype()
Returns ths subtype code.int
hashCode()
boolean
isLive()
Returns true if the BIC is live (connected and not test & training) on the network.boolean
isNonLive()
Returns true if the BIC is not live (not connected) on the network.boolean
isTestAndTraining()
Returns true if the BIC is a Test & Training BIC code.boolean
isValid()
Validates the BIC structure.protected void
parse(java.lang.String bic)
void
setBranch(java.lang.String branch)
void
setCountry(java.lang.String country)
void
setInstitution(java.lang.String institution)
void
setLocation(java.lang.String location)
void
setSubtype(java.lang.String subtype)
Sets a subtype codejava.lang.String
toString()
BicValidationResult
validate()
Validates the BIC structure.
-
-
-
Field Detail
-
TEST8
public static final transient java.lang.String TEST8
Fake "test & training" BIC with 8 chars for testing- Since:
- 7.6
- See Also:
- Constant Field Values
-
TEST12
public static final transient java.lang.String TEST12
Fake Logical terminal address for testing, consisting of a fake "test & training" BIC of 12 chars (including the terminal identification)- Since:
- 7.6
- See Also:
SwiftBlock1.getLogicalTerminal()
, Constant Field Values
-
PARTNER_PREFIX
public static final java.lang.String PARTNER_PREFIX
Constant value with which all partner bics start- Since:
- 7.8
- See Also:
- Constant Field Values
-
branch
protected java.lang.String branch
-
-
Constructor Detail
-
BIC
public BIC(java.lang.String bic)
Constructor with a BIC8 or BIC11 code.For BIC codes with 12 characters (meaning it includes the logical terminal identifier) use
LogicalTerminalAddress
instead. This implementation will drop the LT identifier if a 12 characters full logical terminal addess is passed as parameter.If the code is longer than 11 characters, the remainder will be store as part of the branch code.
- Parameters:
bic
- the BIC code to use in this BIC (8 or 11 chars)
-
BIC
public BIC()
Default constructor
-
-
Method Detail
-
parse
protected void parse(java.lang.String bic)
-
isValid
public boolean isValid()
Validates the BIC structure.- Returns:
- true if the BIC is valid and false otherwise
- See Also:
for details regarding the validation checks or if you need structured details of the validation problem found.
-
validate
public BicValidationResult validate()
Validates the BIC structure.Checks the syntax of the BIC, verifying: the total length is 8, 11 or 12 (LT identifier), the country is a valid ISO country code using
IsoUtils
, the institution is composed by upper case letters and the location and branch are composed by upper case letter or digits.This method does not validate against any BIC directory.
- Returns:
- BicValidationResult with detailed information of the validation problem found
- Since:
- 7.10.3
-
getBranch
public java.lang.String getBranch()
It returns the last three that conform the branch or null if branch is not present.- Returns:
- the BIC's branch part or null if not found.
- Since:
- 7.8.5
-
setBranch
public void setBranch(java.lang.String branch)
- Parameters:
branch
- the branch part of the BIC- Since:
- 7.10.3
-
getBranchOrDefault
public java.lang.String getBranchOrDefault()
Returns the branch code or XXX as default- Returns:
- branch code or default string
- Since:
- 7.10.3
-
getSubtype
public java.lang.String getSubtype()
Returns ths subtype code. Notice this information is not part of the BIC code, it must be explicitly set withsetSubtype(String)
- Returns:
- subtype code
- Since:
- 7.4
-
setSubtype
public void setSubtype(java.lang.String subtype)
Sets a subtype code- Parameters:
subtype
- subtype code to set- Since:
- 7.4
-
isTestAndTraining
public boolean isTestAndTraining()
Returns true if the BIC is a Test & Training BIC code.In SWIFT’s FIN messaging system, a BIC with a zero in the 8th position is a Test & Training BIC, and as such it cannot be used in production FIN messages.
- Returns:
- true if it is a Test & Training BIC, false if is not or if the condition cannot be determined
- Since:
- 7.6
-
isNonLive
public boolean isNonLive()
Returns true if the BIC is not live (not connected) on the network.BICs can identify not only financial institutions but also non-financial ones either connected or not connected to the SWIFT network.
A BIC of an institution which is not connected to the SWIFT network still has a location code with the digit 1 at the end (for instance AFSEUS31). BICs like that are called non-SWIFT BICs (or BIC 1).
In SWIFT’s FIN messaging system, a BIC with a one in the 8th position is a Non-Live BIC.
Note this is not the opposite of
isLive()
- Returns:
- true if it is a Non-Live BIC, false if is not or if the condition cannot be determined
- Since:
- 7.7
-
isLive
public boolean isLive()
Returns true if the BIC is live (connected and not test & training) on the network.BICs can identify not only financial institutions but also non-financial ones either connected or not connected to the SWIFT network.
In SWIFT’s FIN messaging system, a BIC with a character different than zero (that would be Test & Training) or one (that would be non-connected) in the 8th position is a Live BIC.
Note this is not the opposite of
isNonLive()
- Returns:
- true if it is a Non-Live BIC, false if is not or if the condition cannot be determined
- Since:
- 7.7
-
getBic8
public java.lang.String getBic8()
Returns the first 8 characters of the BIC code, composed by the institution code, country and location.- Returns:
- the bic8 or null if the BIC has less than 8 characters
- Since:
- 7.6
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getBic11
public java.lang.String getBic11()
Returns the BIC code with 11 characters composed by institution code, country, location and branch.If the branch is not present, then XXX will be used as default branch.
- Returns:
- the bic11 or null if the BIC has less than 8 characters
- Since:
- 7.6
-
distinguishedName
public java.lang.String distinguishedName()
Returns the Distinguished Name (DN) for this BIC.The created DN always includes the BIC8 and "swift" and if the branch is present and not "XXX" it will also be included as organization unit (ou)
- Returns:
- ou=<branch>,o=<bic8>,o=swift
- Since:
- 7.9.3
-
distinguishedName
public java.lang.String distinguishedName(boolean includeDefaultBranch)
Returns the Distinguished Name (DN) for this BIC.The created DN always includes the BIC8 and "swift" and if the branch is present and not "XXX" it will also be included as organization unit (ou)
- Parameters:
includeDefaultBranch
- if true will return ou=<xxx even if the branch is not present- Returns:
- ou=<branch>,o=<bic8>,o=swift
- Since:
- 9.3.15
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getInstitution
public java.lang.String getInstitution()
- Returns:
- the institution identifier part of the BIC
- Since:
- 7.10.3
-
setInstitution
public void setInstitution(java.lang.String institution)
- Parameters:
institution
- the institution identifier part of the BIC- Since:
- 7.10.3
-
getCountry
public java.lang.String getCountry()
- Returns:
- the country part of the BIC
- Since:
- 7.10.3
-
setCountry
public void setCountry(java.lang.String country)
- Parameters:
country
- the country part of the BIC- Since:
- 7.10.3
-
getLocation
public java.lang.String getLocation()
- Returns:
- the location part of the BIC
- Since:
- 7.10.3
-
setLocation
public void setLocation(java.lang.String location)
- Parameters:
location
- the location part of the BIC- Since:
- 7.10.3
-
asTestBic
public BIC asTestBic()
Returns a new BIC with second character of the location set to zero. If the location is invalid it is set with a default value. Also if it has more than 2 characters it is trimmed to two with a zero in the second position.- Returns:
- test BIC
- Since:
- 9.1.3
-
-