public class SwiftTagListBlock extends SwiftBlock implements Serializable, Iterable<Tag>
Modifier and Type | Field and Description |
---|---|
static SwiftTagListBlock |
EMPTY_LIST
Immutableempty instance of this class.
|
blockType, id, input, output, unparsedTexts
Constructor and Description |
---|
SwiftTagListBlock()
Default constructor, shouldn't be used normally.
|
SwiftTagListBlock(List<Tag> tags)
Intended to be used by search results in this class
|
Modifier and Type | Method and Description |
---|---|
void |
add(Field f)
Deprecated.
use
append(Field) instead |
void |
addTag(Tag t)
Deprecated.
use
append(Tag) instead of this |
void |
addTags(List<Tag> tags)
Add all tags in the List argument to the current blocks.
|
SwiftTagListBlock |
append(Field... fields)
Appends all fields to the current block
|
SwiftTagListBlock |
append(Field field)
Add the given field to the end of the list.
|
SwiftTagListBlock |
append(SwiftTagListBlock... blocks)
Appends all blocks to the end of this one.
|
SwiftTagListBlock |
append(SwiftTagListBlock block)
Appends all tags in block to the contents of this block
|
SwiftTagListBlock |
append(Tag... tags)
Appends all tags to the current block
|
SwiftTagListBlock |
append(Tag tag)
Add the given tag to the end of the list
|
Tag[] |
asTagArray()
Get the content of this tag block as a Tag array.
|
SwiftTagListBlock |
clear()
Removes all tags from the backing storage.
|
boolean |
containsAllOf(String... name)
Tell if this block contains all of the given name tags.
|
boolean |
containsAnyOf(String... name)
Tell if this block contains any of the given name tags.
|
boolean |
containsField(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(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 number of tags in this taglist
|
int |
countByName(String tagname)
Counts how many tags with the given name are present in the block.
|
int |
countTagsStarsWith(String name,
String value)
Counts tags starting with the given value
|
boolean |
equals(Object obj) |
SwiftTagListBlock |
filterByName(boolean include,
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(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(String key)
Iterate through tags in this block and return the first tag whose name matches key,
or
null if none is found. |
Field |
getFieldByName(String fieldname,
String component1)
Get the first field with the given name whose component 1 matched 'being'.
|
Field |
getFieldByName(String fieldname,
String being,
String component2)
Similar to #getFieldByName(String, String) except that it also adds the check of matching component2
|
Field |
getFieldByNumber(int num)
Search and retrieve the first Field with the given number.
|
Field |
getFieldByNumber(int number,
String being)
Get the first field with the given number and that
Field.is(String) the value in being. |
Field[] |
getFieldsByName(String name)
Similar to
getTagsByName(String)
NOTE: supports 'a' wildcard. |
List<? extends Field> |
getFieldsByName(String name,
String being)
Get all the fields that match the given name and whose first component is being.
|
List<? extends Field> |
getFieldsByNumber(int i)
get all Fields of a given number.
|
String |
getName()
Returns the block name (this method is to be overwritten for derived classes).
|
Integer |
getNumber()
Returns the block number (this method is to be overwritten for derived classes).
|
SwiftTagListBlock |
getOptionalList(String[][] optionalTags)
Search a secuence of optional tags.
|
SwiftTagListBlock |
getOptionalList(String[][] optionalTags,
int startAt) |
List<SwiftTagListBlock> |
getOptionalLists(String[][] optionalTags) |
SwiftTagListBlock |
getSubBlock(Integer from,
Integer to)
Analog to substring from to.
|
SwiftTagListBlock |
getSubBlock(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(String startTagName,
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(String tagname)
Deprecated.
|
SwiftTagListBlock |
getSubBlockAfterFirst(String tagname,
boolean includeSeparator)
Get a subblock after the first tag with the given tagname.
|
SwiftTagListBlock |
getSubBlockAfterLast(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(String tagname,
boolean includeSeparator)
get a new list with all the tags found before the first tagname.
|
SwiftTagListBlock |
getSubBlockBeforeLast(String tagname,
boolean includeDelimiterInResult)
Get a new list with all tags until tagname is found, included or not depending on the value of
includeDelimiterInResult |
SwiftTagListBlock |
getSubBlockByIndex(Integer startIndex,
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 |
getSubBlockByTagNames(Integer startIndex,
String... searchTags)
Find a sub block given a comprehensive ordered list of search tag names.
|
SwiftTagListBlock |
getSubBlockDelimitedWithOptionalTail(String[] start,
String[] end,
String[] tail)
Get the
|
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).
|
List<SwiftTagListBlock> |
getSubBlocks(int startTagNumber,
String endTagName)
Get all sub blocks using the starting Tag number and ending Tag name as block boundaries (Tag values are ignored).
|
List<SwiftTagListBlock> |
getSubBlocks(String blockName)
Gets all sub blocks with a specific name, using ISO 15022 FIN block structure definitions.
|
List<SwiftTagListBlock> |
getSubBlocks(String startTagName,
int endTagNumber)
Get all sub blocks using the starting Tag name and ending Tag number as block boundaries (Tag values are ignored).
|
List<SwiftTagListBlock> |
getSubBlocks(String startTagName,
String endTagName)
Get all sub blocks using the starting and ending Tag names as block boundaries (Tag values are ignored).
|
List<SwiftTagListBlock> |
getSubBlocks(Tag start,
Tag end)
Get all sub blocks using the starting and ending Tags as block boundaries.
The starting and end tags are included in the resulting sub blocks. |
List<SwiftTagListBlock> |
getSubBlocksByTagNames(Integer startIndex,
String... searchTags)
Similar to
getSubBlockByTagNames(Integer, String...) but will return
all matches for the indicated subblock |
List<SwiftTagListBlock> |
getSubBlocksDelimitedWithOptionalTail(String[] start,
String[] end,
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
|
Tag |
getTag(int i)
Gets the Tag of the given index in this block, the position is zero-based.
|
Tag |
getTagByName(String key)
Iterate through tags in this block and return the first tag whose name matches key,
or
null if none is found. |
Tag |
getTagByName(String fieldname,
String component1,
String component2)
Get the first field with the given name, matching the given values
for components 1 and 2.
This is particularly helpful to find generic field by its qualifier. |
Tag |
getTagByNumber(int i)
Search and retrieve the first tag with the given number.
|
int |
getTagCount()
Deprecated.
use
countAll() instead |
int |
getTagCount(String key)
Deprecated.
renamed to
countByName(String) |
Integer |
getTagIndex(String startTagNumber,
String[] letterOptions)
Get the index of the given tag in the list.
|
Map<String,String> |
getTagMap()
Gets a Map that contains the the fields names as keys and the values as map value.
|
List<Tag> |
getTags()
Gets the internal List of tags in block.
|
List<Tag> |
getTagsByContent(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(String name)
Get a reference to tags in the block that match the given tag name.
|
List<Tag> |
getTagsByNumber(int i)
get all tags of a given number.
|
List<Tag> |
getTagsByValue(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 |
String |
getTagValue(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 |
String[] |
getTagValues(String key)
Gets all values for a given tagname.
|
int |
hashCode() |
int |
indexOfAnyFirst(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,
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(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,
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(String tagname)
Get the index of the first tagname in the list or -1 if not found or any precondition is not met
|
int |
indexOfFirstValue(String tagname,
String value)
Get the index of the first tagname in the list with the given value or -1 if not found or any precondition is not met (current tag list is null or empty)
|
int |
indexOfLast(String tagname)
Get the index of the last tagname in the list or -1 if not found or any precondition is not met
|
int |
indexOfLastValue(String tagname,
String value)
Get the index of the last tagname with the given value 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.
|
Iterator<Tag> |
iterator() |
SwiftTagListBlock |
removeAfterFirst(String name,
boolean includeBoundaryInResult) |
SwiftTagListBlock |
removeAfterFirstStartsWith(String name,
String startsWith)
Return a new block with all tags until the first tagname with the given name that start with startsWith
|
int |
removeAll(String name)
Remove all tags in the current block that match the given name.
|
SwiftTagListBlock |
removeSubBlock(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. |
String |
removeTag(String tag)
Remove the tag with the given name in the block.
|
SwiftTagListBlock |
removeUntilFirst(String tagname,
boolean includeBoundaryInResult)
Creates a new
SwiftTagListBlock that contains all tags after the given tagname. |
protected void |
setBlockName(String blockName)
Sets the block name (this method is to be overwrite for derived classes).
|
protected void |
setBlockNumber(Integer blockNumber)
Sets the block number (this method is to be overwrite for derived classes).
|
void |
setTags(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.
|
List<SwiftTagListBlock> |
splitByTagName(String tagName)
Split the given list with the given tagname.
|
SwiftTagListBlock |
sublist(Integer start,
Integer end)
Get a new list with the elements contained between start and end, both inclusive.
|
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. |
List<String> |
tagNamesList() |
String |
toJson() |
String |
toString()
convert this to string
|
SwiftTagListBlock |
trimAfterFirst(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 static final SwiftTagListBlock EMPTY_LIST
public SwiftTagListBlock()
public boolean containsTag(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 caseIllegalArgumentException
- if parameter tagName is null
public String getTagValue(String key)
null
if that tagname is not found.key
- name of the tag, example: 13C (case sensitive)null
if the tag is not setIllegalArgumentException
- if parameter key is null
public Tag getTagByName(String key)
null
if none is found.
NOTE: exact naming only, 'a' syntax not supported herekey
- name of the tag to searchnull
if it is not foundIllegalArgumentException
- if parameter key is null
public Field getFieldByName(String fieldname, String being, String component2)
getFieldByName(String, String)
public Tag getTagByName(String fieldname, String component1, String component2)
fieldname
- EXACT name only. 'a' notation NOT SUPPORTEDcomponent1
- the string to match as component 1.component2
- the string to match as component 2.null
if none foundpublic Field getFieldByName(String fieldname, String component1)
fieldname
- EXACT name only. 'a' notation NOT SUPPORTEDcomponent1
- the string to match as component 1, may be null
.null
if none found{@link
- IllegalArgumentException} if key is null
Field.is(String)
public Field getFieldByName(String key)
null
if none is found.
NOTE: exact naming only, 'a' syntax not supported here
Same as doing getTagByName(String)
.getField()
.key
- name of the tag to searchnull
if it is not foundIllegalArgumentException
- if parameter key is null
getTagByName(String)
public List<Tag> getTags()
Tag
@Deprecated @ProwideDeprecated(phase3=_2018) public void addTag(Tag t)
append(Tag)
instead of this@Deprecated @ProwideDeprecated(phase3=_2018) public void add(Field f)
append(Field)
instead@Deprecated @ProwideDeprecated(phase3=_2018) public int getTagCount(String key)
countByName(String)
public int countByName(String tagname)
tagname
- the name of the tagIllegalArgumentException
- if tagname key is null
public String[] getTagValues(String key)
key
- name of the tag to be searched, case sensitiveIllegalArgumentException
- if parameter key is null
public String toString()
toString
in class SwiftBlock
public Map<String,String> getTagMap()
null
if there are not tags in the blockpublic String removeTag(String tag)
tag
- name of the tag to remove must not be nullIllegalArgumentException
- if parameter tag is null
removeAll(String)
public int removeAll(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 removedIllegalArgumentException
- if parameter name is null
removeTag(String)
public Tag[] getTagsByName(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 blockIllegalArgumentException
- if parameter name is null
public Field[] getFieldsByName(String name)
getTagsByName(String)
NOTE: supports 'a' wildcard. If 95a is given, all 95, 95K, 95J fields will be returned..
This is case sensitive.IllegalArgumentException
- if name is nullpublic List<? extends Field> getFieldsByName(String name, String being)
name
- the name of the field to match, may end with 'a' as wildcard. When name ends with 'a' it is removed from the search and the field is matched with startsWith instead of equalsbeing
- value to match in Field.is(String)
which compares the value of component 1public 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 retrieveIndexOutOfBoundsException
- if the index is invalidList.get(int)
public Field getField(int i)
getTag(int)
.getField()i
- NullPointerException
- if the tag with the given index does not existpublic void addTags(List<Tag> tags)
tags
- the list of tags to addIllegalArgumentException
- if parameter name is null
@Deprecated @ProwideDeprecated(phase2=_2018) public int getTagCount()
countAll()
insteadpublic int countAll()
public void setTags(List<Tag> tags)
tags
- the tags of the block, may be null
to remove all the tags of the blockIllegalArgumentException
- 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(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
- the field number to searchgetTagByNumber(int)
public List<Tag> getTagsByNumber(int i)
getTagByNumber(int)
,
Tag.getNumber()
public List<? extends Field> getFieldsByNumber(int i)
getTagByNumber(int)
,
Tag.getNumber()
,
Tag.isNumber(int)
public Field getFieldByNumber(int number, String being)
Field.is(String)
the value in being.
This is intended to match calling
getFieldByNumber(95, "FOO")
will match all these:
null
if none is foundpublic List<Tag> getTagsByValue(String value)
value
- value of tags to findpublic List<Tag> getTagsByContent(String value)
value
- value of tags to findpublic 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 List<SwiftTagListBlock> getSubBlocks(String startTagName, 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 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 List<SwiftTagListBlock> getSubBlocks(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 List<SwiftTagListBlock> getSubBlocks(int startTagNumber, 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(Integer startIndex, Integer endIndex)
startIndex
- endIndex
- getTagIndex(String, String[])
public Integer getTagIndex(String startTagNumber, 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(String startTagName, 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 List<SwiftTagListBlock> getSubBlocks(String blockName)
blockName
- block name, used for blockgetSubBlocks(Tag, Tag)
public SwiftTagListBlock getSubBlock(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 String getName()
SwiftBlock
getName
in class SwiftBlock
public Integer getNumber()
SwiftBlock
getNumber
in class SwiftBlock
protected void setBlockName(String blockName)
SwiftBlock
setBlockName
in class SwiftBlock
blockName
- the block name to setprotected void setBlockNumber(Integer blockNumber)
SwiftBlock
setBlockNumber
in class SwiftBlock
blockNumber
- the block number to setpublic void visit(TagVisitor visitor)
public List<SwiftTagListBlock> splitByTagName(String tagName)
tagName
- public boolean containsField(String name)
name
- field name to search, supporting the 'a' notationgetFieldsByName(String)
public SwiftTagListBlock getSubBlockAfterFirst(String tagname, boolean includeSeparator)
tagname
- the tag that will be used for splittingincludeSeparator
- include tagname in the returned sequence or not@Deprecated @ProwideDeprecated(phase2=_2018) public SwiftTagListBlock getSubBlockAfterFirst(String tagname)
getSubBlockAfterFirst(String, boolean)
getSubBlockAfterFirst(tagname, true);
public SwiftTagListBlock getSubBlockBeforeFirst(String tagname, boolean includeSeparator)
true
public SwiftTagListBlock getSubBlockAfterLast(String tagname, boolean includeDelimiterInResult)
public SwiftTagListBlock getSubBlock(Integer from, 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.IllegalArgumentException
- if from is equal or bigger than to.List.subList(int, int)
public int indexOfLast(String tagname)
public int indexOfLastValue(String tagname, String value)
public int indexOfAnyLast(String... tagnames)
tagnames
- a variable list of tagnames to search. Exact match only, wildcards NOT acceptedpublic int indexOfAnyLastAfterIndex(int index, String... tagnames)
public int indexOfFirst(String tagname)
public int indexOfFirstValue(String tagname, String value)
public int indexOfAnyFirst(String... tagnames)
public int indexOfAnyFirstAfterIndex(int index, String... tagnames)
public SwiftTagListBlock getSubBlockBeforeLast(String tagname, boolean includeDelimiterInResult)
includeDelimiterInResult
tagname
- the tag to searchincludeDelimiterInResult
- flag to include delimiter in the resultpublic SwiftTagListBlock trimAfterFirst(String tagname, boolean includeBoundaryInResult)
tagname
- includeBoundaryInResult
- public SwiftTagListBlock removeUntilFirst(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(String blockName)
blockName
- block name, used for blockpublic boolean containsAnyOf(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(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, 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(String... names)
names
- list of tagnames to matchpublic SwiftTagListBlock removeAfterFirst(String name, boolean includeBoundaryInResult)
removeUntilFirst(String, boolean)
public List<SwiftTagListBlock> getSubBlocksDelimitedWithOptionalTail(String[] start, String[] end, String[] tail)
start
- name of the tag that identifies the begin of the sequenceend
- name of the tag that identifies the end of the sequencetail
- names of tags that are optional and belong to the sequence, the must be after endNamepublic List<SwiftTagListBlock> getSubBlocksByTagNames(Integer startIndex, String... searchTags)
getSubBlockByTagNames(Integer, String...)
but will return
all matches for the indicated subblockpublic SwiftTagListBlock getSubBlockByTagNames(Integer startIndex, String... searchTags)
For example given the block [20, 21, 32A, 54, 36, 36, 58B, 72]
startIndex
- optional starting offset, defaults to zero to search from the beginning of the blocksearchTags
- a list of tags to search, in order, for example: 20, 59A, 50K, 72public SwiftTagListBlock getSubBlockDelimitedWithOptionalTail(String[] start, String[] end, String[] tail)
start
- end
- tail
- public SwiftTagListBlock sublist(Integer start, Integer end)
null
.start
- start index, zero based. if null = zeroend
- last index, zero based, null means last elementpublic SwiftTagListBlock getOptionalList(String[][] optionalTags)
optionalTags
- public SwiftTagListBlock getOptionalList(String[][] optionalTags, int startAt)
public List<SwiftTagListBlock> getOptionalLists(String[][] optionalTags)
public int countTagsStarsWith(String name, String value)
name
- the exact name of the tag to be matchedvalue
- the value that will be used to test if tag value startsWithTag.startsWith(String)
,
StringUtils.startsWith(String, String)
public SwiftTagListBlock removeAfterFirstStartsWith(String name, String startsWith)
name
- startsWith
- public String toJson()
public SwiftTagListBlock append(SwiftTagListBlock block)
block
- public SwiftTagListBlock append(SwiftTagListBlock... blocks)
blocks
- may be null
or empty, if so nothing happenspublic SwiftTagListBlock append(Tag tag)
tag
- the tag to add, must not be null
this
IllegalArgumentException
- if tag is nullpublic SwiftTagListBlock append(Tag... tags)
tags
- the tags to append. may be null
in which case nothing happensthis
public SwiftTagListBlock append(Field field)
field
- the field to add, must not be null
this
IllegalArgumentException
- if field is nullpublic SwiftTagListBlock append(Field... fields)
fields
- the fields to append. may be null
in which case nothing happensthis
public Tag[] asTagArray()
public SwiftTagListBlock clear()