com.prowidesoftware.swift.model
Class UnparsedTextList

java.lang.Object
  extended by com.prowidesoftware.swift.model.UnparsedTextList
All Implemented Interfaces:
java.io.Serializable

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.

Since:
5.0
Version:
$Id: UnparsedTextList.java,v 1.1.1.1 2013/04/10 17:04:50 mgriffa Exp $
Author:
www.prowidesoftware.com
See Also:
Serialized Form

Constructor Summary
UnparsedTextList()
          Default Constructor
UnparsedTextList(java.util.Collection<java.lang.String> texts)
          Constructor from a collection of texts
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnparsedTextList

public UnparsedTextList()
Default Constructor


UnparsedTextList

public UnparsedTextList(java.util.Collection<java.lang.String> texts)
Constructor from a collection of texts

Parameters:
texts - the list of unparsed texts to set
Throws:
java.lang.IllegalArgumentException - if parameter texts is null
java.lang.IllegalArgumentException - if parameter texts has elements of class other than String
Method Detail

getId

public java.lang.Long getId()
Get the unique identifier of this unparsed text list or null if it is not set

Returns:
the unique identifier

setId

public void setId(java.lang.Long id)
Sets the unique identifier of this unparsed text list

Parameters:
id - the unique identifier to set.

getAsFINString

public java.lang.String getAsFINString()
gets as FIN string, conforming a String object with the concatenation of the unparsed texts.

Returns:
String concatenation of the unparsed texts

toString

public java.lang.String toString()
convert this to string

Overrides:
toString in class java.lang.Object

isMessage

public 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:".

Parameters:
text - the text to analyze
Returns:
true if the text is likely to be a SWIFT message

getTexts

public java.util.List<java.lang.String> getTexts()
returns the full list of unparsed texts

Returns:
the list of texts

setTexts

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.

Parameters:
texts - the list of unparsed texts to set
Throws:
java.lang.IllegalArgumentException - if parameter texts is null
java.lang.IllegalArgumentException - if parameter texts has elements of class other than String
Since:
5.0

size

public java.lang.Integer size()
get the number of unparsed texts

Returns:
the number of unparsed texts

isMessage

public java.lang.Boolean isMessage(java.lang.Integer index)
decides if a specific text (by index) is likely a SWIFT FIN message. Exceptions are inherited from base implementation methods.

Parameters:
index - the unparsed text number
Returns:
true if the text at position index is likely to be a SWIFT message
Throws:
java.lang.IllegalArgumentException - if parameter index is null
java.lang.IndexOutOfBoundsException - if parameter index is out of bounds

getText

public java.lang.String getText(java.lang.Integer index)
get an unparsed text

Parameters:
index - the unparsed text number
Returns:
the requested text
Throws:
java.lang.IllegalArgumentException - if parameter index is null
java.lang.IndexOutOfBoundsException - if parameter index is out of bounds

getTextAsMessage

public SwiftMessage getTextAsMessage(java.lang.Integer index)
get an unparsed text as a parsed swift message

Parameters:
index - the unparsed text number
Returns:
the text at position index parsed into a SwiftMessage object
Throws:
java.lang.IllegalArgumentException - if parameter index is null
java.lang.IndexOutOfBoundsException - if parameter index is out of bounds

addText

public void addText(java.lang.String text)
adds a new unparsed text

Parameters:
text - the unparsed text to append
Throws:
java.lang.IllegalArgumentException - if parameter text is null

addText

public void addText(SwiftMessage message)
adds a new unparsed text from a message

Parameters:
message - the message to be appended
Throws:
java.lang.IllegalArgumentException - if parameter message is null

removeText

public void removeText(java.lang.Integer index)
removes an unparsed text

Parameters:
index - the index of the text to remove
Throws:
java.lang.IllegalArgumentException - if parameter index is null
java.lang.IndexOutOfBoundsException - if parameter index is out of bounds

removeText

public void removeText(int index)
removes an unparsed text

Parameters:
index - the index of the text to remove
Throws:
java.lang.IndexOutOfBoundsException - if parameter index is out of bounds

removeText

public void removeText(java.lang.String text)
removes an unparsed text

Parameters:
text - the text value to remove (uses equals)
Throws:
java.lang.IllegalArgumentException - if parameter text is null

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object