Class ISOMsg
java.lang.Object
org.jpos.iso.ISOComponent
org.jpos.iso.ISOMsg
- All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Loggeable
- Direct Known Subclasses:
FSDISOMsg, ISOMsgRef.Ref, ISOVMsg
implements Composite
within a Composite pattern
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected booleanprotected intprotected ISOHeaderstatic final intprotected intprotected booleanstatic final intprotected ISOPackagerprotected byte[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()clone(int... fields) Partially clone an ISOMsgPartially clone an ISOMsg by field pathsvoiddump(PrintStream p, String indent) dump the message to a PrintStream.byte[]getBytes(int fldno) Return the byte[] value associated with the given ISOField numberbyte[]Return the String value associated with the given field pathclone fieldsgetComponent(int fldno) get the component associated with the given field numbergetComponent(String fpath) get the component associated with the given field numberIn order to interchange Composites and Leafs we use getComposite().intintbyte[]get optional message header imageReturn this messages ISOHeadergetKey()valid on Leafs only.inta Composite must override this functiongetMTI()getString(int fldno) Return the String value associated with the given ISOField numberReturn the String value associated with the given field pathbyte[]Get optional trailer image.getValue()valid on Leafs only.getValue(int fldno) Return the object value associated with the given field numberReturn the object value associated with the given field pathbooleanhasAny(int[] fields) Check if the message has any of these fieldsbooleanCheck if the message has any of these fieldsbooleanhasField(int fldno) Check if a given field is presentbooleanCheck if a field indicated by a fpath is presentbooleanbooleanhasFields(int[] fields) Check if all fields are presentbooleanhasMTI()booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisInner()booleanbooleanbooleanbooleanbooleanbooleanbooleanvoidvoidMerges the content of the specified ISOMsg into this ISOMsg instance.voidmove(int oldFieldNumber, int newFieldNumber) moves a field (renumber)byte[]pack()pack the message with the current packagerprotected voidvoidprotected voidprotected voidvoidsetup BitMapvoidset(int fldno, byte[] value) Creates an ISOBinaryField associated with fldno within this ISOMsg.voidCreates an ISOField associated with fldno within this ISOMsg.voidCreates an ISOField associated with fldno within this ISOMsg.voidCreates an ISOField associated with fldno within this ISOMsg.voidset(String fpath, ISOComponent c) Creates an ISOField associated with fldno within this ISOMsgvoidset(ISOComponent c) Set a field within this messagevoidsetDirection(int direction) Sets the direction information related to this messagevoidsetFieldNumber(int fieldNumber) changes this Component field number
Use with care, this method does not change any reference held by a Composite.voidsetHeader(byte[] b) Sets an optional message header imagevoidvoidvoidvoidsets an appropriate response MTI.voidsets an appropriate retransmission MTIvoidLet this ISOMsg object hold a weak reference to an ISOSource (usually used to carry a reference to the incoming ISOChannel)voidsetTrailer(byte[] trailer) Sets optional trailer data.voidDon't call setValue on an ISOMsg.toString()intunpack(byte[] b) unpack a messagevoidunpack(InputStream in) voidunset(int fldno) Unset a field if it exists, otherwise ignore.voidunset(int... flds) Unsets several fields at oncevoidUnset a field referenced by a fpath if it exists, otherwise ignore.voidUnset a a set of fields referenced by fpaths if any ot them exist, otherwise ignore.protected voidvoidprotected voidwriteHeader(ObjectOutput out) protected voidMethods inherited from class ISOComponent
getBytes, pack
-
Field Details
-
fields
-
maxField
-
packager
-
dirty
-
maxFieldDirty
-
direction
-
header
-
trailer
-
fieldNumber
-
INCOMING
- See Also:
-
OUTGOING
- See Also:
-
-
Constructor Details
-
ISOMsg
public ISOMsg()Creates an ISOMsg -
ISOMsg
Creates a nested ISOMsg- Parameters:
fieldNumber- (in the outer ISOMsg) of this nested message
-
ISOMsg
-
-
Method Details
-
setFieldNumber
changes this Component field number
Use with care, this method does not change any reference held by a Composite.- Specified by:
setFieldNumberin classISOComponent- Parameters:
fieldNumber- new field number
-
setDirection
Sets the direction information related to this message- Parameters:
direction- can be either ISOMsg.INCOMING or ISOMsg.OUTGOING
-
setHeader
-
setHeader
-
getHeader
get optional message header image- Returns:
- message header image (may be null)
-
setTrailer
Sets optional trailer data. Note: The trailer data requires a customised channel that explicitly handles the trailer data from the ISOMsg.- Parameters:
trailer- The trailer data.
-
getTrailer
-
getISOHeader
Return this messages ISOHeader- Returns:
- header associated with this ISOMsg, can be null
-
getDirection
- Returns:
- the direction (ISOMsg.INCOMING or ISOMsg.OUTGOING)
- See Also:
-
isIncoming
- Returns:
- true if this message is an incoming message
- See Also:
-
isOutgoing
- Returns:
- true if this message is an outgoing message
- See Also:
-
getMaxField
Description copied from class:ISOComponenta Composite must override this function- Overrides:
getMaxFieldin classISOComponent- Returns:
- the max field number associated with this message
-
setPackager
- Parameters:
p- - a peer packager
-
getPackager
- Returns:
- the peer packager
-
set
Set a field within this message- Overrides:
setin classISOComponent- Parameters:
c- - a component- Throws:
ISOException
-
set
-
set
-
set
Creates an ISOField associated with fldno within this ISOMsg- Parameters:
fpath- dot-separated field path (i.e. 63.2)c- component- Throws:
ISOException- on error
-
set
-
set
Creates an ISOBinaryField associated with fldno within this ISOMsg.- Parameters:
fldno- field numbervalue- field value
-
unset
Unset a field if it exists, otherwise ignore.- Overrides:
unsetin classISOComponent- Parameters:
fldno- - the field number
-
unset
Unsets several fields at once- Parameters:
flds- - array of fields to be unset from this ISOMsg
-
unset
-
unset
-
getComposite
In order to interchange Composites and Leafs we use getComposite(). A Composite component returns itself and a Leaf returns null.- Overrides:
getCompositein classISOComponent- Returns:
- ISOComponent
-
recalcBitMap
-
getChildren
clone fields- Overrides:
getChildrenin classISOComponent- Returns:
- copy of fields
-
pack
pack the message with the current packager- Specified by:
packin classISOComponent- Returns:
- the packed message
- Throws:
ISOException
-
unpack
unpack a message- Specified by:
unpackin classISOComponent- Parameters:
b- - raw message- Returns:
- consumed bytes
- Throws:
ISOException
-
unpack
- Specified by:
unpackin classISOComponent- Throws:
IOExceptionISOException
-
dump
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:
dumpin interfaceLoggeable- Specified by:
dumpin classISOComponent- Parameters:
p- - print streamindent- - optional indent string
-
getComponent
get the component associated with the given field number- Parameters:
fldno- the Field Number- Returns:
- the Component
-
getValue
-
getValue
Return the object value associated with the given field path- Parameters:
fpath- field path- Returns:
- the field Object (may be null)
- Throws:
ISOException- on error
-
getComponent
get the component associated with the given field number- Parameters:
fpath- field path- Returns:
- the Component
- Throws:
ISOException- on error
-
getString
-
getString
-
getBytes
Return the byte[] value associated with the given ISOField number- Parameters:
fldno- the Field Number- Returns:
- field's byte[] value or null if ISOException or UnsupportedEncodingException happens
-
getBytes
-
hasField
Check if a given field is present- Parameters:
fldno- the Field Number- Returns:
- boolean indicating the existence of the field
-
hasFields
Check if all fields are present- Parameters:
fields- an array of fields to check for presence- Returns:
- true if all fields are present
-
hasAny
Check if the message has any of these fields- Parameters:
fields- an array of fields to check for presence- Returns:
- true if at least one field is present
-
hasAny
-
hasField
-
hasFields
- Returns:
- true if ISOMsg has at least one field
-
setValue
Don't call setValue on an ISOMsg. You'll sure get an ISOException. It's intended to be used on Leafs- Specified by:
setValuein classISOComponent- Parameters:
obj-- Throws:
ISOException- See Also:
-
clone
-
clone
-
clone
-
merge
Merges the content of the specified ISOMsg into this ISOMsg instance. It iterates over the fields of the input message and, for each field that is present, sets the corresponding component in this message to the value from the input message. This operation includes all fields that are present in the input message, but does not remove any existing fields from this message unless they are explicitly overwritten by the input message.If the input message contains a header (non-null), this method also clones the header and sets it as the header of this message.
- Parameters:
m- The ISOMsg to merge into this ISOMsg. It must not benull. The method does nothing ifmisnull.mergeHeader- A boolean flag indicating whether to merge the header of the input message into this message.
-
merge
-
toString
-
getKey
Description copied from class:ISOComponentvalid on Leafs only. The value returned is used by ISOMsg as a key to this field.- Overrides:
getKeyin classISOComponent- Returns:
- object representing the field number
- Throws:
ISOException
-
getValue
Description copied from class:ISOComponentvalid on Leafs only.- Overrides:
getValuein classISOComponent- Returns:
- object representing the field value
-
isInner
- Returns:
- true on inner messages
-
setMTI
- Parameters:
mti- new MTI- Throws:
ISOException- if message is inner message
-
move
moves a field (renumber)- Parameters:
oldFieldNumber- old field numbernewFieldNumber- new field number- Throws:
ISOException- on error
-
getFieldNumber
- Specified by:
getFieldNumberin classISOComponent
-
hasMTI
- Returns:
- true is message has MTI field
- Throws:
ISOException- if this is an inner message
-
getMTI
- Returns:
- current MTI
- Throws:
ISOException- on inner message or MTI not set
-
isRequest
- Returns:
- true if message "seems to be" a request
- Throws:
ISOException- on MTI not set
-
isResponse
- Returns:
- true if message "seems not to be" a request
- Throws:
ISOException- on MTI not set
-
isAuthorization
- Returns:
- true if message class is "authorization"
- Throws:
ISOException- on MTI not set
-
isFinancial
- Returns:
- true if message class is "financial"
- Throws:
ISOException- on MTI not set
-
isFileAction
- Returns:
- true if message class is "file action"
- Throws:
ISOException- on MTI not set
-
isReversal
- Returns:
- true if message class is "reversal"
- Throws:
ISOException- on MTI not set
-
isChargeback
- Returns:
- true if message class is "chargeback"
- Throws:
ISOException- on MTI not set
-
isReconciliation
- Returns:
- true if message class is "reconciliation"
- Throws:
ISOException- on MTI not set
-
isAdministrative
- Returns:
- true if message class is "administrative"
- Throws:
ISOException- on MTI not set
-
isFeeCollection
- Returns:
- true if message class is "fee collection"
- Throws:
ISOException- on MTI not set
-
isNetworkManagement
- Returns:
- true if message class is "fee collection"
- Throws:
ISOException- on MTI not set
-
isRetransmission
- Returns:
- true if message is Retransmission
- Throws:
ISOException- on MTI not set
-
setResponseMTI
sets an appropriate 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
sets an appropriate retransmission MTI- Throws:
ISOException- on MTI not set or it is not a request
-
writeHeader
- Throws:
IOException
-
readHeader
- Throws:
IOExceptionClassNotFoundException
-
writePackager
- Throws:
IOException
-
readPackager
- Throws:
IOExceptionClassNotFoundException
-
writeDirection
- Throws:
IOException
-
readDirection
- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
setSource
-
getSource
-