com.prowidesoftware.swift.model
Class SwiftBlock1

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

public class SwiftBlock1
extends SwiftValueBlock
implements java.io.Serializable

Base class for SWIFT Basic Header Block (block 1). It contains information about the source of the message.
The basic header block is fixed-length and continuous with no field delimiters. This class contains its elements as individual attributes for easier management of the block value.
This block is mandatory for all SWIFT messages.

Since:
4.0
Version:
$Id: SwiftBlock1.java,v 1.1.1.1 2013/04/10 17:04:50 mgriffa Exp $
Author:
www.prowidesoftware.com
See Also:
Serialized Form

Field Summary
static java.lang.String APPLICATION_ID_FIN
          Constant for FIN messages in application id
static java.lang.String APPLICATION_ID_GPA
          Constant for GPA (General Purpose Application) messages in application id
static java.lang.String APPLICATION_ID_LOGINS
          Constant for Logins and so messages in application id
 
Fields inherited from class com.prowidesoftware.swift.model.SwiftBlock
blockType, id, input, output, unparsedTexts
 
Constructor Summary
SwiftBlock1()
          Default constructor
SwiftBlock1(java.lang.String value)
          Creates a block 1 object setting attributes by parsing the fixed string argument;
for example "F01BANKBEBBAXXX2222123456" or "1:F01BANKBEBBAXXX2222123456"
SwiftBlock1(java.lang.String applicationId, java.lang.String serviceId, java.lang.String logicalTerminal, java.lang.String sessionNumber, java.lang.String sequenceNumber)
          Constructor for specific values
 
Method Summary
 void clean()
          Sets all attributes to null
 boolean equals(java.lang.Object obj)
           
 java.lang.String getApplicationId()
          Gets the application ID field in block 1
 java.lang.String getBlockValue()
          This method should be overwritten by subclasses, calling this method will throw a java.lang.UnsupportedOperationException
 java.lang.String getLogicalTerminal()
          Gets the The Logical Terminal address of the sender for messages sent or the receiver for messages received from the SWIFT network.
 java.lang.String getName()
          Returns the block name (the value 1 as a string)
 java.lang.Integer getNumber()
          Returns the block number (the value 1 as an integer)
 java.lang.String getSequenceNumber()
          Gets the sequence number field in block 1
 java.lang.String getServiceId()
          Gets the service ID field in block 1
 java.lang.String getSessionNumber()
          Gets the session number in block 1
 java.lang.String getValue()
          Gets the fixed length block 1 value, as a result of concatenating its individual elements as follow:
Application ID Service ID + Logical terminal (LT) address + Session number + Sequence number.
Notice that this method does not return the "1:" string.
 int hashCode()
           
 boolean isEmpty()
          Tell if this block is empty or not.
 void setApplicationId(java.lang.String applicationId)
          Sets the applicationId
protected  void setBlockName(java.lang.String blockName)
          Sets the block name.
protected  void setBlockNumber(java.lang.Integer blockNumber)
          Sets the block number.
 void setBlockValue(java.lang.String value)
          This method should be overwritten by subclasses, calling this method will throw a java.lang.UnsupportedOperationException
 void setLogicalTerminal(java.lang.String logicalTerminal)
          Sets the The Logical Terminal address of the sender for messages sent or the receiver for messages received from the SWIFT network.
 void setSender(java.lang.String BIC)
          Sets the Logical Terminal.
 void setSequenceNumber(java.lang.String sequenceNumber)
          Sets the Sequence number that is generated by the user's computer.
For all FIN messages with a Service Identifier of 01 or 05, this number is the next expected sequence number appropriate to the direction of the transmission.
For FIN messages with a Service Identifier of 21 or 25, the sequence number is that of the acknowledged service message.
It is padded with zeros.
 void setServiceId(java.lang.String serviceId)
          Sets the Service ID
 void setSessionNumber(java.lang.String sessionNumber)
          Sets the Session number.
 void setValue(java.lang.String value)
          Sets the block's attributes by parsing the fixed string argument;
for example "F01BANKBEBBAXXX2222123456" or "1:F01BANKBEBBAXXX2222123456"
 
Methods inherited from class com.prowidesoftware.swift.model.SwiftValueBlock
getValuePart, size
 
Methods inherited from class com.prowidesoftware.swift.model.SwiftBlock
getBlockType, getId, getInput, getOutput, getUnparsedTexts, getUnparsedTextsSize, isTagBlock, setBlockType, setId, setInput, setOutput, setUnparsedTexts, toString, unparsedTextAddText, unparsedTextAddText, unparsedTextGetAsMessage, unparsedTextGetText, unparsedTextIsMessage, unparsedTextVerify
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

APPLICATION_ID_FIN

public static final transient java.lang.String APPLICATION_ID_FIN
Constant for FIN messages in application id

Since:
4.1
See Also:
Constant Field Values

APPLICATION_ID_GPA

public static final transient java.lang.String APPLICATION_ID_GPA
Constant for GPA (General Purpose Application) messages in application id

Since:
4.1
See Also:
Constant Field Values

APPLICATION_ID_LOGINS

public static final transient java.lang.String APPLICATION_ID_LOGINS
Constant for Logins and so messages in application id

Since:
4.1
See Also:
Constant Field Values
Constructor Detail

SwiftBlock1

public SwiftBlock1(java.lang.String applicationId,
                   java.lang.String serviceId,
                   java.lang.String logicalTerminal,
                   java.lang.String sessionNumber,
                   java.lang.String sequenceNumber)
Constructor for specific values

