public abstract class AbstractMT extends Object
AbstractMX
Modifier and Type | Field and Description |
---|---|
protected SwiftMessage |
m |
Constructor and Description |
---|
AbstractMT()
Creates a particular MT initialized with a new SwiftMessage.
|
AbstractMT(int messageType)
Create an input message for the given type setting TEST BICS as sender and receiver.
All mandatory header attributes are completed with default values. |
AbstractMT(int messageType,
String sender,
String receiver)
Creates a new input message for the given type setting the given sender and receiver.
All mandatory header attributes are completed with default values. |
AbstractMT(MtSwiftMessage m)
Deprecated.
use constructor from subclasses instead
|
AbstractMT(SwiftMessage m) |
Modifier and Type | Method and Description |
---|---|
void |
addField(Field f)
Adds the given field to the body block.
|
AbstractMT |
append(Field... fields)
Add all the fields to the end of the block4
|
AbstractMT |
append(SwiftTagListBlock block)
Add all tags from block to the end of the block4
|
AbstractMT |
append(Tag... tags)
Add all tags to the end of the block4
|
static AbstractMT |
create(int messageType)
Create a blank message for the given category setting TEST bics as sender and receiver
|
static AbstractMT |
create(int messageType,
String sender,
String receiver)
Create a blank message for the given category setting the given sender and receiver BICs
|
String |
FIN()
Deprecated.
use
message() instead of this |
String |
getApplicationId() |
String |
getLogicalTerminal() |
String |
getMessagePriority() |
abstract String |
getMessageType()
Returns this MT number
|
String |
getReceiver()
Gets the message receiver BIC from the message headers.
|
String |
getSender()
Gets the message sender BIC from the message headers.
|
SwiftTagListBlock |
getSequence(String name)
Convenience method to get a sequence named
name from this message without creating the MTXXX class. |
static SwiftTagListBlock |
getSequence(SwiftMessage msg,
String sequence)
Get the given sequence from the msg
|
List<SwiftTagListBlock> |
getSequenceList(String name)
Convenience method to get the list of sequences named
name from this message without creating the MTXXX class. |
String |
getSequenceNumber() |
String |
getServiceId() |
String |
getSessionNumber() |
SwiftMessage |
getSwiftMessage() |
protected SwiftMessage |
getSwiftMessageNotNullOrException()
Get the swift message guaranteeing a non null return.
|
boolean |
isInput() |
boolean |
isOutput() |
boolean |
isType(Integer type)
Returns true if the message is the same type as the indicated by parameter.
|
String |
json()
Returns the JSON representation of this message.
|
String |
message()
Get this message as string containing the FIN message (SWIFT MT message).
|
static AbstractMT |
parse(File file)
Parses a the file content into the MTxxx that corresponds to the found message type.
|
static AbstractMT |
parse(InputStream stream)
Parses a the stream content into the MTxxx that corresponds to the found message type.
|
static AbstractMT |
parse(String fin)
Parses a the string content into the MTxxx that corresponds to the found message type.
|
protected static SwiftMessage |
read(String fin)
Base implementation for subclasses static parse.
|
void |
setReceiver(BIC bic)
Sets the logical terminal field of the application header block 2.
Notice this method only makes sense when building input messages (messages that are going to be sent to swift). |
void |
setReceiver(String receiver)
Sets the logical terminal field of the application header block 2.
|
void |
setSender(BIC bic)
Sets the logical terminal field of the header block 1 with the parameter BIC code and default LT identifier
(the message is assumed to be of type input).
Notice this method only makes sense when building input messages (messages that are going to be sent to swift). |
void |
setSender(String sender)
Sets the logical terminal field of the header block 1 (the message is assumed to be of type input).
|
void |
setSwiftMessage(SwiftMessage m) |
String |
toString() |
void |
write(File file)
Writes the message into a file with its message content in the FIN format.
|
void |
write(OutputStream stream)
Writes the message into a given output stream with its message content in the FIN format,
encoding content in UTF-8.
|
String |
xml()
Returns the message content in XML format.
The XML created is the internal format defined and used by Prowide Core. Notice: it is neither a standard nor the MX version of this MT. |
protected SwiftMessage m
public AbstractMT(SwiftMessage m)
m
- swift message to model as a particular MTpublic AbstractMT(MtSwiftMessage m)
m
- swift message to model as a particular MTpublic AbstractMT()
public AbstractMT(int messageType)
messageType
- AbstractMT(int, String, String)
public AbstractMT(int messageType, String sender, String receiver)
messageType
- message type to createsender
- the sender address as a bic8, bic11 or full logical terminal consisting of 12 charactersreceiver
- the receiver address as a bic8, bic11 or full logical terminal consisting of 12 characterspublic static AbstractMT parse(String fin) throws IOException
string
- a string containing a swift MT messageIOException
public static AbstractMT parse(InputStream stream) throws IOException
stream
- a stream containing a swift MT messageIOException
#parse(String)}
public static AbstractMT parse(File file) throws IOException
file
- a file containing a swift MT messageIOException
#parse(String)}
public SwiftMessage getSwiftMessage()
protected SwiftMessage getSwiftMessageNotNullOrException()
public void setSwiftMessage(SwiftMessage m)
m
- swift message to model as a particular MTpublic String getApplicationId()
SwiftBlock1#getApplicationId()
public String getServiceId()
SwiftBlock1#getServiceId()
public String getLogicalTerminal()
SwiftBlock1#getLogicalTerminal()
public String getSessionNumber()
SwiftBlock1#getSessionNumber()
public String getSequenceNumber()
SwiftBlock1#getSequenceNumber()
public String getMessagePriority()
SwiftBlock2.getMessagePriority()
public boolean isInput()
SwiftBlock2.isInput()
public boolean isOutput()
SwiftBlock2.isOutput()
public void setSender(String sender)
sender
- the sender address as a bic8, bic11 or full logical terminal consisting of 12 charactersSwiftBlock1#setSender(String)
public void setSender(BIC bic)
bic
- a BIC codeSwiftBlock1#setLogicalTerminal(BIC)
public String getSender()
public void setReceiver(String receiver)
receiver
- the sender address as a bic8, bic11 or full logical terminal consisting of 12 charactersSwiftBlock2Input.setReceiver(String)
public void setReceiver(BIC bic)
bic
- a BIC codeSwiftBlock2Input.setReceiver(String)
public String getReceiver()
public void addField(Field f)
f
- @Deprecated public String FIN()
message()
instead of thismessage()
So the same method can be used for both MT and MX
This method may be deleted in 2016message()
public String message()
public abstract String getMessageType()
public List<SwiftTagListBlock> getSequenceList(String name)
name
from this message without creating the MTXXX class.
getSequenceList("A")
is the same as
((CastToSpecificMT)getMT()).getSequenceAList()
The requested sequence must be repetitive for non repetitive sequences use getSequence(name)name
- getSequence(String)
public SwiftTagListBlock getSequence(String name)
name
from this message without creating the MTXXX class.
getSequence("A")
is the same as
((CastToSpecificMT)getMT()).getSequenceA()
The requested sequence must NOT be repetitive for repetitive sequences use getSequenceList(name)name
- getSequenceList(String)
public static AbstractMT create(int messageType)
messageType
- create(int, String, String)
public static AbstractMT create(int messageType, String sender, String receiver)
messageType
- sender
- receiver
- public AbstractMT append(SwiftTagListBlock block)
block
- public AbstractMT append(Tag... tags)
tags
- public AbstractMT append(Field... fields)
fields
- protected static SwiftMessage read(String fin)
public void write(File file) throws IOException
a
- non null file to write, if it does not exists, it will be createdIOException
public void write(OutputStream stream) throws IOException
a
- non null stream to writeIOException
public String json()
public String xml()
public boolean isType(Integer type)
type
- a three digits number indicating a SWIFT MT typepublic static SwiftTagListBlock getSequence(SwiftMessage msg, String sequence)
msg
- the message to extract the sequence fromsequence
- the sequence nameSwiftMessage.toMT()