Package com.prowidesoftware.swift.model
Class SwiftBlockUser
- java.lang.Object
-
- com.prowidesoftware.swift.model.SwiftBlock
-
- com.prowidesoftware.swift.model.SwiftTagListBlock
-
- com.prowidesoftware.swift.model.SwiftBlockUser
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<Tag>
public class SwiftBlockUser extends SwiftTagListBlock implements java.io.Serializable
Base class for SWIFT User "ad-hoc" Blocks (blocks with number other than 1-5 or names).
The assumption is that these User Defined Blocks are used and defined as tag blocks (meaning that these blocks behave like a block 3 or 5).
NOTE: this is not part of SWIFT standard, but seems to be common practice for users to append some locally defined blocks to annotate messages in a semi-compatible way (for example: add block 9 for some local information or block "S" for system reference).
- Since:
- 5.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
blockName
Block name.protected java.lang.Integer
sortKey
Indicates the position of this user block in a message when persisted.-
Fields inherited from class com.prowidesoftware.swift.model.SwiftTagListBlock
EMPTY_LIST
-
Fields inherited from class com.prowidesoftware.swift.model.SwiftBlock
blockType, input, output, unparsedTexts
-
-
Constructor Summary
Constructors Constructor Description SwiftBlockUser()
Default constructorSwiftBlockUser(java.lang.Integer blockNumber)
Constructor for empty numbered user blockSwiftBlockUser(java.lang.Integer blockNumber, java.util.List<Tag> tags)
Constructor for numbered user block with tag initializationSwiftBlockUser(java.lang.String blockName)
Constructor for named user blockSwiftBlockUser(java.lang.String blockName, java.util.List<Tag> tags)
Constructor for named user block with tag initialization
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static SwiftBlockUser
fromJson(java.lang.String json)
This method deserializes the JSON data into an user block object.java.lang.String
getBlockName()
The block name.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 (if it can be converted to an integer, -1 otherwise).java.lang.Integer
getSortKey()
get the sortkey of this user block when persistedint
hashCode()
protected java.lang.Boolean
isValidName()
Checks if the block name (and or number) is valid for a user defined block.static java.lang.Boolean
isValidName(java.lang.Integer blockNumber)
Checks if the block number is valid for a user defined block.static java.lang.Boolean
isValidName(java.lang.String blockName)
Checks if the block name is valid for a user defined block.static java.lang.Boolean
isValidName(java.lang.String blockName, java.lang.Integer blockNumber)
Checks if the block name and are valid for a user defined block.protected void
setBlockName(java.lang.String blockName)
Sets the block name.protected void
setBlockNumber(java.lang.Integer blockNumber)
Sets the block number.void
setSortKey(java.lang.Integer sortKey)
Set the sortkey of this user block when persisted.-
Methods inherited from class com.prowidesoftware.swift.model.SwiftTagListBlock
addTag, addTags, append, append, append, append, append, append, asTagArray, clear, containsAllOf, containsAnyOf, containsField, containsTag, containsTag, containsTag, countAll, countByName, countTagsStarsWith, fields, filterByName, filterByNameOrdered, getField, getFieldByName, getFieldByName, getFieldByName, getFieldByNumber, getFieldByNumber, getFieldByQualifiers, getFieldsByName, getFieldsByName, getFieldsByNumber, getOptionalList, getOptionalList, getOptionalLists, getSubBlock, getSubBlock, getSubBlock, getSubBlock, getSubBlockAfterFirst, getSubBlockAfterFirst, getSubBlockAfterLast, getSubBlockBeforeFirst, getSubBlockBeforeFirst, getSubBlockBeforeLast, getSubBlockByTagNames, getSubBlockDelimitedWithOptionalTail, getSubBlocks, getSubBlocks, getSubBlocks, getSubBlocks, getSubBlocks, getSubBlocks, getSubBlocksByTagNames, getSubBlocksDelimitedWithOptionalTail, getTag, getTagByName, getTagByName, getTagByNumber, getTagIndex, getTagMap, getTags, getTagsByContent, getTagsByName, getTagsByName, getTagsByNumber, getTagsByValue, getTagValue, getTagValues, indexOfAnyFirst, indexOfAnyFirstAfterIndex, indexOfAnyLast, indexOfAnyLastAfterIndex, indexOfFirst, indexOfFirstValue, indexOfLast, indexOfLastValue, isEmpty, iterator, removeAfterFirstStartsWith, removeAll, removeSubBlock, removeSubBlocks, removeTag, setTag, setTags, setTags, size, splitByTagName, splitByTagName, sublist, tagIterator, tagNamesList, toJson, toString, visit
-
Methods inherited from class com.prowidesoftware.swift.model.SwiftBlock
getBlockType, getInput, getOutput, getUnparsedTexts, getUnparsedTextsSize, isTagBlock, setBlockType, setInput, setOutput, setUnparsedTexts, unparsedTextAddText, unparsedTextAddText, unparsedTextGetAsMessage, unparsedTextGetText, unparsedTextIsMessage, unparsedTextVerify
-
-
-
-
Field Detail
-
sortKey
protected java.lang.Integer sortKey
Indicates the position of this user block in a message when persisted. This value is used to remember the positions of the blocks inside a message when persisted. This value may not be set when persistence is not used and should not be used by clients.
-
blockName
protected java.lang.String blockName
Block name. For integer numbered blocks, this will be the block number converted to string. For other blocks (for example: "S"), this will be the block real identifier and block number (if requested) will be -1.- Since:
- 5.0
-
-
Constructor Detail
-
SwiftBlockUser
public SwiftBlockUser()
Default constructor- Since:
- 5.0
-
SwiftBlockUser
public SwiftBlockUser(java.lang.Integer blockNumber)
Constructor for empty numbered user block- Parameters:
blockNumber
- the block number to initialize- Throws:
java.lang.IllegalArgumentException
- if parameter blockNumber is nulljava.lang.IllegalArgumentException
- if parameter blockNumber is not a valid User Defined Block number (values 6..9)- Since:
- 5.0
-
SwiftBlockUser
public SwiftBlockUser(java.lang.Integer blockNumber, java.util.List<Tag> tags)
Constructor for numbered user block with tag initialization- Parameters:
blockNumber
- the block number to initializetags
- the list of tags to initialize- Throws:
java.lang.IllegalArgumentException
- if parameter blockNumber or tags are nulljava.lang.IllegalArgumentException
- if parameter blockNumber is not a valid User Defined Block number (values 6..9)java.lang.IllegalArgumentException
- if parameter tags is not composed of Strings- Since:
- 5.0
-
SwiftBlockUser
public SwiftBlockUser(java.lang.String blockName)
Constructor for named user block- Parameters:
blockName
- the block name to initialize- Throws:
java.lang.IllegalArgumentException
- if parameter blockName is nulljava.lang.IllegalArgumentException
- if parameter blockName is not a valid User Defined Block name (single letter)- Since:
- 5.0
-
SwiftBlockUser
public SwiftBlockUser(java.lang.String blockName, java.util.List<Tag> tags)
Constructor for named user block with tag initialization- Parameters:
blockName
- the block name to initializetags
- the list of tags to initialize- Throws:
java.lang.IllegalArgumentException
- if parameter blockName or tags are nulljava.lang.IllegalArgumentException
- if parameter blockName is not a valid User Defined Block name (single letter)java.lang.IllegalArgumentException
- if parameter tags is not composed of Strings- Since:
- 5.0
-
-
Method Detail
-
isValidName
public static java.lang.Boolean isValidName(java.lang.String blockName, java.lang.Integer blockNumber)
Checks if the block name and are valid for a user defined block.- Parameters:
blockName
- the block nameblockNumber
- the block number- Returns:
- true if the block name and number are valid
- Since:
- 5.0
-
isValidName
public static java.lang.Boolean isValidName(java.lang.String blockName)
Checks if the block name is valid for a user defined block.- Parameters:
blockName
- the block name- Returns:
- true if the block name and number are valid
- Since:
- 5.0
-
isValidName
public static java.lang.Boolean isValidName(java.lang.Integer blockNumber)
Checks if the block number is valid for a user defined block. Invalid blocks are blocks null or values 1-5 inclusive, all other values are considered valid.- Parameters:
blockNumber
- the block number- Returns:
- true if the block name and number are valid
- Since:
- 5.0
-
fromJson
public static SwiftBlockUser fromJson(java.lang.String json)
This method deserializes the JSON data into an user block object.- Since:
- 7.9.8
- See Also:
SwiftTagListBlock.toJson()
-
getNumber
public java.lang.Integer getNumber()
Returns the block number (if it can be converted to an integer, -1 otherwise).- Overrides:
getNumber
in classSwiftTagListBlock
- Returns:
- Integer containing the block's name as an integer or -1 if the block name is not numeric
-
getName
public java.lang.String getName()
Description copied from class:SwiftBlock
Returns the block name (this method is to be overwritten for derived classes).- Overrides:
getName
in classSwiftTagListBlock
- Returns:
- block name
- See Also:
getBlockName()
-
getBlockName
public java.lang.String getBlockName()
The block name.- Returns:
- the block name
- Since:
- 5.0
-
setBlockName
protected void setBlockName(java.lang.String blockName)
Sets the block name.- Overrides:
setBlockName
in classSwiftTagListBlock
- Parameters:
blockName
- the block name to set- Throws:
java.lang.IllegalArgumentException
- if parameter blockName is nulljava.lang.IllegalArgumentException
- if parameter blockName is not a valid User Defined Block name (single letter)- Since:
- 5.0
-
setBlockNumber
protected void setBlockNumber(java.lang.Integer blockNumber)
Sets the block number. This really setsblockName
- Overrides:
setBlockNumber
in classSwiftTagListBlock
- Parameters:
blockNumber
- the block number to set- Throws:
java.lang.IllegalArgumentException
- if parameter blockNumber is nulljava.lang.IllegalArgumentException
- if parameter blockNumber is not a valid User Defined Block number (values 6..9)- Since:
- 5.0
-
isValidName
protected java.lang.Boolean isValidName()
Checks if the block name (and or number) is valid for a user defined block. The block name is considered valid if its numeric value is other than 1-5 and if its named identification value is a one char string, for example "S".- Returns:
- true if the block name and number are valid
- Since:
- 5.0
-
getSortKey
public java.lang.Integer getSortKey()
get the sortkey of this user block when persisted- Returns:
- an integer with the current sortkey
- See Also:
sortKey
-
setSortKey
public void setSortKey(java.lang.Integer sortKey)
Set the sortkey of this user block when persisted. This value may be changed by clients when persistence is used and the order of the user blocks in a message are being modified.- Parameters:
sortKey
- the new sortkey
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classSwiftTagListBlock
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classSwiftTagListBlock
-
-