Class BaseHeader

java.lang.Object
org.jpos.iso.header.BaseHeader
All Implemented Interfaces:
Serializable, Cloneable, ISOHeader, Loggeable
Direct Known Subclasses:
BASE1Header

public class BaseHeader extends Object implements ISOHeader, Loggeable
Base implementation of ISOHeader providing common header handling for ISO-8583 channels.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected byte[]
    Raw header bytes.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default Constructor.
    BaseHeader(byte[] header)
    Creates a BaseHeader wrapping the given raw bytes.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a clone of this ISOHeader.
    void
    dump(PrintStream p, String indent)
    Dumps a human-readable representation of this object to the print stream.
    Returns the destination address in this ISOHeader.
    int
    Returns the number of bytes in this ISOHeader when packed.
    Returns the source address in this ISOHeader.
    boolean
    Returns true if ASCII encoding is used for source/destination fields.
    byte[]
    Packs this header into a byte array.
    void
    setAsciiEncoding(boolean asciiEncoding)
    Sets the encoding for source/destination fields.
    void
    Sets the destination address in this ISOHeader.
    void
    Sets the source address in this ISOHeader.
    void
    Swaps the source and destination addresses in this ISOHeader (if they exist).
    int
    unpack(byte[] header)
    Unpacks the header from a raw byte array.

    Methods inherited from class Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Loggeable

    dump
    Modifier and Type
    Method
    Description
    default void
    Dumps a representation of this object using the specified renderer type.
  • Field Details

  • Constructor Details

    • BaseHeader

      public BaseHeader()
      Default Constructor. Used by Class.forName.newInstance(...);
    • BaseHeader

      public BaseHeader(byte[] header)
      Creates a BaseHeader wrapping the given raw bytes.
      Parameters:
      header - raw header bytes
  • Method Details

    • clone

      public Object clone()
      Description copied from interface: ISOHeader
      Returns a clone of this ISOHeader.
      Specified by:
      clone in interface ISOHeader
      Overrides:
      clone in class Object
      Returns:
      cloned ISOHeader instance
    • pack

      public byte[] pack()
      Description copied from interface: ISOHeader
      Packs this header into a byte array.
      Specified by:
      pack in interface ISOHeader
      Returns:
      this header serialised as a byte array
    • unpack

      public int unpack(byte[] header)
      Description copied from interface: ISOHeader
      Unpacks the header from a raw byte array.
      Specified by:
      unpack in interface ISOHeader
      Parameters:
      header - raw bytes to parse
      Returns:
      the number of bytes consumed
    • getLength

      public int getLength()
      Description copied from interface: ISOHeader
      Returns the number of bytes in this ISOHeader when packed.
      Specified by:
      getLength in interface ISOHeader
      Returns:
      header length in bytes
    • setDestination

      public void setDestination(String dst)
      Description copied from interface: ISOHeader
      Sets the destination address in this ISOHeader.
      Specified by:
      setDestination in interface ISOHeader
      Parameters:
      dst - the destination address
    • setSource

      public void setSource(String src)
      Description copied from interface: ISOHeader
      Sets the source address in this ISOHeader.
      Specified by:
      setSource in interface ISOHeader
      Parameters:
      src - the source address
    • getDestination

      Description copied from interface: ISOHeader
      Returns the destination address in this ISOHeader.
      Specified by:
      getDestination in interface ISOHeader
      Returns:
      the destination address, or null if not set
    • getSource

      public String getSource()
      Description copied from interface: ISOHeader
      Returns the source address in this ISOHeader.
      Specified by:
      getSource in interface ISOHeader
      Returns:
      the source address, or null if not set
    • swapDirection

      public void swapDirection()
      Description copied from interface: ISOHeader
      Swaps the source and destination addresses in this ISOHeader (if they exist).
      Specified by:
      swapDirection in interface ISOHeader
    • dump

      public void dump(PrintStream p, String indent)
      Description copied from interface: Loggeable
      Dumps a human-readable representation of this object to the print stream.
      Specified by:
      dump in interface Loggeable
      Parameters:
      p - the output stream
      indent - indentation prefix
    • setAsciiEncoding

      public void setAsciiEncoding(boolean asciiEncoding)
      Sets the encoding for source/destination fields.
      Parameters:
      asciiEncoding - true for ASCII, false for BCD
    • isAsciiEncoding

      public boolean isAsciiEncoding()
      Returns true if ASCII encoding is used for source/destination fields.
      Returns:
      true if ASCII encoding is active