Parameters:
applicationId - the application id
serviceId - the service id
logicalTerminal - the logical terminal name
sessionNumber - the session number
sequenceNumber - the message sequence number

SwiftBlock1

public SwiftBlock1()
Default constructor


SwiftBlock1

public SwiftBlock1(java.lang.String value)
Creates a block 1 object setting attributes by parsing the fixed string argument;
for example "F01BANKBEBBAXXX2222123456" or "1:F01BANKBEBBAXXX2222123456"

Parameters:
value - a fixed length string of 25 or 27 (which must start with '1:') characters containing the blocks value
Method Detail

setBlockNumber

protected void setBlockNumber(java.lang.Integer blockNumber)
Sets the block number.

Specified by:
setBlockNumber in class SwiftBlock
Parameters:
blockNumber - the block number to set
Throws:
java.lang.IllegalArgumentException - if parameter blockName is not the integer 1
Since:
5.0

setBlockName

protected void setBlockName(java.lang.String blockName)
Sets the block name. Will cause an exception unless setting block number to 1.

Specified by:
setBlockName in class SwiftBlock
Parameters:
blockName - the block name to set
Throws:
java.lang.IllegalArgumentException - if parameter blockName is not the string "1"
Since:
5.0

getNumber

public java.lang.Integer getNumber()
Returns the block number (the value 1 as an integer)

Specified by:
getNumber in class SwiftBlock
Returns:
Integer containing the block's number

getName

public java.lang.String getName()
Returns the block name (the value 1 as a string)

Specified by:
getName in class SwiftBlock
Returns:
block name
Since:
5.0

setApplicationId

public void setApplicationId(java.lang.String applicationId)
Sets the applicationId

Parameters:
applicationId - String of 1 character containing the Application ID (F, A or L)

getApplicationId

public java.lang.String getApplicationId()
Gets the application ID field in block 1

Returns:
application ID field in block 1

setServiceId

public void setServiceId(java.lang.String serviceId)
Sets the Service ID

Parameters:
serviceId - string of 2 characters containing Service ID (01, 02, 03, etc...)

getServiceId

public java.lang.String getServiceId()
Gets the service ID field in block 1

Returns:
service ID field in block 1

setLogicalTerminal

public void setLogicalTerminal(java.lang.String logicalTerminal)
Sets the The Logical Terminal address of the sender for messages sent or the receiver for messages received from the SWIFT network.

Parameters:
logicalTerminal - it is fixed at 12 characters; it must not have X in position 9 (padded with "X" if no branch is required).

setSender

public void setSender(java.lang.String BIC)
Sets the Logical Terminal.

Since:
6.4
See Also:
setLogicalTerminal(String)

getLogicalTerminal

public java.lang.String getLogicalTerminal()
Gets the The Logical Terminal address of the sender for messages sent or the receiver for messages received from the SWIFT network.

Returns:
the 12 characters logical terminal address

setSessionNumber

public void setSessionNumber(java.lang.String sessionNumber)
Sets the Session number. It is generated by the user's computer. As appropriate, the current application session number based on the Login. It is padded with zeros.

Parameters:
sessionNumber - 4 numbers.

getSessionNumber

public java.lang.String getSessionNumber()
Gets the session number in block 1

Returns:
session number in block 1

setSequenceNumber

public void setSequenceNumber(java.lang.String sequenceNumber)
Sets the Sequence number that is generated by the user's computer.
For all FIN messages with a Service Identifier of 01 or 05, this number is the next expected sequence number appropriate to the direction of the transmission.
For FIN messages with a Service Identifier of 21 or 25, the sequence number is that of the acknowledged service message.
It is padded with zeros.

Parameters:
sequenceNumber - 6 numbers

getSequenceNumber

public java.lang.String getSequenceNumber()
Gets the sequence number field in block 1

Returns:
sequence number field in block 1

isEmpty

public boolean isEmpty()
Tell if this block is empty or not. This block is considered to be empty if all its attributes are set to null.

Overrides:
isEmpty in class SwiftValueBlock
Returns:
true if all fields are null and false in other case

getValue

public java.lang.String getValue()
Gets the fixed length block 1 value, as a result of concatenating its individual elements as follow:
Application ID Service ID + Logical terminal (LT) address + Session number + Sequence number.
Notice that this method does not return the "1:" string.

Overrides:
getValue in class SwiftValueBlock
Returns:
the blocks value as a single string

getBlockValue

public java.lang.String getBlockValue()
Description copied from class: SwiftValueBlock
This method should be overwritten by subclasses, calling this method will throw a java.lang.UnsupportedOperationException

Overrides:
getBlockValue in class SwiftValueBlock
Returns:
N/A
See Also:
getValue()

setValue

public void setValue(java.lang.String value)
Sets the block's attributes by parsing the fixed string argument;
for example "F01BANKBEBBAXXX2222123456" or "1:F01BANKBEBBAXXX2222123456"

Overrides:
setValue in class SwiftValueBlock
Parameters:
value - a fixed length string of 25 or 27 (which must start with '1:') characters containing the blocks value

setBlockValue

public void setBlockValue(java.lang.String value)
Description copied from class: SwiftValueBlock
This method should be overwritten by subclasses, calling this method will throw a java.lang.UnsupportedOperationException

Overrides:
setBlockValue in class SwiftValueBlock
Parameters:
value - unused
See Also:
setValue(String)

clean

public void clean()
Sets all attributes to null

Since:
6.4

hashCode

public int hashCode()
Overrides:
hashCode in class SwiftBlock

equals

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