jPOS 1.6.1 API Documentation

org.jpos.iso
Class ISOMsg

java.lang.Object
  extended by org.jpos.iso.ISOComponent
      extended by org.jpos.iso.ISOMsg
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, Loggeable
Direct Known Subclasses:
ISOVMsg

public class ISOMsg
extends ISOComponent
implements java.lang.Cloneable, Loggeable, java.io.Externalizable

implements Composite whithin a Composite pattern

Version:
$Id: ISOMsg.java 2599 2008-01-28 03:38:34Z apr $
Author:
apr@cs.com.uy
See Also:
ISOComponent, ISOField, Serialized Form

Field Summary
static int INCOMING
           
static int OUTGOING
           
 
Constructor Summary
ISOMsg()
          Creates an ISOMsg
ISOMsg(int fieldNumber)
          Creates a nested ISOMsg
ISOMsg(java.lang.String mti)
          Creates an ISOMsg with given mti
 
Method Summary
 java.lang.Object clone()
           
 java.lang.Object clone(int[] fields)
          Partially clone an ISOMsg
 void dump(java.io.PrintStream p, java.lang.String indent)
          dump the message to a PrintStream.
 byte[] getBytes(int fldno)
          Return the byte[] value associated with the given ISOField number
 byte[] getBytes(java.lang.String fpath)
          Return the String value associated with the given field path
 java.util.Hashtable getChildren()
          clone fields
 ISOComponent getComponent(int fldno)
          get the component associated with the given field number
 ISOComponent getComposite()
          In order to interchange Composites and Leafs we use getComposite().
 int getDirection()
           
 byte[] getHeader()
          get optional message header image
 ISOHeader getISOHeader()
          Return this messages ISOHeader
 java.lang.Object getKey()
          valid on Leafs only.
 int getMaxField()
          a Composite must override this function
 java.lang.String getMTI()
           
 ISOPackager getPackager()
           
 ISOSource getSource()
           
 java.lang.String getString(int fldno)
          Return the String value associated with the given ISOField number
 java.lang.String getString(java.lang.String fpath)
          Return the String value associated with the given field path
 java.lang.Object getValue()
          valid on Leafs only.
 java.lang.Object getValue(int fldno)
          Return the object value associated with the given field number
 java.lang.Object getValue(java.lang.String fpath)
          Return the object value associated with the given field path
 boolean hasField(int fldno)
          Check if a given field is present
 boolean hasFields(int[] fields)
          Check if all fields are present
 boolean isIncoming()
           
 boolean isInner()
           
 boolean isOutgoing()
           
 boolean isRequest()
           
 boolean isResponse()
           
 boolean isRetransmission()
           
 void merge(ISOMsg m)
          add all fields present on received parameter to this ISOMsg
please note that received fields take precedence over existing ones (simplifying card agent message creation and template handling)
 void move(int oldFieldNumber, int newFieldNumber)
          moves a field (renumber)
 byte[] pack()
          pack the message with the current packager
 void readExternal(java.io.ObjectInput in)
           
 void recalcBitMap()
          setup BitMap
 void set(int fldno, byte[] value)
          Creates an ISOBinaryField associated with fldno within this ISOMsg
 void set(int fldno, java.lang.String value)
          Creates an ISOField associated with fldno within this ISOMsg
 void set(ISOComponent c)
          Set a field within this message
 void set(java.lang.String fpath, byte[] value)
          Creates an ISOField associated with fldno within this ISOMsg
 void set(java.lang.String fpath, java.lang.String value)
          Creates an ISOField associated with fldno within this ISOMsg
 void setDirection(int direction)
          Sets the direction information related to this message
 void setFieldNumber(int fieldNumber)
          changes this Component field number
Use with care, this method does not change any reference held by a Composite.
 void setHeader(byte[] b)
          Sets an optional message header image
 void setHeader(ISOHeader header)
           
 void setMTI(java.lang.String mti)
           
 void setPackager(ISOPackager p)
           
 void setResponseMTI()
          sets an appropiate response MTI.
 void setRetransmissionMTI()
          sets an appropiate retransmission MTI
 void setSource(ISOSource source)
          Let this ISOMsg object hold a weak reference to an ISOSource (usually used to carry a reference to the incoming ISOChannel)
 void setValue(java.lang.Object obj)
          Don't call setValue on an ISOMsg.
 java.lang.String toString()
           
 int unpack(byte[] b)
          unpack a message
 void unpack(java.io.InputStream in)
           
 void unset(int fldno)
          Unset a field if it exists, otherwise ignore.
 void unset(int[] flds)
          Unsets several fields at once
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.jpos.iso.ISOComponent
getBytes, pack
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INCOMING

