com.prowidesoftware.swift.model
Class SwiftBlock

java.lang.Object
  extended by com.prowidesoftware.swift.model.SwiftBlock
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
SwiftTagListBlock, SwiftValueBlock

public abstract class SwiftBlock
extends java.lang.Object
implements java.io.Serializable

Base class for a generic SWIFT block.
This is an abstract class so specific block classes for each block (block 1, 2, 3, etc...) should be instantiated.

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)

Version:
$Id: SwiftBlock.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 blockType
          helper for hibernate mapping
protected  java.lang.Long id
          Unique identifier of the swift block.
protected  java.lang.Boolean input
          Only valid for block2, only when using hibernate for persistence
protected  java.lang.Boolean output
          Only valid for block2, only when using hibernate for persistence
protected  UnparsedTextList unparsedTexts
          List of unparsed texts.
 
Constructor Summary
SwiftBlock()
          Default constructor, shouldn't be used normally.
SwiftBlock(UnparsedTextList unparsedText)
          Constructor for an unparsed text list
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.String getBlockType()
           
 java.lang.Long getId()
          Get the unique identifier of this block or null if it is not set
 java.lang.Boolean getInput()
          Deprecated. use getBlockType()
abstract  java.lang.String getName()
          Returns the block name (this method is to be overwritten for derived classes).
abstract  java.lang.Integer getNumber()
          Returns the block number (this method is to be overwritten for derived classes).
 java.lang.Boolean getOutput()
          Deprecated. use getBlockType()
 UnparsedTextList getUnparsedTexts()
          Returns the unparsed text list attached to the Block.
 java.lang.Integer getUnparsedTextsSize()
          returns the size of the unparsed text list
 int hashCode()
           
 boolean isTagBlock()
          Tell if this block is a block that contains a list of tags (3-5) or is a block with fixed length value (1-2)
protected abstract  void setBlockName(java.lang.String blockName)
          Sets the block name (this method is to be overwrite for derived classes).
