com.prowidesoftware.swift.model
Class SwiftBlockUser

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

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
Version:
$Id: SwiftBlockUser.java,v 1.1.1.1 2013/04/10 17:04:50 mgriffa Exp $
Author:
www.prowidesoftware.com
See Also:
Serialized Form

Field Summary
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
tags
 
Fields inherited from class com.prowidesoftware.swift.model.SwiftBlock
blockType, id, input, output, unparsedTexts
 
Constructor Summary
SwiftBlockUser()
          Default constructor
SwiftBlockUser(java.lang.Integer blockNumber)
          Constructor for empty numbered user block
SwiftBlockUser(java.lang.Integer blockNumber, java.util.List<Tag> tags)
          Constructor for numbered user block with tag initialization
SwiftBlockUser(java.lang.String blockName)
          Constructor for named user block
SwiftBlockUser(java.lang.String blockName, java.util.List<Tag> tags)
          Constructor for named user block with tag initialization
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 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 persisted
 int 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
add, addTag, addTags, containsAnyOf, containsField, containsTag, containsTag, containsTag, getField, getFieldByName, getFieldsByName, getSubBlock, getSubBlock, getSubBlock, getSubBlockAfterFirst, getSubBlockAfterLast, getSubBlockByIndex, getSubBlocks, getSubBlocks, getSubBlocks, getSubBlocks, getSubBlocks, getSubBlocks, getTag, getTagByName, getTagByNumber, getTagCount, getTagCount, getTagIndex, getTagMap, getTags, getTagsByContent, getTagsByName, getTagsByValue, getTagValue, getTagValues, isEmpty, removeAll, removeTag, removeUntilFirst, setTags, setTags, size, splitByTagName, tagIterator, toString, trimAfterFirst, visit
 
Methods inherited from class com.prowidesoftware.swift.model.SwiftBlock
getBlockType, getId, getInput, getOutput, getUnparsedTexts, getUnparsedTextsSize, isTagBlock, setBlockType, setId, setInput, setOutput, setUnparsedTexts, unparsedTextAddText, unparsedTextAddText, unparsedTextGetAsMessage, unparsedTextGetText, unparsedTextIsMessage, unparsedTextVerify
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 null
java.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 initialize
tags - the list of tags to initialize
Throws:
java.lang.IllegalArgumentException - if parameter blockNumber or tags are null
java.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 null
java.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 initialize
tags - the list of tags to initialize
Throws:
java.lang.IllegalArgumentException - if parameter blockName or tags are null
java.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

getNumber

public java.lang.Integer getNumber()
Returns the block number (if it can be converted to an integer, -1 otherwise).

Overrides:
getNumber in class SwiftTagListBlock
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 class SwiftTagListBlock
Returns:
block name
See Also:
getBlockName()

getBlockName

public java.lang.String getBlockName()
The block name.

Returns:
the block name
Since:
5.0

setBlockNumber

protected void setBlockNumber(java.lang.Integer blockNumber)
Sets the block number. This really sets blockName

Overrides:
setBlockNumber in class SwiftTagListBlock
Parameters:
blockNumber - the block number to set
Throws:
java.lang.IllegalArgumentException - if parameter blockNumber is null
java.lang.IllegalArgumentException - if parameter blockNumber is not a valid User Defined Block number (values 6..9)
Since:
5.0

setBlockName

protected void setBlockName(java.lang.String blockName)
Sets the block name.

Overrides:
setBlockName in class SwiftTagListBlock
Parameters:
blockName - the block name to set
Throws:
java.lang.IllegalArgumentException - if parameter blockName is null
java.lang.IllegalArgumentException - if parameter blockName is not a valid User Defined Block name (single letter)
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

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 name
blockNumber - 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

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

hashCode

public int hashCode()
Overrides:
hashCode in class SwiftTagListBlock

equals

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