Package com.prowidesoftware.swift.model
Class SwiftBlock2Output
- java.lang.Object
-
- com.prowidesoftware.swift.model.SwiftBlock
-
- com.prowidesoftware.swift.model.SwiftValueBlock
-
- com.prowidesoftware.swift.model.SwiftBlock2
-
- com.prowidesoftware.swift.model.SwiftBlock2Output
-
- All Implemented Interfaces:
java.io.Serializable
public class SwiftBlock2Output extends SwiftBlock2 implements java.io.Serializable
Base class for SWIFT Application Header Block (block 2) for OUTPUT (from SWIFT).
This block is used to construct messages that have been output from the SWIFT network. From the application point of view, it correspond to the RECEIVED messages.
It's value is fixed-length and continuous with no field delimiters. This class contains its elements as individual attributes for easier management of the block value.
For a received message, a message being output from SWIFT, the SwiftBlock2Output includes explicit information regarding the MIR. This is sometimes confusing because it is an output block with an input reference. The important thing to understand here is that the MIR information is related to the original sender of the message that has been received. The attributes of this header (block 2 output) are explicitly documented as MIR information by SWIFT.
The MOR itself could be created combining information from block 1 and 2 but it usually does not make sense.
- Since:
- 4.0
- See Also:
MIR
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.prowidesoftware.swift.model.SwiftBlock2
SwiftBlock2.MessagePriority
-
-
Field Summary
-
Fields inherited from class com.prowidesoftware.swift.model.SwiftBlock2
messagePriority, messageType
-
Fields inherited from class com.prowidesoftware.swift.model.SwiftBlock
blockType, input, output, unparsedTexts
-
-
Constructor Summary
Constructors Constructor Description SwiftBlock2Output()
Default ConstructorSwiftBlock2Output(SwiftBlock2Output block)
Copy constructorSwiftBlock2Output(java.lang.String value)
Creates the block with lenient false, meaning it expects a fixed length value.SwiftBlock2Output(java.lang.String value, boolean lenient)
Creates a block 2 output object setting attributes by parsing the string argument containing the blocks value.SwiftBlock2Output(java.lang.String messageType, java.lang.String senderInputTime, java.lang.String MIRDate, java.lang.String MIRLogicalTerminal, java.lang.String MIRSessionNumber, java.lang.String MIRSequenceNumber, java.lang.String receiverOutputDate, java.lang.String receiverOutputTime, java.lang.String messagePriority)
Constructor for specific values
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.lang.String
field(SwiftBlock2OutputField field)
Generic getter for block attributes based on qualified names fromSwiftBlock2OutputField
static SwiftBlock2Output
fromJson(java.lang.String json)
This method deserializes the JSON data into an incoming (output) block 2 object.java.lang.String
getBlockValue()
This method should be overwritten by subclasses, calling this method will throw ajava.lang.UnsupportedOperationException
java.lang.String
getMIR()
Gets the full MIR (Message Input Reference) string of 28 characters containing the sender's date, LT address, session and sequence:
for example YYMMDDBANKBEBBAXXX2222123456java.lang.String
getMIRDate()
Gets the date the sender sent the message to SWIFT, from the MIR field, in the format YYMMDDjava.lang.String
getMIRLogicalTerminal()
Gets the the full LT address of the sender of the message, from the MIR field, for example: BANKBEBBAXXXjava.lang.String
getMIRSequenceNumber()
Gets the date the sender sequence number, from the MIR field, in the format NNNNNNjava.lang.String
getMIRSessionNumber()
Gets the date the sender session number, from the MIR field, in the format NNNNjava.lang.String
getReceiverOutputDate()
Gets the Output date local to the receiverjava.lang.String
getReceiverOutputTime()
Gets the Output time local to the receiver, written in the following format: HHMMBIC
getSenderBIC()
Gets the sender's BIC code.
For output message the sender address is contained in this block2 and not in the header block 1 as for input messages.java.lang.String
getSenderInputTime()
Returns the input time with respect to the senderjava.lang.String
getValue()
Gets the fixed length block 2 value, as a result of concatenating its individual elements as follow:
Message Type + Sender Input Time + MIR + Receiver Output Date + Receiver Output Time + Message Priority.int
hashCode()
boolean
isEmpty()
Tell if this block is empty or not.void
setBlockValue(java.lang.String value)
This method should be overwritten by subclasses, calling this method will throw ajava.lang.UnsupportedOperationException
void
setField(SwiftBlock2OutputField field, java.lang.String value)
Generic setter for block attributes based on qualified names fromSwiftBlock2OutputField
void
setMIR(java.lang.String mir)
Sets the full MIR (Message Input Reference) from a fixed length (28 characters) string containing the complete MIR value.void
setMIR(java.lang.String mir, boolean lenient)
Sets the MIR (Message Input Reference) attributes by parsing the string argument containing the complete MIR value.
For example YYMMDDBANKBEBBAXXX2222123456void
setMIRDate(java.lang.String MIRDate)
Sets the date the sender sent the message to SWIFT, from the MIR fieldvoid
setMIRDate(java.util.Calendar cal)
Sets the date the sender sent the message to SWIFT, from the MIR fieldvoid
setMIRLogicalTerminal(LogicalTerminalAddress MIRLogicalTerminal)
Sets the the full LT address of the sender of the message.void
setMIRLogicalTerminal(java.lang.String MIRLogicalTerminal)
Sets the the full LT address of the sender of the message.void
setMIRSequenceNumber(java.lang.String MIRSequenceNumber)
Sets the sequence number field of the MIRvoid
setMIRSessionNumber(java.lang.String MIRSessionNumber)
Sets the session number field of the MIRvoid
setReceiverOutputDate(java.lang.String receiverOutputDate)
Sets the Output date local to the receiver, written in the following format: YYMMDDvoid
setReceiverOutputDateTime(java.util.Calendar cal)
Sets the receiver output date and receiver output time fields from a Calendarvoid
setReceiverOutputTime(java.lang.String receiverOutputTime)
Sets the Output time local to the receiver, written in the following format: HHMMvoid
setSender(BIC bic)
Creates a full LT address using the parameter BIC code and a default LT identifier, and sets the resulting address as MIR logical terminal address.void
setSender(java.lang.String sender)
Completes if necessary and sets the LT address of the sender as MIR logical terminal address.
The sender addresses will be filled with proper default LT identifier and branch codes if not provided.void
setSenderInputTime(java.lang.String senderInputTime)
Sets the input time with respect to the sendervoid
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 the string argument containing the blocks value.
This value can be in different flavors because some fields are optional.
Example of supported values:-
Methods inherited from class com.prowidesoftware.swift.model.SwiftBlock2
clean, field, getMessagePriority, getMessagePriorityType, getMessageType, getName, getNumber, isInput, isOutput, setBlockName, setBlockNumber, setField, setMessagePriority, setMessageType, toJson, toString
-
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, unparsedTextAddText, unparsedTextAddText, unparsedTextGetAsMessage, unparsedTextGetText, unparsedTextIsMessage, unparsedTextVerify
-
-
-
-
Constructor Detail
-
SwiftBlock2Output
public SwiftBlock2Output(java.lang.String messageType, java.lang.String senderInputTime, java.lang.String MIRDate, java.lang.String MIRLogicalTerminal, java.lang.String MIRSessionNumber, java.lang.String MIRSequenceNumber, java.lang.String receiverOutputDate, java.lang.String receiverOutputTime, java.lang.String messagePriority)
Constructor for specific values- Parameters:
messageType
- the message typesenderInputTime
- the input timeMIRDate
- dateMIRLogicalTerminal
- logical terminalMIRSessionNumber
- session numberMIRSequenceNumber
- message sequence numberreceiverOutputDate
- receiver datereceiverOutputTime
- receiver timemessagePriority
- the message priority (S=system, U=urgent, N=normal)
-
SwiftBlock2Output
public SwiftBlock2Output(java.lang.String value)
Creates the block with lenient false, meaning it expects a fixed length value. Example of supported values:
"O1001200970103BANKBEBBAXXX22221234569701031201N" or "2:O1001200970103BANKBEBBAXXX22221234569701031201N"- Parameters:
value
- a fixed length string of 46 (starting with 'O') or 49 (starting with '2:O') characters containing the blocks value- Throws:
java.lang.IllegalArgumentException
- if parameter is not 47 or 49 characters- See Also:
SwiftBlock2Output(String, boolean)
-
SwiftBlock2Output
public SwiftBlock2Output(java.lang.String value, boolean lenient)
Creates a block 2 output object setting attributes by parsing the string argument containing the blocks value. This value can be in different flavors because some fields are optional.- 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)
-
SwiftBlock2Output
public SwiftBlock2Output()
Default Constructor
-
SwiftBlock2Output
public SwiftBlock2Output(SwiftBlock2Output block)
Copy constructor- Parameters:
block
- an existing block2 to copy- Since:
- 7.10.4
-
-
Method Detail
-
fromJson
public static SwiftBlock2Output fromJson(java.lang.String json)
This method deserializes the JSON data into an incoming (output) block 2 object.- Since:
- 7.9.8
- See Also:
SwiftBlock2.toJson()
-
getSenderInputTime
public java.lang.String getSenderInputTime()
Returns the input time with respect to the sender- Returns:
- 4 numbers HHMM
-
setSenderInputTime
public void setSenderInputTime(java.lang.String senderInputTime)
Sets the input time with respect to the sender- Parameters:
senderInputTime
- 4 numbers HHMM
-
getMIRDate
public java.lang.String getMIRDate()
Gets the date the sender sent the message to SWIFT, from the MIR field, in the format YYMMDD- Returns:
- String with 6 numbers
-
setMIRDate
public void setMIRDate(java.lang.String MIRDate)
Sets the date the sender sent the message to SWIFT, from the MIR field- Parameters:
MIRDate
- 6 numbers with date in format YYMMDD
-
setMIRDate
public void setMIRDate(java.util.Calendar cal)
Sets the date the sender sent the message to SWIFT, from the MIR field- Parameters:
cal
- the calendar to format date from- Since:
- 9.1.3
-
setSender
public void setSender(BIC bic)
Creates a full LT address using the parameter BIC code and a default LT identifier, and sets the resulting address as MIR logical terminal address.- Since:
- 7.6
- See Also:
setMIRLogicalTerminal(LogicalTerminalAddress)
-
setSender
public void setSender(java.lang.String sender)
Completes if necessary and sets the LT address of the sender as MIR logical terminal address.
The sender addresses will be filled with proper default LT identifier and branch codes if not provided.- Since:
- 7.6
- See Also:
setMIRLogicalTerminal(LogicalTerminalAddress)
-
getMIRLogicalTerminal
public java.lang.String getMIRLogicalTerminal()
Gets the the full LT address of the sender of the message, from the MIR field, for example: BANKBEBBAXXX- Returns:
- LT address
-
setMIRLogicalTerminal
public void setMIRLogicalTerminal(java.lang.String MIRLogicalTerminal)
Sets the the full LT address of the sender of the message.- Parameters:
MIRLogicalTerminal
- 12 characters full LT address
-
setMIRLogicalTerminal
public void setMIRLogicalTerminal(LogicalTerminalAddress MIRLogicalTerminal)
Sets the the full LT address of the sender of the message.- Parameters:
MIRLogicalTerminal
- 12 characters full LT address- Since:
- 7.6
- See Also:
LogicalTerminalAddress.getSenderLogicalTerminalAddress()
-
getSenderBIC
public BIC getSenderBIC()
Gets the sender's BIC code.
For output message the sender address is contained in this block2 and not in the header block 1 as for input messages.- Returns:
- sender BIC address
- Since:
- 7.6
- See Also:
BIC
-
getMIRSessionNumber
public java.lang.String getMIRSessionNumber()
Gets the date the sender session number, from the MIR field, in the format NNNN- Returns:
- 4 numbers
-
setMIRSessionNumber
public void setMIRSessionNumber(java.lang.String MIRSessionNumber)
Sets the session number field of the MIR- Parameters:
MIRSessionNumber
- 4 numbers
-
getMIRSequenceNumber
public java.lang.String getMIRSequenceNumber()
Gets the date the sender sequence number, from the MIR field, in the format NNNNNN- Returns:
- 6 numbers
-
setMIRSequenceNumber
public void setMIRSequenceNumber(java.lang.String MIRSequenceNumber)
Sets the sequence number field of the MIR- Parameters:
MIRSequenceNumber
- 6 numbers
-
getMIR
public java.lang.String getMIR()
Gets the full MIR (Message Input Reference) string of 28 characters containing the sender's date, LT address, session and sequence:
for example YYMMDDBANKBEBBAXXX2222123456- Returns:
- a String with MIR, returns null if all MIR components are null
-
setMIR
public void setMIR(java.lang.String mir)
Sets the full MIR (Message Input Reference) from a fixed length (28 characters) string containing the complete MIR value.- Parameters:
mir
- complete MIR string value, a fixed length (28 characters) string containing the MIR value- Throws:
java.lang.IllegalArgumentException
- if parameter has an invalid total size.- See Also:
setMIR(String, boolean)
-
setMIR
public void setMIR(java.lang.String mir, boolean lenient)
Sets the MIR (Message Input Reference) attributes by parsing the string argument containing the complete MIR value.
For example YYMMDDBANKBEBBAXXX2222123456- Parameters:
mir
- complete MIR stringlenient
- 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
-
getReceiverOutputDate
public java.lang.String getReceiverOutputDate()
Gets the Output date local to the receiver- Returns:
- 6 characters in format YYMMDD
-
setReceiverOutputDate
public void setReceiverOutputDate(java.lang.String receiverOutputDate)
Sets the Output date local to the receiver, written in the following format: YYMMDD- Parameters:
receiverOutputDate
- 6 characters in format YYMMDD
-
getReceiverOutputTime
public java.lang.String getReceiverOutputTime()
Gets the Output time local to the receiver, written in the following format: HHMM- Returns:
- String with 4 numbers
-
setReceiverOutputTime
public void setReceiverOutputTime(java.lang.String receiverOutputTime)
Sets the Output time local to the receiver, written in the following format: HHMM- Parameters:
receiverOutputTime
- String with 4 numbers
-
setReceiverOutputDateTime
public void setReceiverOutputDateTime(java.util.Calendar cal)
Sets the receiver output date and receiver output time fields from a Calendar- Parameters:
cal
- the calendar to format date and time from- Since:
- 9.1.3
-
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 2 value, as a result of concatenating its individual elements as follow:
Message Type + Sender Input Time + MIR + Receiver Output Date + Receiver Output Time + Message Priority.- 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 (between 46 and 49) string containing the blocks' value- Throws:
java.lang.IllegalArgumentException
- if parameter has an invalid total size.- 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 the string argument containing the blocks value.
This value can be in different flavors because some fields are optional.
Example of supported values:
"O1001200970103BANKBEBBAXXX22221234569701031201" (46) or "2:O1001200970103BANKBEBBAXXX22221234569701031201" (48) // used for service/system messages "O1001200970103BANKBEBBAXXX22221234569701031201N" (47) or "2:O1001200970103BANKBEBBAXXX22221234569701031201N" (49)
- 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
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classSwiftBlock2
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classSwiftBlock2
-
field
public java.lang.String field(SwiftBlock2OutputField field)
Generic getter for block attributes based on qualified names fromSwiftBlock2OutputField
- Parameters:
field
- field to get- Returns:
- field value or null if attribute is not set
- Since:
- 7.7
-
setField
public void setField(SwiftBlock2OutputField field, java.lang.String value)
Generic setter for block attributes based on qualified names fromSwiftBlock2OutputField
- Parameters:
field
- field to getvalue
- content to set- Since:
- 7.8
-
-