public class SwiftTagListBlock extends SwiftBlock implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected java.util.List<Tag> |
tags
Contains instances of Tag in this block, used to store the block's fields.
|
blockType, id, input, output, unparsedTexts
Constructor and Description |
---|
SwiftTagListBlock()
Default constructor, shouldn't be used normally.
|
SwiftTagListBlock(java.util.List<Tag> tags)
Intended to be used by search results in this class
|
Modifier and Type | Method and Description |
---|---|
void |
add(Field f) |
void |
addTag(Tag t)
Adds a tag to this block.
|
void |
addTags(java.util.List<Tag> tags)
Add all tags in the List argument to the current blocks.
|
boolean |
containsAllOf(java.lang.String... name)
Tell if this block contains all of the given name tags.
|
boolean |
containsAnyOf(java.lang.String... name)
Tell if this block contains any of the given name tags.
|
boolean |
containsField(java.lang.String name)
Tell if this block contains a field with the given name supporting 'a' notation ie: 56a
|
boolean |
containsTag(int i)
Iterates the internal list of tags and returns true if there is at least one tag with the given number
i
This method is useful to search any variant of a tag
containsTag(58) will return true if there is any variant of 58A, 58D, or so. |
boolean |
containsTag(java.lang.String tagName)
Tells if this block contains a tag with the given name.
|
boolean |
containsTag(Tag t)
Iterates the internal list of tags and returns true if there is at least one tag equals to the given one.
|
int |
countAll()
Gets the amount of tags in this taglist
|
int |
countByName(java.lang.String tagname)
Counts how many tags with the given name are present in the block.
|
int |
countTagsStarsWith(java.lang.String name,
java.lang.String value)
Counts tags starting with the given value
|
boolean |
equals(java.lang.Object obj) |
SwiftTagListBlock |
filterByName(boolean include,
java.lang.String... names)
Returns a new block that includes (
true ) or excludes (false ), depending on includeOrExclude flag
all tags with names matching any of the parameter names.Once a tagname is matched, it is removed from the list of tags to be matched, causing to be only included/excluded the first instance of every tagname. For example: 1, 2, 3, 4, 5, 6 filter by names 2, 4, 5 will return 1, 3, 6. |
SwiftTagListBlock |
filterByNameOrdered(java.lang.String... names)
Returns a new block that includes all tags with names matching any of the parameter names until a non matching tag is found.
Once a tagname is matched, it is removed from the list of tags to be matched, causing to be only included/excluded the first instance of every tagname. For example: 1, 2, 3, 9, 4, 5, 6 filter by names 1, 2, 3, 4 will return 1, 2, 3. |
Field |
getField(int i)
shortcut to
getTag(int) .getField() |
Field |
getFieldByName(java.lang.String key)
Shortcut to
getTagByName(String) .getField() |
Field |
getFieldByNumber(int num) |
Field[] |
getFieldsByName(java.lang.String name)
Similar to
getTagsByName(String)
NOTE: supports 'a' wildcard. |
java.util.List<? extends Field> |
getFieldsByNumber(int i)
get all Fields of a given number.
|
java.lang.String |
getName()
Returns the block name (this method is to be overwritten for derived classes).
|
java.lang.Integer |
getNumber()
Returns the block number (this method is to be overwritten for derived classes).
|
SwiftTagListBlock |
getOptionalList(java.lang.String[][] optionalTags)
Search a secuence of optional tags.
|
SwiftTagListBlock |
getOptionalList(java.lang.String[][] optionalTags,
int startAt) |
java.util.List<SwiftTagListBlock> |
getOptionalLists(java.lang.String[][] optionalTags) |
SwiftTagListBlock |
getSubBlock(java.lang.Integer from,
java.lang.Integer to)
Analog to substring from to.
|
SwiftTagListBlock |
getSubBlock(java.lang.String blockName)
Gets all tags of a specific sub block, searching for the first occurrence of the starting 16R field (with blockName as value)
and its correspondent 16S field (with blockName as value).
|
SwiftTagListBlock |
getSubBlock(java.lang.String startTagName,
java.lang.String endTagName)
Get all tags between the first occurrence of the starting Tag name and the first occurrence of an optional ending Tag name.
|
SwiftTagListBlock |
getSubBlock(Tag start,
Tag end)
Get all tags between the first occurrence of the starting Tag and the first occurrence of an optional ending Tag.
|
SwiftTagListBlock |
getSubBlockAfterFirst(java.lang.String tagname)
Get a subblock after the first tag with the given tagname.
|
SwiftTagListBlock |
getSubBlockAfterLast(java.lang.String tagname,
boolean includeDelimiterInResult)
Get a new list with tags between the last instance of tag with tagname name found or null if the tag was not found
|
SwiftTagListBlock |
getSubBlockBeforeFirst(java.lang.String tagname,
boolean includeSeparator)
get a new list with all the tags found before the first tagname.
|
SwiftTagListBlock |
getSubBlockBeforeLast(java.lang.String tagname,
boolean includeDelimiterInResult) |
SwiftTagListBlock |
getSubBlockByIndex(java.lang.Integer startIndex,
java.lang.Integer endIndex)
Get the block containing the list of tags between the given indexes.
The implementation uses subList so the resulting List of tags will containing elements from the original List startIndex to endIndex - 1. |
SwiftTagListBlock |
getSubBlockDelimitedWithOptionalTail(java.lang.String[] start,
java.lang.String[] end,
java.lang.String[] tail)
Get the
|
java.util.List<SwiftTagListBlock> |
getSubBlocks(int startTagNumber,
int endTagNumber)
Get all sub blocks using the starting and ending Tag numbers as block boundaries (Tag values are ignored).
|
java.util.List<SwiftTagListBlock> |
getSubBlocks(int startTagNumber,
java.lang.String endTagName)
Get all sub blocks using the starting Tag number and ending Tag name as block boundaries (Tag values are ignored).
|
java.util.List<SwiftTagListBlock> |
getSubBlocks(java.lang.String blockName)
Gets all sub blocks with a specific name, using ISO 15022 FIN block structure definitions.
|
java.util.List<SwiftTagListBlock> |
getSubBlocks(java.lang.String startTagName,
int endTagNumber)
Get all sub blocks using the starting Tag name and ending Tag number as block boundaries (Tag values are ignored).
|
java.util.List<SwiftTagListBlock> |
getSubBlocks(java.lang.String startTagName,
java.lang.String endTagName)
Get all sub blocks using the starting and ending Tag names as block boundaries (Tag values are ignored).
|
java.util.List<SwiftTagListBlock> |
getSubBlocks(Tag start,
Tag end)
Get all sub blocks using the starting and ending Tags as block boundaries.
|
java.util.List<SwiftTagListBlock> |
getSubBlocksDelimitedWithOptionalTail(java.lang.String[] start,
java.lang.String[] end,
java.lang.String[] tail)
Get all subblocks in message that start with tag with tagname, end with tag named endName and optionally, may be null, have optionalTail tag names at the end of the secuence
TODO definir comportamiento si hay cosas de mas en el medio
|
Tag |
getTag(int i)
Gets the Tag of the given index in this block, the position is zero-based.
|
Tag |
getTagByName(java.lang.String key)
Iterate through tags in this block and return the first tag whose name matches key,
or
null if none is found. |
Tag |
getTagByNumber(int i)
Search and retrieve the first tag with the given number.
|
int |
getTagCount()
Deprecated.
use
countAll() instead |
int |
getTagCount(java.lang.String key)
Deprecated.
renamed to
countByName(String) |
java.lang.Integer |
getTagIndex(java.lang.String startTagNumber,
java.lang.String[] letterOptions)
Get the index of the given tag in the list.
|
java.util.Map<java.lang.String,java.lang.String> |
getTagMap()
Gets a Map that contains the the fields names as keys and the values as map value.
|
java.util.List<Tag> |
getTags()
Gets the internal List of tags in block.
|
java.util.List<Tag> |
getTagsByContent(java.lang.String value)
Returns the tags having the specified content as part of its value.
For example the field :98A::XDTE//20090818 will be included for parameter XDTE |
Tag[] |
getTagsByName(java.lang.String name)
Get a reference to tags in the block that match the given tag name.
|
java.util.List<Tag> |
getTagsByNumber(int i)
get all tags of a given number.
|
java.util.List<Tag> |
getTagsByValue(java.lang.String value)
Returns the tags having the exact specified content as value.
For example the field :98A::XDTE//20090818 will be included for parameter :XDTE//20090818 |
java.lang.String |
getTagValue(java.lang.String key)
Gets the value of the given tag or
null if that tagname is not found.NOTE: if the tag is present more than once, then this method retrieves the value of the first occurrence |
java.lang.String[] |
getTagValues(java.lang.String key)
Gets all values for a given tagname.
|
int |
hashCode() |
int |
indexOfAnyFirst(java.lang.String... tagnames)
Get the index of the first of any tagnames in the list or -1 if not found or any precondition is not met
|
int |
indexOfAnyFirstAfterIndex(int index,
java.lang.String... tagnames)
Get the index of the first of any tagnames after the given index in the list or -1 if not found or any precondition is not met
|
int |
indexOfAnyLast(java.lang.String... tagnames)
Get the index of the last of any tagnames in the list or -1 if not found or any precondition is not met
|
int |
indexOfAnyLastAfterIndex(int index,
java.lang.String... tagnames)
Get the index of the last of any tagnames after the given index in the list or -1 if not found or any precondition is not met
|
int |
indexOfFirst(java.lang.String tagname)
Get the index of the first tagname in the list or -1 if not found or any precondition is not met
|
int |
indexOfLast(java.lang.String tagname)
Get the index of the last tagname in the list or -1 if not found or any precondition is not met
|
boolean |
isEmpty()
Tells if the block contains at least one Tag.
|
SwiftTagListBlock |
removeAfterFirst(java.lang.String name,
boolean includeBoundaryInResult) |
SwiftTagListBlock |
removeAfterFirstStartsWith(java.lang.String name,
java.lang.String startsWith)
Return a new block with all tags until the first tagname with the given name that start with startsWith
|
int |
removeAll(java.lang.String name)
Remove all tags in the current block that match the given name.
|
SwiftTagListBlock |
removeSubBlock(java.lang.String blockName)
Get a sub block with all tags but the ones in the first occurrence of the given sub block.
It searches for a starting 16R field (with blockName as value) and its correspondent 16S field (with blockName as value) as block boundaries and removes those fields from the result. |
java.lang.String |
removeTag(java.lang.String tag)
Remove the tag with the given name in the block.
|
SwiftTagListBlock |
removeUntilFirst(java.lang.String tagname,
boolean includeBoundaryInResult)
Creates a new
SwiftTagListBlock that contains all tags after the given tagname. |
protected void |
setBlockName(java.lang.String blockName)
Sets the block name (this method is to be overwrite for derived classes).
|
protected void |
setBlockNumber(java.lang.Integer blockNumber)
Sets the block number (this method is to be overwrite for derived classes).
|
void |
setTags(java.util.List<Tag> tags)
Set the list of tags of this block.
|
void |
setTags(Tag[] tags) |
int |
size()
Tells the amount of fields contained in the block, may be zero.
|
java.util.List<SwiftTagListBlock> |
splitByTagName(java.lang.String tagName)
Split the given list with the given tagname.
|
SwiftTagListBlock |
sublist(java.lang.Integer start,
java.lang.Integer end)
Get a new list with the elements contained between start and end, both inclusive.
|
java.util.Iterator<Tag> |
tagIterator()
Gets a Iterator for the tags in this block or
null if no tags are present on the block an empty iterator is returned. |
java.util.List<java.lang.String> |
tagNamesList() |
java.lang.String |
toString()
convert this to string
|
SwiftTagListBlock |
trimAfterFirst(java.lang.String tagname,
boolean includeBoundaryInResult)
Get a subblock with all tags in this blocks until the first occurrence of a tag with tagname.
|
void |
visit(TagVisitor visitor) |
getBlockType, getId, getInput, getOutput, getUnparsedTexts, getUnparsedTextsSize, isTagBlock, setBlockType, setId, setInput, setOutput, setUnparsedTexts, unparsedTextAddText, unparsedTextAddText, unparsedTextGetAsMessage, unparsedTextGetText, unparsedTextIsMessage, unparsedTextVerify
public SwiftTagListBlock()
public SwiftTagListBlock(java.util.List<Tag> tags)
public boolean containsTag(java.lang.String tagName)
exact tagname match only
This method iterates throw tags and checks the name to be matched against the given tagname. Thus, it will not distinguish between tags that appear only one time and tags that appear in multiple instances.
tagName
- fieldname to search, like "32A" or "58"true
if the given field has been set on this block
or false
in other casejava.lang.IllegalArgumentException
- if parameter tagName is null
public java.lang.String getTagValue(java.lang.String key)
null
if that tagname is not found.key
- name of the tag, example: 13C (case sensitive)null
if the tag is not setjava.lang.IllegalArgumentException
- if parameter key is null
public Tag getTagByName(java.lang.String key)
null
if none is found.key
- name of the tag to searchnull
if it is not foundjava.lang.IllegalArgumentException
- if parameter key is null
public Field getFieldByName(java.lang.String key)
getTagByName(String)
.getField()key
- public java.util.List<Tag> getTags()
Tag
public void addTag(Tag t)
t
- the tag to addjava.lang.IllegalArgumentException
- if parameter t is null
public void add(Field f)
public int getTagCount(java.lang.String key)
countByName(String)
countByName(String)
public int countByName(java.lang.String tagname)
tagname
- the name of the tagjava.lang.IllegalArgumentException
- if tagname key is null
public java.lang.String[] getTagValues(java.lang.String key)
key
- name of the tag to be searched, case sensitivejava.lang.IllegalArgumentException
- if parameter key is null
public java.lang.String toString()
toString
in class SwiftBlock
public java.util.Map<java.lang.String,java.lang.String> getTagMap()
null
if there are not tags in the blockpublic java.lang.String removeTag(java.lang.String tag)
tag
- name of the tag to remove must not be nulljava.lang.IllegalArgumentException
- if parameter tag is null
removeAll(String)
public int removeAll(java.lang.String name)
containsTag(String)
must be used.name
- the name of the tag to remove. may be null
in which case the tags containing 'block data' will be removedjava.lang.IllegalArgumentException
- if parameter name is null
removeTag(String)
public Tag[] getTagsByName(java.lang.String name)
null
all tags that contain block data will be returned.
If no tag is found an empty array is returned.name
- the name of the tag to search in this blockjava.lang.IllegalArgumentException
- if parameter name is null
public Field[] getFieldsByName(java.lang.String name)
getTagsByName(String)
NOTE: supports 'a' wildcard. If 95a is given, all 95, 95K, 95J fields will be returned..
This is case sensitive.java.lang.IllegalArgumentException
- if name is nullpublic java.util.Iterator<Tag> tagIterator()
null
if no tags are present on the block an empty iterator is returned.Tag
public Tag getTag(int i)
i
- the index position of the tag to retrievejava.lang.IndexOutOfBoundsException
- if the index is invalidList.get(int)
public Field getField(int i)
getTag(int)
.getField()i
- java.lang.NullPointerException
- if the tag with the given index does not existpublic void addTags(java.util.List<Tag> tags)
tags
- the list of tags to addjava.lang.IllegalArgumentException
- if parameter name is null
public int getTagCount()
countAll()
insteadpublic int countAll()
public void setTags(java.util.List<Tag> tags)
tags
- the tags of the block, may be null
to remove all the tags of the blockjava.lang.IllegalArgumentException
- if parameter tags is not null
and contains elements of class other than Tagpublic void setTags(Tag[] tags)
tags
- tags to setsetTags(List)
public boolean isEmpty()
true
if the block contains at least one Tag and false
in other casepublic int size()
public int hashCode()
hashCode
in class SwiftBlock
public boolean equals(java.lang.Object obj)
equals
in class SwiftBlock
public boolean containsTag(int i)
i
This method is useful to search any variant of a tag
containsTag(58)
will return true
if there is any variant of 58A, 58D, or so.i
- the tag number to search in tagstrue
if there is a tag with the given number, no matter if the tag is or not a letter option (letter option may be any or empty)public Tag getTagByNumber(int i)
i
- the tagname to searchnull
if no tag is found.containsTag(int)
public Field getFieldByNumber(int num)
num
- getTagByNumber(int)
public java.util.List<Tag> getTagsByNumber(int i)
getTagByNumber(int)
,
Tag.getNumber()
public java.util.List<? extends Field> getFieldsByNumber(int i)
getTagByNumber(int)
,
Tag.getNumber()
,
Tag.isNumber(int)
public java.util.List<Tag> getTagsByValue(java.lang.String value)
value
- value of tags to findpublic java.util.List<Tag> getTagsByContent(java.lang.String value)
value
- value of tags to findpublic java.util.List<SwiftTagListBlock> getSubBlocks(Tag start, Tag end)
start
- starting tagend
- ending tagSwiftTagListBlock
new blocks containing the found tags (the list can be empty if no tags are found)public SwiftTagListBlock getSubBlock(Tag start, Tag end)
null
or not found after the starting Tag, it returns all tags until end of block.
The starting and end tags are included in the resulting block.start
- starting tagend
- ending tag or null
public java.util.List<SwiftTagListBlock> getSubBlocks(java.lang.String startTagName, java.lang.String endTagName)
startTagName
- starting tag nameendTagName
- ending tag nameSwiftTagListBlock
new blocks containing the found tags (the list can be empty if no tags are found)public java.util.List<SwiftTagListBlock> getSubBlocks(int startTagNumber, int endTagNumber)
startTagNumber
- starting tag number regardless of the letter optionendTagNumber
- ending tag number regardless of the letter optionSwiftTagListBlock
new blocks containing the found tags (the list can be empty if no tags are found)public java.util.List<SwiftTagListBlock> getSubBlocks(java.lang.String startTagName, int endTagNumber)
startTagName
- starting tag nameendTagNumber
- ending tag number regardless of the letter optionSwiftTagListBlock
new blocks containing the found tags (the list can be empty if no tags are found)public java.util.List<SwiftTagListBlock> getSubBlocks(int startTagNumber, java.lang.String endTagName)
startTagNumber
- starting tag name number regardless of the letter optionendTagName
- ending tag nameSwiftTagListBlock
new blocks containing the found tags (the list can be empty if no tags are found)public SwiftTagListBlock getSubBlockByIndex(java.lang.Integer startIndex, java.lang.Integer endIndex)
startIndex
- endIndex
- getTagIndex(String, String[])
public java.lang.Integer getTagIndex(java.lang.String startTagNumber, java.lang.String[] letterOptions)
startTagNumber
- the number of the tag, without any letter optionletterOptions
- list of letter options to search, an empty string is accepted to search no letter optionnull
if the tag is not foundpublic SwiftTagListBlock getSubBlock(java.lang.String startTagName, java.lang.String endTagName)
null
or not found after the starting Tag name, it returns all tags until end of block.
The starting and end tags are included in the resulting block.startTagName
- starting tag nameendTagName
- ending tag name or null
public java.util.List<SwiftTagListBlock> getSubBlocks(java.lang.String blockName)
blockName
- block name, used for blockgetSubBlocks(Tag, Tag)
public SwiftTagListBlock getSubBlock(java.lang.String blockName)
blockName
- block name, used for blockgetSubBlock(Tag, Tag)
public boolean containsTag(Tag t)
t
- the tag to search in tagstrue
if tag is foundpublic java.lang.String getName()
SwiftBlock
getName
in class SwiftBlock
public java.lang.Integer getNumber()
SwiftBlock
getNumber
in class SwiftBlock
protected void setBlockName(java.lang.String blockName)
SwiftBlock
setBlockName
in class SwiftBlock
blockName
- the block name to setprotected void setBlockNumber(java.lang.Integer blockNumber)
SwiftBlock
setBlockNumber
in class SwiftBlock
blockNumber
- the block number to setpublic void visit(TagVisitor visitor)
public java.util.List<SwiftTagListBlock> splitByTagName(java.lang.String tagName)
tagName
- public boolean containsField(java.lang.String name)
name
- field name to search, supporting the 'a' notationgetFieldsByName(String)
public SwiftTagListBlock getSubBlockAfterFirst(java.lang.String tagname)
tagname
- public SwiftTagListBlock getSubBlockBeforeFirst(java.lang.String tagname, boolean includeSeparator)
true
public SwiftTagListBlock getSubBlockAfterLast(java.lang.String tagname, boolean includeDelimiterInResult)
public SwiftTagListBlock getSubBlock(java.lang.Integer from, java.lang.Integer to)
List.subList(int, int)
a larger to
value is equivalent to the list sizefrom
- may be null in which case is equivalent to zeroto
- may be null in which case is equivalent to the index of the last item.java.lang.IllegalArgumentException
- if from is equal or bigger than to.List.subList(int, int)
public int indexOfLast(java.lang.String tagname)
public int indexOfAnyLast(java.lang.String... tagnames)
public int indexOfAnyLastAfterIndex(int index, java.lang.String... tagnames)
public int indexOfFirst(java.lang.String tagname)
public int indexOfAnyFirst(java.lang.String... tagnames)
public int indexOfAnyFirstAfterIndex(int index, java.lang.String... tagnames)
public SwiftTagListBlock getSubBlockBeforeLast(java.lang.String tagname, boolean includeDelimiterInResult)
tagname
- includeDelimiterInResult
- public SwiftTagListBlock trimAfterFirst(java.lang.String tagname, boolean includeBoundaryInResult)
tagname
- includeBoundaryInResult
- public SwiftTagListBlock removeUntilFirst(java.lang.String tagname, boolean includeBoundaryInResult)
SwiftTagListBlock
that contains all tags after the given tagname.
tagname is included or not depending on the value of includeBoundaryInResult
tagname
- the tagname to searchincludeBoundaryInResult
- if true, the found boundary tag will be the first item in the returned listSwiftTagListBlock
with the tags foundremoveAfterFirst(String, boolean)
public SwiftTagListBlock removeSubBlock(java.lang.String blockName)
blockName
- block name, used for blockpublic boolean containsAnyOf(java.lang.String... name)
containsTag(String)
.name
- the list of tags to check, if null
or empty this method will return false without further actioncontainsTag(String)
,
containsAllOf(String...)
public boolean containsAllOf(java.lang.String... name)
containsTag(String)
.name
- the list of tags to check, if null
or empty this method will return false without further actioncontainsTag(String)
,
containsAnyOf(String...)
public SwiftTagListBlock filterByName(boolean include, java.lang.String... names)
true
) or excludes (false
), depending on includeOrExclude
flag
all tags with names matching any of the parameter names.include
- if true
include all tags with given names, if false
include all tags with a name not in namesnames
- list of tagnames to matchpublic SwiftTagListBlock filterByNameOrdered(java.lang.String... names)
names
- list of tagnames to matchpublic SwiftTagListBlock removeAfterFirst(java.lang.String name, boolean includeBoundaryInResult)
removeUntilFirst(String, boolean)
public java.util.List<SwiftTagListBlock> getSubBlocksDelimitedWithOptionalTail(java.lang.String[] start, java.lang.String[] end, java.lang.String[] tail)
startName
- name of the tag that identifies the begin of the sequenceendName
- name of the tag that identifies the end of the sequenceoptionalTail
- names of tags that are optional and belong to the sequence, the must be after endNamepublic SwiftTagListBlock getSubBlockDelimitedWithOptionalTail(java.lang.String[] start, java.lang.String[] end, java.lang.String[] tail)
start
- end
- tail
- public SwiftTagListBlock sublist(java.lang.Integer start, java.lang.Integer end)
null
.start
- start index, zero based. if null = zeroend
- last index, zero based, null means last elementpublic SwiftTagListBlock getOptionalList(java.lang.String[][] optionalTags)
optionalTags
- public SwiftTagListBlock getOptionalList(java.lang.String[][] optionalTags, int startAt)
public java.util.List<SwiftTagListBlock> getOptionalLists(java.lang.String[][] optionalTags)
public java.util.List<java.lang.String> tagNamesList()
public int countTagsStarsWith(java.lang.String name, java.lang.String value)
public SwiftTagListBlock removeAfterFirstStartsWith(java.lang.String name, java.lang.String startsWith)
name
- startsWith
-