Class MessageErrorIndicator

java.lang.Object
org.jpos.iso.MessageErrorIndicator

public class MessageErrorIndicator extends Object
Encodes and decodes the ISO 8583 Message Error Indicator (DE-018).

DE-018 carries up to ten error sets, each exactly 14 positions long. Each set identifies the type of error and the precise location within the message (data element, sub-element for constructed fields, or dataset identifier plus bit/tag for composite fields).

Error sets are concatenated without separators. The overall field is transmitted as an LLLVAR character field.

Error set wire layout

 Pos  Len  Type        Subfield
 1–2    2  N2 (ASCII)  Error severity
 3–6    4  N4 (ASCII)  Message error code
 7–9    3  N3 (ASCII)  Data element in error (001–128)
10–11   2  N2 (ASCII)  Data sub-element in error (constructed DEs), else "00"
  12    1  B1 (binary) Dataset identifier (composite DEs), else 0x00
13–14   2  B2 (binary) Dataset bit or TLV tag (composite DEs), else 0x0000

Usage:

MessageErrorIndicator mei = new MessageErrorIndicator()
    .add(FieldError.primitiveError(ErrorCode.REQUIRED_MISSING, 37))
    .add(FieldError.compositeError(ErrorCode.INVALID_VALUE, 55, 0x37, 0x9F26));

msg.set(18, new String(mei.pack(), ISOUtil.CHARSET));

// or

MessageErrorIndicator parsed = MessageErrorIndicator.unpack(msg.getBytes(18));
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • add

      Appends an error set.
      Parameters:
      error - error set to add
      Returns:
      this indicator for fluent chaining
      Throws:
      IllegalStateException - when the maximum of 10 error sets has been reached
    • errors

      Returns an unmodifiable view of the current error sets.
      Returns:
      error set list
    • isEmpty

      public boolean isEmpty()
      Indicates whether this indicator contains no error sets.
      Returns:
      true when empty
    • size

      public int size()
      Returns the number of error sets.
      Returns:
      error set count
    • pack

      public byte[] pack()
      Serializes all error sets to the DE-018 wire format.
      Returns:
      packed bytes suitable for setting on DE-018 of an ISOMsg
    • unpack

      public static MessageErrorIndicator unpack(byte[] data) throws ISOException
      Deserializes DE-018 wire bytes into a MessageErrorIndicator.
      Parameters:
      data - DE-018 field bytes (must be a multiple of 14)
      Returns:
      parsed indicator
      Throws:
      ISOException - when the byte array is malformed