Package com.prowidesoftware.swift.model
Class SwiftBlock
- java.lang.Object
-
- 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)- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
blockType
helper for hibernate mappingprotected java.lang.Boolean
input
Only valid for block2, only when using hibernate for persistenceprotected java.lang.Boolean
output
Only valid for block2, only when using hibernate for persistenceprotected UnparsedTextList
unparsedTexts
List of unparsed texts.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SwiftBlock()
Default constructor, shouldn't be used normally.SwiftBlock(UnparsedTextList unparsedText)
Constructor for an unparsed text list
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.lang.String
getBlockType()
java.lang.Boolean
getInput()
Deprecated.UsegetBlockType()
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.UsegetBlockType()
UnparsedTextList
getUnparsedTexts()
Returns the unparsed text list attached to the Block.java.lang.Integer
getUnparsedTextsSize()
returns the size of the unparsed text listint
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 calledvoid
setInput(java.lang.Boolean input)
Only valid for block2, only when using hibernate for persistencevoid
setOutput(java.lang.Boolean output)
Only valid for block2, only when using hibernate for persistencevoid
setUnparsedTexts(UnparsedTextList texts)
sets the list of unparsed textsjava.lang.String
toString()
void
unparsedTextAddText(SwiftMessage message)
adds a new unparsed text from a messagevoid
unparsedTextAddText(java.lang.String text)
adds a new unparsed textSwiftMessage
unparsedTextGetAsMessage(java.lang.Integer index)
get an unparsed text as a parsed swift messagejava.lang.String
unparsedTextGetText(java.lang.Integer index)
get an unparsed textjava.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
-
-
-
Field Detail
-
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
protected 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
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
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
- block type
-
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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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 nulljava.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 nulljava.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
-
getInput
@Deprecated public java.lang.Boolean getInput()
Deprecated.UsegetBlockType()
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
@Deprecated public java.lang.Boolean getOutput()
Deprecated.UsegetBlockType()
Only valid for block2, only when using hibernate for persistence- Returns:
true
if message block type is2O
-
setOutput
public void setOutput(java.lang.Boolean output)
Only valid for block2, only when using hibernate for persistence- Parameters:
output
- the is output parameter
-
-