public class UnparsedTextList
extends java.lang.Object
implements java.io.Serializable
List of unparsed texts for messages, blocks or tags.
For performance reasons, the
unparsed texts are stored directly as strings inside this list object. The need then
for this object (as opposed to directly using a List) is for some functionality
aggregation, specially if you consider that the same is used in all levels of the
message structure.
It is expected that classes that use this object do not create unnecessary instances of this (also for performance reasons). The motive become obvious when you consider that an average SWIFT message will have 4 blocks (1, 2, 3 and 4) and that block 4 will have at least 20 tags (so the count of instances of this will be: 1 for the message, 4 for the blocks and 20 for the tags, giving 25). For more complex messages, the number is near linear with the number of tags, while at the same time, most of those messages will have no unparsed texts.
For this, it is expected that the message, block and tag objects will have some convenience methods to access this class methods only if they have a valid object.
This class will be used in four different scenarios:
1) SERVICE MESSAGES (for example: ACK)
It's been reported that Swift Alliance Access appends the original message to the ACK on delivery. In this case, the appended original message will be attached to the ACK as an unparsed text
2) SOME SYSTEM MESSAGES (for example: MT 021, Retrieval Response)
In this case, as per documentation, the retrieved message is appended in block 4, after the tags of the message. In this case, the original (retrieved) message is appended to block 4 as an unparsed text.
3) SOME REPORT MESSAGES (for example: MT 056, LT History Report)
In this case, complete messages (one or more) are appended to a tag value. An example of this is MT 056 (LT History Report) where the original login request and the associated login response (optional) are appended to TAG 270 value. Here, two unparsed texts are appended to tag 270 of the parsed message.
4) USER DEFINED BLOCKS
As part of the user defined blocks support, we have decided to append the (complete) original block text as an unparsed text to the User Block (class SwiftBlockUser) to allow for some degree of liberty regarding data encoding in these blocks (however, these user defined blocks where designed considering that they behave as standard block 3 or 5.
Constructor and Description |
---|
UnparsedTextList()
Default Constructor
|
UnparsedTextList(java.util.Collection<java.lang.String> texts)
Constructor from a collection of texts
|
Modifier and Type | Method and Description |
---|---|
void |
addText(java.lang.String text)
adds a new unparsed text
|
void |
addText(SwiftMessage message)
adds a new unparsed text from a message
|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getAsFINString()
gets as FIN string, conforming a String object with the concatenation of the unparsed texts.
|
java.lang.Long |
getId()
Get the unique identifier of this unparsed text list or
null if it is not set |
java.lang.String |
getText(java.lang.Integer index)
get an unparsed text
|
SwiftMessage |
getTextAsMessage(java.lang.Integer index)
get an unparsed text as a parsed swift message
|
java.util.List<java.lang.String> |
getTexts()
returns the full list of unparsed texts
|
int |
hashCode() |
java.lang.Boolean |
isMessage(java.lang.Integer index)
decides if a specific text (by index) is likely a SWIFT FIN message.
|
static java.lang.Boolean |
isMessage(java.lang.String text)
decides if it is likely that an unparsed text is a SWIFT FIN message.
It is considered that a text it is likely to be message if it contains the text "{1:". |
void |
removeText(int index)
removes an unparsed text
|
void |
removeText(java.lang.Integer index)
removes an unparsed text
|
void |
removeText(java.lang.String text)
removes an unparsed text
|
void |
setId(java.lang.Long id)
Sets the unique identifier of this unparsed text list
|
protected void |
setTexts(java.util.List<java.lang.String> texts)
Set the list of texts, the list must be a list of Strings or an empty list.
This method is mainly needed for persistence services. |
java.lang.Integer |
size()
get the number of unparsed texts
|
java.lang.String |
toString()
convert this to string
|
public UnparsedTextList()
public UnparsedTextList(java.util.Collection<java.lang.String> texts)
texts
- the list of unparsed texts to setjava.lang.IllegalArgumentException
- if parameter texts is null
java.lang.IllegalArgumentException
- if parameter texts has elements of class other than Stringpublic void addText(java.lang.String text)
text
- the unparsed text to appendjava.lang.IllegalArgumentException
- if parameter text is null
public void addText(SwiftMessage message)
message
- the message to be appendedjava.lang.IllegalArgumentException
- if parameter message is null
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String getAsFINString()
public java.lang.Long getId()
null
if it is not setpublic java.lang.String getText(java.lang.Integer index)
index
- the unparsed text numberjava.lang.IllegalArgumentException
- if parameter index is null
java.lang.IndexOutOfBoundsException
- if parameter index is out of boundspublic SwiftMessage getTextAsMessage(java.lang.Integer index)
index
- the unparsed text numberjava.lang.IllegalArgumentException
- if parameter index is null
java.lang.IndexOutOfBoundsException
- if parameter index is out of boundspublic java.util.List<java.lang.String> getTexts()
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.Boolean isMessage(java.lang.Integer index)
index
- the unparsed text numberjava.lang.IllegalArgumentException
- if parameter index is null
java.lang.IndexOutOfBoundsException
- if parameter index is out of boundspublic static java.lang.Boolean isMessage(java.lang.String text)
text
- the text to analyzepublic void removeText(int index)
index
- the index of the text to removejava.lang.IndexOutOfBoundsException
- if parameter index is out of boundspublic void removeText(java.lang.Integer index)
index
- the index of the text to removejava.lang.IllegalArgumentException
- if parameter index is null
java.lang.IndexOutOfBoundsException
- if parameter index is out of boundspublic void removeText(java.lang.String text)
text
- the text value to remove (uses equals)java.lang.IllegalArgumentException
- if parameter text is null
public void setId(java.lang.Long id)
id
- the unique identifier to set.protected void setTexts(java.util.List<java.lang.String> texts)
texts
- the list of unparsed texts to setjava.lang.IllegalArgumentException
- if parameter texts is null
java.lang.IllegalArgumentException
- if parameter texts has elements of class other than Stringpublic java.lang.Integer size()
public java.lang.String toString()
toString
in class java.lang.Object