Package org.jpos.iso

Class ISOMsg

    • Constructor Summary

      Constructors 
      Constructor Description
      ISOMsg()
      Creates an ISOMsg
      ISOMsg​(int fieldNumber)
      Creates a nested ISOMsg
      ISOMsg​(java.lang.String mti)
      Creates an ISOMsg with given mti
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()  
      java.lang.Object clone​(int... fields)
      Partially clone an ISOMsg
      ISOMsg clone​(java.lang.String... fpaths)
      Partially clone an ISOMsg by field paths
      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.Map getChildren()
      clone fields
      ISOComponent getComponent​(int fldno)
      get the component associated with the given field number
      ISOComponent getComponent​(java.lang.String fpath)
      get the component associated with the given field number
      ISOComponent getComposite()
      In order to interchange Composites and Leafs we use getComposite().
      int getDirection()  
      int getFieldNumber()  
      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
      byte[] getTrailer()
      Get optional trailer image.
      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 hasAny​(int[] fields)
      Check if the message has any of these fields
      boolean hasAny​(java.lang.String... fields)
      Check if the message has any of these fields
      boolean hasField​(int fldno)
      Check if a given field is present
      boolean hasField​(java.lang.String fpath)
      Check if a field indicated by a fpath is present
      boolean hasFields()  
      boolean hasFields​(int[] fields)
      Check if all fields are present
      boolean hasMTI()  
      boolean isAdministrative()  
      boolean isAuthorization()  
      boolean isChargeback()  
      boolean isFeeCollection()  
      boolean isFileAction()  
      boolean isFinancial()  
      boolean isIncoming()  
      boolean isInner()  
      boolean isNetworkManagement()  
      boolean isOutgoing()  
      boolean isReconciliation()  
      boolean isRequest()  
      boolean isResponse()  
      boolean isRetransmission()  
      boolean isReversal()  
      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
      protected void readDirection​(java.io.ObjectInput in)  
      void readExternal​(java.io.ObjectInput in)  
      protected void readHeader​(java.io.ObjectInput in)  
      protected void readPackager​(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​(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 set​(java.lang.String fpath, ISOComponent c)
      Creates an ISOField associated with fldno within this ISOMsg
      void set​(ISOComponent c)
      Set a field within this message
      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 appropriate response MTI.
      void setRetransmissionMTI()
      sets an appropriate 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 setTrailer​(byte[] trailer)
      Sets optional trailer data.
      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 unset​(java.lang.String fpath)
      Unset a field referenced by a fpath if it exists, otherwise ignore.
      void unset​(java.lang.String... fpaths)
      Unset a set of fields referenced by fpaths, if any of them exist.
      protected void writeDirection​(java.io.ObjectOutput out)  
      void writeExternal​(java.io.ObjectOutput out)  
      protected void writeHeader​(java.io.ObjectOutput out)  
      protected void writePackager​(java.io.ObjectOutput out)  
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ISOMsg

        public ISOMsg()
        Creates an ISOMsg
      • ISOMsg

        public ISOMsg​(int fieldNumber)
        Creates a nested ISOMsg
        Parameters:
        fieldNumber - (in the outer ISOMsg) of this nested message
      • 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
      • getHeader

        public byte[] getHeader()
        get optional message header image
        Returns:
        message header image (may be null)
      • setTrailer

        public void setTrailer​(byte[] trailer)
        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

        public byte[] getTrailer()
        Get optional trailer image.
        Returns:
        message trailer image (may be null)
      • getISOHeader

        public ISOHeader getISOHeader()
        Return this messages ISOHeader
        Returns:
        header associated with this ISOMsg, can be null
      • 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
      • set

        public void set​(int fldno,
                        java.lang.String value)
        Creates an ISOField associated with fldno within this ISOMsg.
        Parameters:
        fldno - field number
        value - field value
      • set

        public void set​(java.lang.String fpath,
                        java.lang.String value)
        Creates an ISOField associated with fldno within this ISOMsg.
        Parameters:
        fpath - dot-separated field path (i.e. 63.2)
        value - field value
      • set

        public void set​(java.lang.String fpath,
                        ISOComponent c)
                 throws ISOException
        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

        public void set​(java.lang.String fpath,
                        byte[] value)
        Creates an ISOField associated with fldno within this ISOMsg.
        Parameters:
        fpath - dot-separated field path (i.e. 63.2)
        value - binary field value
      • set

        public void set​(int fldno,
                        byte[] value)
        Creates an ISOBinaryField associated with fldno within this ISOMsg.
        Parameters:
        fldno - field number
        value - field value
      • 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
      • unset

        public void unset​(java.lang.String fpath)
        Unset a field referenced by a fpath if it exists, otherwise ignore.
        Parameters:
        fpath - dot-separated field path (i.e. 63.2)
      • unset

        public void unset​(java.lang.String... fpaths)
        Unset a set of fields referenced by fpaths, if any of them exist. Otherwise, ignore.
        Parameters:
        fpaths - dot-separated field paths (i.e. 63.2)
      • 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
      • 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)
        Return the object value associated with the given field number
        Parameters:
        fldno - the Field Number
        Returns:
        the field Object
      • 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 - on error
      • getComponent

        public ISOComponent getComponent​(java.lang.String fpath)
                                  throws ISOException
        get the component associated with the given field number
        Parameters:
        fpath - field path
        Returns:
        the Component
        Throws:
        ISOException - on error
      • 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 or null if ISOException or UnsupportedEncodingException happens
      • 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
      • hasAny

        public boolean hasAny​(int[] fields)
        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

        public boolean hasAny​(java.lang.String... fields)
        Check if the message has any of these fields
        Parameters:
        fields - to check for presence
        Returns:
        true if at least one field is present
      • hasField

        public boolean hasField​(java.lang.String fpath)
        Check if a field indicated by a fpath is present
        Parameters:
        fpath - dot-separated field path (i.e. 63.2)
        Returns:
        true if field present
      • hasFields

        public boolean hasFields()
        Returns:
        true if ISOMsg has at least one field
      • 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
      • clone

        public ISOMsg clone​(java.lang.String... fpaths)
        Partially clone an ISOMsg by field paths
        Parameters:
        fpaths - string array of field paths to copy
        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
      • 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 - on error
      • setResponseMTI

        public void setResponseMTI()
                            throws ISOException
        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
      • writeHeader

        protected void writeHeader​(java.io.ObjectOutput out)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • readHeader

        protected void readHeader​(java.io.ObjectInput in)
                           throws java.io.IOException,
                                  java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writePackager

        protected void writePackager​(java.io.ObjectOutput out)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • readPackager

        protected void readPackager​(java.io.ObjectInput in)
                             throws java.io.IOException,
                                    java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeDirection

        protected void writeDirection​(java.io.ObjectOutput out)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readDirection

        protected void readDirection​(java.io.ObjectInput in)
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • 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