Beispiel #1
0
  @Override
  public int unpack(ISOComponent m, byte[] b) throws ISOException {
    LogEvent evt = new LogEvent(this, "unpack");
    int consumed = 0;
    ISOComponent c;

    // Unpack the fields
    while (consumed < b.length) {
      // Determine current tag
      int i = consumed == 0 && fld[0] != null ? 0 : tagPrefixer.decodeLength(b, consumed);

      if (!(i < fld.length) || fld[i] == null)
        throw new ISOException("Unsupported sub-field " + i + " unpacking field " + m.getKey());

      c = fld[i].createComponent(i);
      consumed += fld[i].unpack(c, b, consumed);
      if (logger != null) {
        evt.addMessage(
            "<unpack fld=\"" + i + "\" packager=\"" + fld[i].getClass().getName() + "\">");
        evt.addMessage("  <value>" + c.getValue().toString() + "</value>");
        evt.addMessage("</unpack>");
      }
      m.set(c);
    }
    Logger.log(evt);
    return consumed;
  }
 /**
  * @see
  *     com.newland.message.packager.FieldPackager.iso.ISOFieldPackager#unpack(org.jpos.iso.ISOComponent,
  *     byte[], int)
  */
 public int unpack(IField<?> c, byte[] b, int offset) throws MessageException {
   try {
     int len = prefixer.decodeLength(b, offset);
     if (len == -1) {
       // The prefixer doesn't know how long the field is, so use
       // maxLength instead
       len = getLength();
     }
     int lenLen = prefixer.getPackedLength();
     byte[] unpacked = interpreter.uninterpret(b, offset + lenLen, len);
     // logger.debug("当前解析域值:["+CodecUtils.hexString(unpacked)+"]");
     ((IField<byte[]>) c).setValue(unpacked);
     return lenLen + interpreter.getPackedLength(len);
   } catch (Exception e) {
     throw new MessageException(makeExceptionMessage(c, "unpacking"), e);
   }
 }
  @Override
  public int unpack(ISOComponent c, byte[] b, int offset) throws ISOException {
    try {
      int len = prefixer.decodeLength(b, offset);
      if (len == -1) {
        // The prefixer doesn't know how long the field is, so use
        // maxLength instead
        len = getLength(b, offset);
      }

      int lenLen = prefixer.getPackedLength();
      String unpacked = interpreter.uninterpret(b, offset + lenLen, len);

      c.setValue(unpacked);
      return lenLen + interpreter.getPackedLength(len);
    } catch (Exception e) {
      throw new ISOException(makeExceptionMessage(c, "unpacking"), e);
    }
  }