public static final int INCOMING
See Also:
Constant Field Values

OUTGOING

public static final int OUTGOING
See Also:
Constant Field Values
Constructor Detail

ISOMsg

public ISOMsg()
Creates an ISOMsg


ISOMsg

public ISOMsg(int fieldNumber)
Creates a nested ISOMsg


ISOMsg

public ISOMsg(java.lang.String mti)
Creates an ISOMsg with given mti

Parameters:
mti - Msg's MTI
Method Detail

setFieldNumber

public void setFieldNumber(int fieldNumber)
changes this Component field number
Use with care, this method does not change any reference held by a Composite.

Specified by:
setFieldNumber in class ISOComponent
Parameters:
fieldNumber - new field number

setDirection

public void setDirection(int direction)
Sets the direction information related to this message

Parameters:
direction - can be either ISOMsg.INCOMING or ISOMsg.OUTGOING

setHeader

public void setHeader(byte[] b)
Sets an optional message header image

Parameters:
b - header image

setHeader

public void setHeader(ISOHeader header)

getHeader

public byte[] getHeader()
get optional message header image

Returns:
message header image (may be null)

getISOHeader

public ISOHeader getISOHeader()
Return this messages ISOHeader


getDirection

public int getDirection()
Returns:
the direction (ISOMsg.INCOMING or ISOMsg.OUTGOING)
See Also:
ISOChannel

isIncoming

public boolean isIncoming()
Returns:
true if this message is an incoming message
See Also:
ISOChannel

isOutgoing

public boolean isOutgoing()
Returns:
true if this message is an outgoing message
See Also:
ISOChannel

getMaxField

public int getMaxField()
Description copied from class: ISOComponent
a Composite must override this function

Overrides:
getMaxField in class ISOComponent
Returns:
the max field number associated with this message

setPackager

public void setPackager(ISOPackager p)
Parameters:
p - - a peer packager

getPackager

public ISOPackager getPackager()
Returns:
the peer packager

set

public void set(ISOComponent c)
         throws ISOException
Set a field within this message

Overrides:
set in class ISOComponent
Parameters:
c - - a component
Throws:
ISOException

set

public void set(int fldno,
                java.lang.String value)
         throws ISOException
Creates an ISOField associated with fldno within this ISOMsg

Parameters:
fldno - field number
value - field value
Throws:
ISOException

set

public void set(java.lang.String fpath,
                java.lang.String value)
         throws ISOException
Creates an ISOField associated with fldno within this ISOMsg

Parameters:
fpath - dot-separated field path (i.e. 63.2)
value - field value
Throws:
ISOException

set

public void set(java.lang.String fpath,
                byte[] value)
         throws ISOException
Creates an ISOField associated with fldno within this ISOMsg

Parameters:
fpath - dot-separated field path (i.e. 63.2)
value - binary field value
Throws:
ISOException

set

public void set(int fldno,
                byte[] value)
         throws ISOException
Creates an ISOBinaryField associated with fldno within this ISOMsg

Parameters:
fldno - field number
value - field value
Throws:
ISOException

unset

public void unset(int fldno)
Unset a field if it exists, otherwise ignore.

Overrides:
unset in class ISOComponent
Parameters:
fldno - - the field number

unset

public void unset(int[] flds)
Unsets several fields at once

Parameters:
flds - - array of fields to be unset from this ISOMsg

getComposite

public ISOComponent getComposite()
In order to interchange Composites and Leafs we use getComposite(). A Composite component returns itself and a Leaf returns null.

Overrides:
getComposite in class ISOComponent
Returns:
ISOComponent

recalcBitMap

public void recalcBitMap()
                  throws ISOException
setup BitMap

Throws:
ISOException

getChildren

public java.util.Hashtable getChildren()
clone fields

Overrides:
getChildren in class ISOComponent
Returns:
children (in this case 0 children)

pack

public byte[] pack()
            throws ISOException
pack the message with the current packager

Specified by:
pack in class ISOComponent
Returns:
the packed message
Throws:
ISOException

unpack

public int unpack(byte[] b)
           throws ISOException
unpack a message

Specified by:
unpack in class ISOComponent
Parameters:
b - - raw message
Returns:
consumed bytes
Throws:
ISOException

unpack

public void unpack(java.io.InputStream in)
            throws java.io.IOException,
                   ISOException
Specified by:
unpack in class ISOComponent
Throws:
java.io.IOException
ISOException

dump

public void dump(java.io.PrintStream p,
                 java.lang.String indent)
dump the message to a PrintStream. The output is sorta XML, intended to be easily parsed.
Each component is responsible for its own dump function, ISOMsg just calls dump on every valid field.

