Ejemplo n.º 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;
  }
 @Override
 public byte[] pack(ISOComponent c) throws ISOException {
   byte[] tagBytes;
   String tag = c.getValue().toString();
   tagBytes = ISOUtil.hex2byte(tag);
   if (tagBytes.length != getMaxPackedLength()) {
     byte[] b = new byte[getMaxPackedLength()];
     System.arraycopy(tagBytes, 0, b, b.length - tagBytes.length, tagBytes.length);
     tagBytes = b;
   }
   return tagBytes;
 }
Ejemplo n.º 3
0
 public int unpack(ISOComponent m, byte[] b) throws ISOException {
   LogEvent evt = new LogEvent(this, "unpack");
   int consumed = 0;
   for (int i = 0; consumed < b.length; i++) {
     ISOComponent 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;
 }