Class SwiftBlock1
- java.lang.Object
-
- com.prowidesoftware.swift.model.SwiftBlock
-
- com.prowidesoftware.swift.model.SwiftValueBlock
-
- com.prowidesoftware.swift.model.SwiftBlock1
-
- All Implemented Interfaces:
java.io.Serializable
public class SwiftBlock1 extends SwiftValueBlock implements java.io.Serializable
Base class for SWIFT Basic Header Block (block 1). It contains information about the source of the message.
The basic header block is fixed-length and continuous with no field delimiters. This class contains its elements as individual attributes for easier management of the block value.
This block is mandatory for all SWIFT messages.- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
APPLICATION_ID_FIN
Constant for FIN messages in application idstatic java.lang.String
APPLICATION_ID_GPA
Constant for GPA (General Purpose Application) messages in application idstatic java.lang.String
APPLICATION_ID_LOGINS
Constant for Logins and so messages in application id-
Fields inherited from class com.prowidesoftware.swift.model.SwiftBlock
blockType, input, output, unparsedTexts
-
-
Constructor Summary
Constructors Constructor Description SwiftBlock1()
Default constructorSwiftBlock1(SwiftBlock1 block)
Copy constructorSwiftBlock1(java.lang.String value)
Creates the block with lenient false, meaning it expects a fixed length value.SwiftBlock1(java.lang.String value, boolean lenient)
Creates a block 1 object setting attributes by parsing the fixed string argument;SwiftBlock1(java.lang.String applicationId, java.lang.String serviceId, java.lang.String logicalTerminal, java.lang.String sessionNumber, java.lang.String sequenceNumber)
Constructor for specific values
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clean()
Sets all attributes to nullboolean
equals(java.lang.Object o)
java.lang.String
field(SwiftBlock1Field field)
Generic getter for block attributes based on qualified names fromSwiftBlock1Field
static SwiftBlock1
fromJson(java.lang.String json)
This method deserializes the JSON data into an block 1 object.java.lang.String
getApplicationId()
Gets the application ID field in block 1BIC
getBIC()
Gets the BIC code from the LT address.java.lang.String
getBlockValue()
This method should be overwritten by subclasses, calling this method will throw ajava.lang.UnsupportedOperationException
java.lang.String
getLogicalTerminal()
Gets the The Logical Terminal address of the sender for messages sent or the receiver for messages received from the SWIFT network.java.lang.String
getName()
Returns the block name (the value 1 as a string)java.lang.Integer
getNumber()
Returns the block number (the value 1 as an integer)java.lang.String
getSequenceNumber()
Gets the sequence number field in block 1java.lang.String
getServiceId()
Gets the service ID field in block 1ServiceIdType
getServiceIdType()
Maps the service id to the service id enumerationjava.lang.String
getSessionNumber()
Gets the session number in block 1java.lang.String
getValue()
Gets the fixed length block 1 value, as a result of concatenating its individual elements as follow:
Application ID Service ID + Logical terminal (LT) address + Session number + Sequence number.
Notice that this method does not return the "1:" string.int
hashCode()
boolean
isEmpty()
Tell if this block is empty or not.void
setApplicationId(java.lang.String applicationId)
Sets the applicationIdprotected void
setBlockName(java.lang.String blockName)
Sets the block name.protected void
setBlockNumber(java.lang.Integer blockNumber)
Sets the block number.void
setBlockValue(java.lang.String value)
This method should be overwritten by subclasses, calling this method will throw ajava.lang.UnsupportedOperationException
void
setField(SwiftBlock1Field field, java.lang.String value)
Generic setter for block attributes based on qualified names fromSwiftBlock1Field
void
setLogicalTerminal(BIC bic)
Sets the logical terminal address from the parameter BIC code with "A" as default LT identifier and XXX as default branch code.void
setLogicalTerminal(LogicalTerminalAddress logicalTerminal)
Sets the LT address.void
setLogicalTerminal(java.lang.String logicalTerminal)
Sets the The Logical Terminal address with the parameter as it is given without any modification.void
setSender(java.lang.String sender)
Sets the logical terminal address from the parameter BIC.void
setSequenceNumber(java.lang.String sequenceNumber)
Sets the Sequence number that is generated by the user's computer.
For all FIN messages with a Service Identifier of 01 or 05, this number is the next expected sequence number appropriate to the direction of the transmission.
For FIN messages with a Service Identifier of 21 or 25, the sequence number is that of the acknowledged service message.
It is padded with zeros.void
setServiceId(java.lang.String serviceId)
Sets the Service IDvoid
setSessionNumber(java.lang.String sessionNumber)
Sets the Session number.void
setValue(java.lang.String value)
Sets the block's attributes by parsing the fixed length string argument.void
setValue(java.lang.String value, boolean lenient)
Sets the block's attributes by parsing string argument with its content
This value can be in different flavors because some fields are optional.
For example "F01BANKBEBBAXXX2222123456" or "1:F01BANKBEBBAXXX2222123456".java.lang.String
toJson()
Get a json representation of this object.-
Methods inherited from class com.prowidesoftware.swift.model.SwiftValueBlock
getValuePart, getValuePart, size
-
Methods inherited from class com.prowidesoftware.swift.model.SwiftBlock
getBlockType, getInput, getOutput, getUnparsedTexts, getUnparsedTextsSize, isTagBlock, setBlockType, setInput, setOutput, setUnparsedTexts, toString, unparsedTextAddText, unparsedTextAddText, unparsedTextGetAsMessage, unparsedTextGetText, unparsedTextIsMessage, unparsedTextVerify
-
-
-
-
Field Detail
-
APPLICATION_ID_FIN
public static final transient java.lang.String APPLICATION_ID_FIN
Constant for FIN messages in application id- Since:
- 4.1
- See Also:
- Constant Field Values
-
APPLICATION_ID_GPA
public static final transient java.lang.String APPLICATION_ID_GPA
Constant for GPA (General Purpose Application) messages in application id- Since:
- 4.1
- See Also:
- Constant Field Values
-
APPLICATION_ID_LOGINS
public static final transient java.lang.String APPLICATION_ID_LOGINS
Constant for Logins and so messages in application id- Since:
- 4.1
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SwiftBlock1
public SwiftBlock1(java.lang.String applicationId, java.lang.String serviceId, java.lang.String logicalTerminal, java.lang.String sessionNumber, java.lang.String sequenceNumber)
Constructor for specific values- Parameters:
applicationId
- the application idserviceId
- the service idlogicalTerminal
- the logical terminal namesessionNumber
- the session numbersequenceNumber
- the message sequence number
-
SwiftBlock1
public SwiftBlock1()
Default constructor
-
SwiftBlock1
public SwiftBlock1(java.lang.String value)
Creates the block with lenient false, meaning it expects a fixed length value. Example of supported values:
"F01BANKBEBBXXXX2222123456" or "1:F01BANKBEBBAXXX2222123456"- Parameters:
value
- a fixed length string of 25 or 27 (which must start with '1:') characters containing the blocks value- Throws:
java.lang.IllegalArgumentException
- if parameter is not 25 or 27 characters- See Also:
SwiftBlock1(String, boolean)
-
SwiftBlock1
public SwiftBlock1(java.lang.String value, boolean lenient)
Creates a block 1 object setting attributes by parsing the fixed string argument;- Parameters:
value
- string containing the entire blocks valuelenient
- if true the value will be parsed with a best effort heuristic, if false it will throw a IllegalArgumentException if the value has an invalid total size- Since:
- 7.7
- See Also:
setValue(String, boolean)
-
SwiftBlock1
public SwiftBlock1(SwiftBlock1 block)
Copy constructor- Parameters:
block
- an existing block1 to copy- Since:
- 7.10.4
-
-
Method Detail
-
fromJson
public static SwiftBlock1 fromJson(java.lang.String json)
This method deserializes the JSON data into an block 1 object.- Parameters:
json
- json representation- Returns:
- block 1 object
- Since:
- 7.9.8
- See Also:
toJson()
-
setBlockNumber
protected void setBlockNumber(java.lang.Integer blockNumber)
Sets the block number.- Specified by:
setBlockNumber
in classSwiftBlock
- Parameters:
blockNumber
- the block number to set- Throws:
java.lang.IllegalArgumentException
- if parameter blockName is not the integer 1- Since:
- 5.0
-
setBlockName
protected void setBlockName(java.lang.String blockName)
Sets the block name. Will cause an exception unless setting block number to 1.- Specified by:
setBlockName
in classSwiftBlock
- Parameters:
blockName
- the block name to set- Throws:
java.lang.IllegalArgumentException
- if parameter blockName is not the string "1"- Since:
- 5.0
-
getNumber
public java.lang.Integer getNumber()
Returns the block number (the value 1 as an integer)- Specified by:
getNumber
in classSwiftBlock
- Returns:
- Integer containing the block's number
-
getName
public java.lang.String getName()
Returns the block name (the value 1 as a string)- Specified by:
getName
in classSwiftBlock
- Returns:
- block name
- Since:
- 5.0
-
getApplicationId
public java.lang.String getApplicationId()
Gets the application ID field in block 1- Returns:
- application ID field in block 1
-
setApplicationId
public void setApplicationId(java.lang.String applicationId)
Sets the applicationId- Parameters:
applicationId
- String of 1 character containing the Application ID (F, A or L)
-
getServiceId
public java.lang.String getServiceId()
Gets the service ID field in block 1- Returns:
- service ID field in block 1
-
setServiceId
public void setServiceId(java.lang.String serviceId)
Sets the Service ID- Parameters:
serviceId
- string of 2 characters containing Service ID (01, 02, 03, etc...)
-
setSender
public void setSender(java.lang.String sender)
Sets the logical terminal address from the parameter BIC.If the LT identifier is not provided, "A" will be set as default. If the branch code is not provided XXX will be used as default.
The implementation assumes the message is outgoing, and if the full logical terminal address is provided with an "X" as LT identifier, it wil be replaced by and "A".
- Parameters:
sender
- a BIC8, BIC11 or full 12 character length logical terminal address- Since:
- 6.4
- See Also:
setLogicalTerminal(LogicalTerminalAddress)
-
getBIC
public BIC getBIC()
Gets the BIC code from the LT address.- Returns:
- the BIC object
- Since:
- 7.6
-
getLogicalTerminal
public java.lang.String getLogicalTerminal()
Gets the The Logical Terminal address of the sender for messages sent or the receiver for messages received from the SWIFT network.- Returns:
- the 12 characters logical terminal address
-
setLogicalTerminal
public void setLogicalTerminal(java.lang.String logicalTerminal)
Sets the The Logical Terminal address with the parameter as it is given without any modification.Beware for an outgoing message the LT identifier cannot be X and the branch code must be padded with XXX if not present in the BIC address. The complete logical terminal address must always be a 12 characters length alphanumeric string
- Parameters:
logicalTerminal
- should be a fixed at 12 character length string; with the BIC address, LT identifier and branch code.
-
setLogicalTerminal
public void setLogicalTerminal(LogicalTerminalAddress logicalTerminal)
Sets the LT address.
The implementation assumes the message is outgoing, and will tamper the LT identifier if necessary (changing an "X" LT identifier by and "A").
- Parameters:
logicalTerminal
- the logical terminal address to set- Since:
- 7.6
- See Also:
LogicalTerminalAddress.getSenderLogicalTerminalAddress()
-
setLogicalTerminal
public void setLogicalTerminal(BIC bic)
Sets the logical terminal address from the parameter BIC code with "A" as default LT identifier and XXX as default branch code.- Parameters:
bic
- a BIC code- Since:
- 7.6
- See Also:
setLogicalTerminal(LogicalTerminalAddress)
-
getSessionNumber
public java.lang.String getSessionNumber()
Gets the session number in block 1- Returns:
- session number in block 1
-
setSessionNumber
public void setSessionNumber(java.lang.String sessionNumber)
Sets the Session number. It is generated by the user's computer. As appropriate, the current application session number based on the Login. It is padded with zeros.- Parameters:
sessionNumber
- 4 numbers.
-
getSequenceNumber
public java.lang.String getSequenceNumber()
Gets the sequence number field in block 1- Returns:
- sequence number field in block 1
-
setSequenceNumber
public void setSequenceNumber(java.lang.String sequenceNumber)
Sets the Sequence number that is generated by the user's computer.
For all FIN messages with a Service Identifier of 01 or 05, this number is the next expected sequence number appropriate to the direction of the transmission.
For FIN messages with a Service Identifier of 21 or 25, the sequence number is that of the acknowledged service message.
It is padded with zeros.- Parameters:
sequenceNumber
- 6 numbers
-
isEmpty
public boolean isEmpty()
Tell if this block is empty or not. This block is considered to be empty if all its attributes are set to null.- Overrides:
isEmpty
in classSwiftValueBlock
- Returns:
true
if all fields are null and false in other case
-
getValue
public java.lang.String getValue()
Gets the fixed length block 1 value, as a result of concatenating its individual elements as follow:
Application ID Service ID + Logical terminal (LT) address + Session number + Sequence number.
Notice that this method does not return the "1:" string.- Overrides:
getValue
in classSwiftValueBlock
- Returns:
- the blocks value as a single string
-
setValue
public void setValue(java.lang.String value)
Sets the block's attributes by parsing the fixed length string argument.- Overrides:
setValue
in classSwiftValueBlock
- Parameters:
value
- a fixed length string containing the blocks' value (25 or 24 characters when '1:' is not indicated; 26 or 27 characters when starting string '1:' is included)- Throws:
java.lang.IllegalArgumentException
- if parameter is not between 24 and 27 characters.- See Also:
setValue(String, boolean)
-
getBlockValue
public java.lang.String getBlockValue()
Description copied from class:SwiftValueBlock
This method should be overwritten by subclasses, calling this method will throw ajava.lang.UnsupportedOperationException
- Overrides:
getBlockValue
in classSwiftValueBlock
- Returns:
- N/A
- See Also:
getValue()
-
setBlockValue
public void setBlockValue(java.lang.String value)
Description copied from class:SwiftValueBlock
This method should be overwritten by subclasses, calling this method will throw ajava.lang.UnsupportedOperationException
- Overrides:
setBlockValue
in classSwiftValueBlock
- Parameters:
value
- unused- See Also:
setValue(String)
-
setValue
public void setValue(java.lang.String value, boolean lenient)
Sets the block's attributes by parsing string argument with its content
This value can be in different flavors because some fields are optional.
For example "F01BANKBEBBAXXX2222123456" or "1:F01BANKBEBBAXXX2222123456".- Parameters:
value
- string containing the entire blocks valuelenient
- if true the value will be parsed with a best effort heuristic, if false it will throw a IllegalArgumentException if the value has an invalid total size
-
clean
public void clean()
Sets all attributes to null- Since:
- 6.4
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classSwiftBlock
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classSwiftBlock
-
toJson
public java.lang.String toJson()
Get a json representation of this object.Example:
{ "applicationId": "F", "serviceId": "01", "logicalTerminal": "FOOSEDR0AXXX", "sessionNumber": "0000", "sequenceNumber": "000000" }
- Returns:
- json representation
- Since:
- 7.5
-
field
public java.lang.String field(SwiftBlock1Field field)
Generic getter for block attributes based on qualified names fromSwiftBlock1Field
- Parameters:
field
- field to get- Returns:
- field value or null if attribute is not set
- Since:
- 7.7
-
setField
public void setField(SwiftBlock1Field field, java.lang.String value)
Generic setter for block attributes based on qualified names fromSwiftBlock1Field
- Parameters:
field
- field to setvalue
- content to set- Since:
- 7.8
-
getServiceIdType
public ServiceIdType getServiceIdType()
Maps the service id to the service id enumeration- Returns:
- the mapped enumeration or null if service id not present or cannot be mapped
- Since:
- 7.8.3
-
-