Specified by:
dump in interface Loggeable
Specified by:
dump in class ISOComponent
Parameters:
p - - print stream
indent - - optional indent string

getComponent

public ISOComponent getComponent(int fldno)
get the component associated with the given field number

Parameters:
fldno - the Field Number
Returns:
the Component

getValue

public java.lang.Object getValue(int fldno)
                          throws ISOException
Return the object value associated with the given field number

Parameters:
fldno - the Field Number
Returns:
the field Object
Throws:
ISOException

getValue

public java.lang.Object getValue(java.lang.String fpath)
                          throws ISOException
Return the object value associated with the given field path

Parameters:
fpath - field path
Returns:
the field Object (may be null)
Throws:
ISOException

getString

public java.lang.String getString(int fldno)
Return the String value associated with the given ISOField number

Parameters:
fldno - the Field Number
Returns:
field's String value

getString

public java.lang.String getString(java.lang.String fpath)
Return the String value associated with the given field path

Parameters:
fpath - field path
Returns:
field's String value (may be null)

getBytes

public byte[] getBytes(int fldno)
Return the byte[] value associated with the given ISOField number

Parameters:
fldno - the Field Number
Returns:
field's byte[] value

getBytes

public byte[] getBytes(java.lang.String fpath)
Return the String value associated with the given field path

Parameters:
fpath - field path
Returns:
field's byte[] value (may be null)

hasField

public boolean hasField(int fldno)
Check if a given field is present

Parameters:
fldno - the Field Number
Returns:
boolean indicating the existence of the field

hasFields

public boolean hasFields(int[] fields)
Check if all fields are present

Parameters:
fields - an array of fields to check for presence
Returns:
true if all fields are present

setValue

public void setValue(java.lang.Object obj)
              throws ISOException
Don't call setValue on an ISOMsg. You'll sure get an ISOException. It's intended to be used on Leafs

Specified by:
setValue in class ISOComponent
Throws:
ISOException
See Also:
ISOField, ISOException

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

clone

public java.lang.Object clone(int[] fields)
Partially clone an ISOMsg

Parameters:
fields - int array of fields to go
Returns:
new ISOMsg instance

merge

public void merge(ISOMsg m)
add all fields present on received parameter to this ISOMsg
please note that received fields take precedence over existing ones (simplifying card agent message creation and template handling)

Parameters:
m - ISOMsg to merge

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a string suitable for a log

getKey

public java.lang.Object getKey()
                        throws ISOException
Description copied from class: ISOComponent
valid on Leafs only. The value returned is used by ISOMsg as a key to this field.

Overrides:
getKey in class ISOComponent
Returns:
object representing the field number
Throws:
ISOException

getValue

public java.lang.Object getValue()
Description copied from class: ISOComponent
valid on Leafs only.

Overrides:
getValue in class ISOComponent
Returns:
object representing the field value

isInner

public boolean isInner()
Returns:
true on inner messages

setMTI

public void setMTI(java.lang.String mti)
            throws ISOException
Parameters:
mti - new MTI
Throws:
ISOException - if message is inner message

move

public void move(int oldFieldNumber,
                 int newFieldNumber)
          throws ISOException
moves a field (renumber)

Parameters:
oldFieldNumber - old field number
newFieldNumber - new field number
Throws:
ISOException

getMTI

public java.lang.String getMTI()
                        throws ISOException
Returns:
current MTI
Throws:
ISOException - on inner message or MTI not set

isRequest

public boolean isRequest()
                  throws ISOException
Returns:
true if message "seems to be" a request
Throws:
ISOException - on MTI not set

isResponse

public boolean isResponse()
                   throws ISOException
Returns:
true if message "seems not to be" a request
Throws:
ISOException - on MTI not set

isRetransmission

public boolean isRetransmission()
                         throws ISOException
Returns:
true if message is Retransmission
Throws:
ISOException - on MTI not set

setResponseMTI

public void setResponseMTI()
                    throws ISOException
sets an appropiate response MTI. i.e. 0100 becomes 0110
i.e. 0201 becomes 0210
i.e. 1201 becomes 1210

Throws:
ISOException - on MTI not set or it is not a request

setRetransmissionMTI

public void setRetransmissionMTI()
                          throws ISOException
sets an appropiate retransmission MTI

Throws:
ISOException - on MTI not set or it is not a request

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

setSource

public void setSource(ISOSource source)
Let this ISOMsg object hold a weak reference to an ISOSource (usually used to carry a reference to the incoming ISOChannel)

Parameters:
source - an ISOSource

getSource

public ISOSource getSource()
Returns:
an ISOSource or null

jPOS.org