protected abstract  void setBlockNumber(java.lang.Integer blockNumber)
          Sets the block number (this method is to be overwrite for derived classes).
 void setBlockType(java.lang.String blockType)
          should not be normally called
 void setId(java.lang.Long id)
          Sets the unique identifier of this block
 void setInput(java.lang.Boolean input)
          Only valid for block2, only when using hibernate for persistence
 void setOutput(java.lang.Boolean output)
          Only valid for block2, only when using hibernate for persistence
 void setUnparsedTexts(UnparsedTextList texts)
          sets the list of unparsed texts
 java.lang.String toString()
           
 void unparsedTextAddText(java.lang.String text)
          adds a new unparsed text
 void unparsedTextAddText(SwiftMessage message)
          adds a new unparsed text from a message
 SwiftMessage unparsedTextGetAsMessage(java.lang.Integer index)
          get an unparsed text as a parsed swift message
 java.lang.String unparsedTextGetText(java.lang.Integer index)
          get an unparsed text
 java.lang.Boolean unparsedTextIsMessage(java.lang.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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected java.lang.Long id
Unique identifier of the swift block. Mainly used for persistence services.


unparsedTexts

protected UnparsedTextList unparsedTexts
List of unparsed texts. For performance reasons, this will be null until really needed.


input

protected java.lang.Boolean input
Only valid for block2, only when using hibernate for persistence


output

protected java.lang.Boolean output
Only valid for block2, only when using hibernate for persistence


blockType

protected java.lang.String blockType
helper for hibernate mapping

Constructor Detail

SwiftBlock

public SwiftBlock()
Default constructor, shouldn't be used normally. DO NOT USE: present only for subclasses


SwiftBlock

public SwiftBlock(UnparsedTextList unparsedText)
Constructor for an unparsed text list

Parameters:
unparsedText - the list of unparsed texts
Method Detail

getBlockType

public java.lang.String getBlockType()
Returns:
a string identifying block type or null if not implemented

setBlockType

public void setBlockType(java.lang.String blockType)
should not be normally called

Parameters:
blockType -

setBlockNumber

protected abstract void setBlockNumber(java.lang.Integer blockNumber)
Sets the block number (this method is to be overwrite for derived classes).

Parameters:
blockNumber - the block number to set
Since:
5.0

setBlockName

protected abstract void setBlockName(java.lang.String blockName)
Sets the block name (this method is to be overwrite for derived classes).

Parameters:
blockName - the block name to set
Since:
5.0

getNumber

public abstract java.lang.Integer getNumber()
Returns the block number (this method is to be overwritten for derived classes).

Returns:
Integer containing the block's number

getName

public abstract java.lang.String getName()
Returns the block name (this method is to be overwritten for derived classes).

Returns:
block name
Since:
5.0

getId

public java.lang.Long getId()
Get the unique identifier of this block or null if it is not set

Returns:
the unique identifier

setId

public void setId(java.lang.Long id)
Sets the unique identifier of this block

Parameters:
id - the unique identifier to set.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isTagBlock

public boolean isTagBlock()
Tell if this block is a block that contains a list of tags (3-5) or is a block with fixed length value (1-2)

Returns:
true if this object contains a list of tags (which may be empty or null

unparsedTextVerify

protected void unparsedTextVerify()
verifies that the unparsed text list exists


getUnparsedTexts

public UnparsedTextList getUnparsedTexts()
Returns the unparsed text list attached to the Block.

Returns:
the unparsed texts attached to the block

setUnparsedTexts

public void setUnparsedTexts(UnparsedTextList texts)
sets the list of unparsed texts

Parameters:
texts - the new list of unparsed texts (may be null)

getUnparsedTextsSize

public java.lang.Integer getUnparsedTextsSize()
returns the size of the unparsed text list

Returns:
the count of unparsed test attached to the block

unparsedTextIsMessage

public java.lang.Boolean unparsedTextIsMessage(java.lang.Integer index)
decides if a specific text (by index) is likely a SWIFT FIN message. Exceptions are inherited from base implementation methods.

Parameters:
index - the unparsed text number
Returns:
true if the unparsed text at position index is a full SWIFT Message
Throws:
java.lang.IllegalArgumentException - if parameter index is null
java.lang.IndexOutOfBoundsException - if parameter index is out of bounds

unparsedTextGetText

public java.lang.String unparsedTextGetText(java.lang.Integer index)
get an unparsed text

Parameters:
index - the unparsed text number
Returns:
the requested text
Throws:
java.lang.IllegalArgumentException - if parameter index is null
java.lang.IndexOutOfBoundsException - if parameter index is out of bounds

unparsedTextGetAsMessage

public SwiftMessage unparsedTextGetAsMessage(java.lang.Integer index)
get an unparsed text as a parsed swift message

Parameters:
index - the unparsed text number
Returns:
the blocks unparsed text at position index, parsed into a SwiftMessage object
Throws:
java.lang.IllegalArgumentException - if parameter index is null

unparsedTextAddText

public void unparsedTextAddText(java.lang.String text)
adds a new unparsed text

Parameters:
text - the unparsed text to append
Throws:
java.lang.IllegalArgumentException - if parameter text is null

unparsedTextAddText

public void unparsedTextAddText(SwiftMessage message)
adds a new unparsed text from a message

Parameters:
message - the message to be appended
Throws:
java.lang.IllegalArgumentException - if parameter message is null

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

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

getInput

public java.lang.Boolean getInput()
Deprecated. use getBlockType()

Only valid for block2, only when using hibernate for persistence

Returns:
true if the message block type is 2I

setInput

public void setInput(java.lang.Boolean input)
Only valid for block2, only when using hibernate for persistence

Parameters:
input - the is input parameter

getOutput

public java.lang.Boolean getOutput()
Deprecated. use getBlockType()

Only valid for block2, only when using hibernate for persistence

Returns:
true if message block type is 2O

setOutput

public void setOutput(java.lang.Boolean output)
Only valid for block2, only when using hibernate for persistence

Parameters:
output - the is output parameter