public class SwiftBlock1 extends SwiftValueBlock implements java.io.Serializable
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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
APPLICATION_ID_FIN
Constant for FIN messages in application id
|
static java.lang.String |
APPLICATION_ID_GPA
Constant for GPA (General Purpose Application) messages in application id
|
static java.lang.String |
APPLICATION_ID_LOGINS
Constant for Logins and so messages in application id
|
blockType, input, output, unparsedTexts
Constructor and Description |
---|
SwiftBlock1()
Default constructor
|
SwiftBlock1(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
|
SwiftBlock1(SwiftBlock1 block)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
void |
clean()
Sets all attributes to null
|
boolean |
equals(java.lang.Object o) |
java.lang.String |
field(SwiftBlock1Field field)
Generic getter for block attributes based on qualified names from
SwiftBlock1Field |
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 1
|
BIC |
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 a
java.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 1
|
java.lang.String |
getServiceId()
Gets the service ID field in block 1
|
ServiceIdType |
getServiceIdType()
Maps the service id to the service id enumeration
|
java.lang.String |
getSessionNumber()
Gets the session number in block 1
|
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. |
int |
hashCode() |
boolean |
isEmpty()
Tell if this block is empty or not.
|
void |
setApplicationId(java.lang.String applicationId)
Sets the applicationId
|
protected 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 a
java.lang.UnsupportedOperationException |
void |
setField(SwiftBlock1Field field,
java.lang.String value)
Generic setter for block attributes based on qualified names from
SwiftBlock1Field |
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 ID
|
void |
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.
|
getValuePart, getValuePart, size
getBlockType, getInput, getOutput, getUnparsedTexts, getUnparsedTextsSize, isTagBlock, setBlockType, setInput, setOutput, setUnparsedTexts, toString, unparsedTextAddText, unparsedTextAddText, unparsedTextGetAsMessage, unparsedTextGetText, unparsedTextIsMessage, unparsedTextVerify
public static final transient java.lang.String APPLICATION_ID_FIN
public static final transient java.lang.String APPLICATION_ID_GPA
public static final transient java.lang.String APPLICATION_ID_LOGINS
public SwiftBlock1(java.lang.String applicationId, java.lang.String serviceId, java.lang.String logicalTerminal, java.lang.String sessionNumber, java.lang.String sequenceNumber)
applicationId
- the application idserviceId
- the service idlogicalTerminal
- the logical terminal namesessionNumber
- the session numbersequenceNumber
- the message sequence numberpublic SwiftBlock1()
public SwiftBlock1(java.lang.String value)
value
- a fixed length string of 25 or 27 (which must start with '1:') characters containing the blocks valuejava.lang.IllegalArgumentException
- if parameter is not 25 or 27 charactersSwiftBlock1(String, boolean)
public SwiftBlock1(java.lang.String value, boolean lenient)
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 sizesetValue(String, boolean)
public SwiftBlock1(SwiftBlock1 block)
block
- an existing block1 to copypublic static SwiftBlock1 fromJson(java.lang.String json)
json
- json representationtoJson()
protected void setBlockNumber(java.lang.Integer blockNumber)
setBlockNumber
in class SwiftBlock
blockNumber
- the block number to setjava.lang.IllegalArgumentException
- if parameter blockName is not the integer 1protected void setBlockName(java.lang.String blockName)
setBlockName
in class SwiftBlock
blockName
- the block name to setjava.lang.IllegalArgumentException
- if parameter blockName is not the string "1"public java.lang.Integer getNumber()
getNumber
in class SwiftBlock
public java.lang.String getName()
getName
in class SwiftBlock
public java.lang.String getApplicationId()
public void setApplicationId(java.lang.String applicationId)
applicationId
- String of 1 character containing the Application ID (F, A or L)public java.lang.String getServiceId()
public void setServiceId(java.lang.String serviceId)
serviceId
- string of 2 characters containing Service ID (01, 02, 03, etc...)public void setSender(java.lang.String sender)
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".
sender
- a BIC8, BIC11 or full 12 character length logical terminal addresssetLogicalTerminal(LogicalTerminalAddress)
public BIC getBIC()
public java.lang.String getLogicalTerminal()
public void setLogicalTerminal(java.lang.String logicalTerminal)
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
logicalTerminal
- should be a fixed at 12 character length string; with the BIC address, LT identifier and branch code.public void setLogicalTerminal(LogicalTerminalAddress logicalTerminal)
The implementation assumes the message is outgoing, and will tamper the LT identifier if necessary (changing an "X" LT identifier by and "A").
logicalTerminal
- the logical terminal address to setLogicalTerminalAddress.getSenderLogicalTerminalAddress()
public void setLogicalTerminal(BIC bic)
bic
- a BIC codesetLogicalTerminal(LogicalTerminalAddress)
public java.lang.String getSessionNumber()
public void setSessionNumber(java.lang.String sessionNumber)
sessionNumber
- 4 numbers.public java.lang.String getSequenceNumber()
public void setSequenceNumber(java.lang.String sequenceNumber)
sequenceNumber
- 6 numberspublic boolean isEmpty()
isEmpty
in class SwiftValueBlock
true
if all fields are null and false in other casepublic java.lang.String getValue()
getValue
in class SwiftValueBlock
public void setValue(java.lang.String value)
setValue
in class SwiftValueBlock
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)java.lang.IllegalArgumentException
- if parameter is not between 24 and 27 characters.setValue(String, boolean)
public java.lang.String getBlockValue()
SwiftValueBlock
java.lang.UnsupportedOperationException
getBlockValue
in class SwiftValueBlock
getValue()
public void setBlockValue(java.lang.String value)
SwiftValueBlock
java.lang.UnsupportedOperationException
setBlockValue
in class SwiftValueBlock
value
- unusedsetValue(String)
public void setValue(java.lang.String value, boolean lenient)
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 sizepublic void clean()
public boolean equals(java.lang.Object o)
equals
in class SwiftBlock
public int hashCode()
hashCode
in class SwiftBlock
public java.lang.String toJson()
Example:
{ "applicationId": "F", "serviceId": "01", "logicalTerminal": "FOOSEDR0AXXX", "sessionNumber": "0000", "sequenceNumber": "000000" }
public java.lang.String field(SwiftBlock1Field field)
SwiftBlock1Field
field
- field to getpublic void setField(SwiftBlock1Field field, java.lang.String value)
SwiftBlock1Field
field
- field to setvalue
- content to setpublic ServiceIdType getServiceIdType()