public class Tag extends Object implements Serializable
null
;
Multiline tags are read with readline, so while swift defines \r\n to be the line terminator, the parser accepts a more wide range of line terminations. The values are stored in swift line terminators, that is always \r\n, so be aware that if a multiline field is separated with \n parse will be successfully but the returned value will be separated by \r\n
Instances of this class may have a list of unparsed texts (UnparsedTextList).
For easy access, methods have been created that first ensure the lists exists (the
real object is created and then call the base method).
However, not all the base list methods have been implemented. If you need to use not
exposed functionality, retrieve the underlying list with (see getUnparsedTexts method)
Modifier and Type | Field and Description |
---|---|
protected Long |
id
Unique identified when this tag is a persisted element
|
protected String |
name
Name of the tag, usually a number that may be followed by a letter.
|
protected SequenceNode |
sequence
Reference to the sequence node, if any, that this tags belongs to.
|
protected Integer |
sortKey
Indicates the position of this tag in a message when persisted.
|
protected UnparsedTextList |
unparsedTexts
List of unparsed texts.
|
protected String |
value
Value of the corresponding tag.
|
Constructor and Description |
---|
Tag()
Default constructor
|
Tag(String inner)
Create a tag from the value in inner.
|
Tag(String tagname,
String value)
Create a tag with the given tagname and value
|
Tag(String tagname,
String value,
UnparsedTextList unparsedText)
Constructor for tag name and value and an unparsed text list
|
Tag(String inner,
UnparsedTextList unparsedText)
Constructor for tag encoded value and an unparsed text list
|
Tag(UnparsedTextList unparsedText)
Constructor for an unparsed text list
|
Modifier and Type | Method and Description |
---|---|
Field |
asField() |
boolean |
contains(String... values)
Tell if this tag value contains any of the given values.
|
boolean |
contains(String searchStr)
equivalent to StringUtils.contains(tag.getValue(), searchStr)
|
boolean |
equals(Object obj)
Notice two tags with multiple lines as value, one using CRLF characters as line feed
and the other using just a LF character will not be reported as equals.
|
boolean |
equalsIgnoreCR(Tag other)
Similar to
equals(Object) but ignoring carriage returns characters in tag values. |
Field |
getField() |
Long |
getId()
Get the unique identifier of the tag if it is persisted
|
String |
getLetterOption()
Iterate the current tagname and return only letters as told by
Character.isLetter(char) |
String |
getName()
Get the name of this tag
|
int |
getNameAsInt()
Attempt to parse the tag name as an integer.
|
Integer |
getNumber()
Iterate the current tagname and return only number as told by
Character.isDigit(char) |
Integer |
getSortKey()
get the sortkey of this tag
|
UnparsedTextList |
getUnparsedTexts()
returns the unparsed text list
|
Integer |
getUnparsedTextsSize()
returns the size of the unparsed text list
|
String |
getValue()
Get the value of the tag.
Notice that in some cases the value can be null, for example the value of the "DLM" tag in this block: {5:{CHK:F9351591947F}{SYS:1610010606VNDZBET2AXXX0019000381}{DLM:}} |
int |
hashCode() |
boolean |
isNumber(int n)
Tells if this tagname is a given number, so the integer 58 will match 58A and 58D.
|
void |
setId(Long id)
Set the unique identifier of the tag if it is persisted
|
void |
setName(String name)
Set the tag name
|
void |
setNameValue(String name,
String value)
Shorthand equivalent to calling first
setName(String) and then setValue(String) |
void |
setSortKey(Integer sortKey)
Set the sortkey of this tag.
|
void |
setUnparsedTexts(UnparsedTextList texts)
sets the list of unparsed texts
|
void |
setValue(String value)
Sets the value of this tag.
|
boolean |
startsWith(String prefix)
equivalent to StringUtils.startsWith(tag.getValue(), prefix)
|
String |
toString() |
void |
unparsedTextAddText(String text)
adds a new unparsed text
|
void |
unparsedTextAddText(SwiftMessage message)
adds a new unparsed text from a message
|
SwiftMessage |
unparsedTextGetAsMessage(Integer index)
get an unparsed text as a parsed swift message
|
String |
unparsedTextGetText(Integer index)
get an unparsed text
|
Boolean |
unparsedTextIsMessage(Integer index)
decides if a specific text (by index) is likely a SWIFT FIN message.
|
protected void |
unparsedTextVerify()
verifies that the unparsed text list exists
|
protected Long id
protected Integer sortKey
protected String name
null
.protected String value
protected UnparsedTextList unparsedTexts
protected transient SequenceNode sequence
public Tag()
public Tag(String inner)
null
(useful for bloc data)
"" -> name=null, value=null
"foo" -> name=null, value=foo
":foo" -> name=null, value=foo
"foo:" -> name=foo, value=null
"foo:bar" -> name=foo, value=bar
inner
- the string to build the tagIllegalArgumentException
- if inner is null
public Tag(String tagname, String value)
tagname
- name of this tagvalue
- the value of this tagIllegalArgumentException
- if parameter tagname or value are null
public Tag(UnparsedTextList unparsedText)
unparsedText
- the list of unparsed textsTag()
public Tag(String inner, UnparsedTextList unparsedText)
inner
- the string to build the tagunparsedText
- the list of unparsed textsIllegalArgumentException
- if parameter inner is null
Tag(String)
public Tag(String tagname, String value, UnparsedTextList unparsedText)
tagname
- name of this tagvalue
- the value of this tagunparsedText
- the list of unparsed textsIllegalArgumentException
- if parameter tagname or value are null
Tag(String,String)
public String getName()
public void setName(String name)
name
- the name of the tag to be setIllegalArgumentException
- if parameter name is null
public String getValue()
null
if the value was not setpublic void setValue(String value)
value
- the value for the tag, may be null
public Long getId()
null
if it is not a persistent objectpublic void setId(Long id)
id
- the id to be setsortKey
public Integer getSortKey()
sortKey
public void setSortKey(Integer sortKey)
sortKey
- the new sortkeyprotected void unparsedTextVerify()
public UnparsedTextList getUnparsedTexts()
public void setUnparsedTexts(UnparsedTextList texts)
texts
- the new list of unparsed texts (may be null)public Integer getUnparsedTextsSize()
public Boolean unparsedTextIsMessage(Integer index)
index
- the unparsed text numberIllegalArgumentException
- if parameter index is null
IndexOutOfBoundsException
- if parameter index is out of boundspublic String unparsedTextGetText(Integer index)
index
- the unparsed text numberIllegalArgumentException
- if parameter index is null
IndexOutOfBoundsException
- if parameter index is out of boundspublic SwiftMessage unparsedTextGetAsMessage(Integer index)
index
- the unparsed text numberIllegalArgumentException
- if parameter index is null
public void unparsedTextAddText(String text)
text
- the unparsed text to appendIllegalArgumentException
- if parameter text is null
public void unparsedTextAddText(SwiftMessage message)
message
- the message to be appendedIllegalArgumentException
- if parameter message is null
public boolean equalsIgnoreCR(Tag other)
equals(Object)
but ignoring carriage returns characters in tag values.
Meaning CRLF in any of the tags will match both CRLF in the other tag and just LF in the other tagother
- another tag to comparepublic boolean equals(Object obj)
equals
in class Object
equalsIgnoreCR(Tag)
public int getNameAsInt()
public boolean isNumber(int n)
n
- the number that this tagname will be compared totrue
if this tagname starts with the given number or false
in any other casepublic Integer getNumber()
Character.isDigit(char)
null
if no digits are foundpublic String getLetterOption()
Character.isLetter(char)
null
if no letters are foundpublic Field getField()
Field.getField(Tag)
public boolean contains(String... values)
StringUtils.contains(String,String)
values
- variable list of values to testtrue
if the value of this tag is one of the given values.
returns false
in any other case, including a null or empty list of valuespublic void setNameValue(String name, String value)
setName(String)
and then setValue(String)
name
- the tagnamevalue
- the tagvaluepublic boolean startsWith(String prefix)
public boolean contains(String searchStr)
StringUtils.contains(String, String)
public Field asField()
null
if an error occurs