/** * dump the message to a PrintStream. The output is sorta XML, intended to be easily parsed. <br> * Each component is responsible for its own dump function, ISOMsg just calls dump on every valid * field. * * @param p - print stream * @param indent - optional indent string */ public void dump(PrintStream p, String indent) { ISOComponent c; p.print(indent + "<" + XMLPackager.ISOMSG_TAG); switch (direction) { case INCOMING: p.print(" direction=\"incoming\""); break; case OUTGOING: p.print(" direction=\"outgoing\""); break; } if (fieldNumber != -1) p.print(" " + XMLPackager.ID_ATTR + "=\"" + fieldNumber + "\""); p.println(">"); String newIndent = indent + " "; if (getPackager() != null) { p.println(newIndent + "<!-- " + getPackager().getDescription() + " -->"); } if (header instanceof Loggeable) ((Loggeable) header).dump(p, newIndent); for (int i = 0; i <= maxField; i++) { if ((c = (ISOComponent) fields.get(i)) != null) c.dump(p, newIndent); // // Uncomment to include bitmaps within logs // // if (i == 0) { // if ((c = (ISOComponent) fields.get (new Integer (-1))) != null) // c.dump (p, newIndent); // } // } p.println(indent + "</" + XMLPackager.ISOMSG_TAG + ">"); }
/** * moves a field (renumber) * * @param oldFieldNumber old field number * @param newFieldNumber new field number * @throws ISOException */ public void move(int oldFieldNumber, int newFieldNumber) throws ISOException { ISOComponent c = getComponent(oldFieldNumber); unset(oldFieldNumber); if (c != null) { c.setFieldNumber(newFieldNumber); set(c); } else unset(newFieldNumber); }
/** * Set a field within this message * * @param c - a component */ public void set(ISOComponent c) throws ISOException { if (c != null) { Integer i = (Integer) c.getKey(); fields.put(i, c); if (i.intValue() > maxField) { maxField = i.intValue(); } dirty = true; } }
/** * Return the object value associated with the given field number * * @param fldno the Field Number * @return the field Object */ public Object getValue(int fldno) throws ISOException { ISOComponent c = getComponent(fldno); return c != null ? c.getValue() : null; }