@Override public void setFieldNumber(final int fieldNumber) { delegate.setFieldNumber(fieldNumber); }
/** * @param c - the Component to unpack * @param b - binary image * @param offset - starting offset within the binary image * @return consumed bytes * @exception ISOException */ public int unpack (ISOComponent c, byte[] b, int offset) throws ISOException { int len = Integer.parseInt(new String(b, offset, 2)); if (!(c instanceof ISOField)) throw new ISOException (c.getClass().getName() + " is not an ISOField"); c.setFieldNumber( Integer.parseInt(new String(b, offset + 2, 2)) ); c.setValue (new String (b, offset+4, len-2)); return len + 2; } public void unpack (ISOComponent c, InputStream in)
public void unpack (ISOComponent c, InputStream in) throws IOException, ISOException { if (!(c instanceof ISOField)) throw new ISOException (c.getClass().getName() + " is not an ISOField"); int fldno = Integer.parseInt(new String(readBytes (in, 4))); int len = Integer.parseInt(new String(readBytes (in, 3))); c.setFieldNumber(fldno); c.setValue (new String (readBytes (in, len))); }
public void unpack (ISOComponent c, InputStream in) throws IOException, ISOException { if (!(c instanceof ISOField)) throw new ISOException (c.getClass().getName() + " is not an ISOField"); int len = Integer.parseInt(new String(readBytes (in, 2))); int fldno = Integer.parseInt(new String(readBytes (in, 2))); c.setFieldNumber(fldno); c.setValue (new String (readBytes (in, len-2))); }
/** * @param c - the Component to unpack * @param b - binary image * @param offset - starting offset within the binary image * @return consumed bytes * @exception ISOException */ public int unpack (ISOComponent c, byte[] b, int offset) throws ISOException { if (!(c instanceof ISOField)) throw new ISOException (c.getClass().getName() + " is not an ISOField"); c.setFieldNumber( Integer.parseInt(new String(b, offset, 4)) ); offset += 4; int len = Integer.parseInt(new String(b, offset, 3)); offset += 3; c.setValue (new String (b, offset, len)); return len + 7; } public void unpack (ISOComponent c, InputStream in)
/** * @param c - the Component to unpack * @param b - binary image * @param offset - starting offset within the binary image * @return consumed bytes * @exception ISOException */ public int unpack (ISOComponent c, byte[] b, int offset) throws ISOException { int len = Integer.parseInt(ISOUtil.ebcdicToAscii(b, offset, prefixerPackedLength)) - TAG_HEADER_LENGTH; if (!(c instanceof ISOBinaryField)) throw new ISOException (c.getClass().getName() + " is not an ISOBinaryField"); c.setFieldNumber ( Integer.parseInt(ISOUtil.ebcdicToAscii (b, offset+prefixerPackedLength, TAG_HEADER_LENGTH)) ); byte[] value = new byte[len]; System.arraycopy(b, offset + prefixerPackedLength + TAG_HEADER_LENGTH , value, 0, len); c.setValue (value); return len + prefixerPackedLength + TAG_HEADER_LENGTH; } public void unpack (ISOComponent c, InputStream in)
/** * @param c - the Component to unpack * @param b - binary image * @param offset - starting offset within the binary image * @return consumed bytes * @exception ISOException */ public int unpack (ISOComponent c, byte[] b, int offset) throws ISOException { int len = Integer.parseInt(ISOUtil.ebcdicToAscii(b, offset, 3)) - 2; if (!(c instanceof ISOField)) throw new ISOException (c.getClass().getName() + " is not an ISOField"); c.setFieldNumber ( Integer.parseInt(ISOUtil.ebcdicToAscii (b, offset+3, 2)) ); c.setValue (new String (b, offset+5, len)); return len + 5; } public void unpack (ISOComponent c, InputStream in)
public void unpack (ISOComponent c, InputStream in) throws IOException, ISOException { if (!(c instanceof ISOField)) throw new ISOException (c.getClass().getName() + " is not an ISOField"); int len = Integer.parseInt(ISOUtil.ebcdicToAscii(readBytes (in, 3))) - 2; int fldno = Integer.parseInt(ISOUtil.ebcdicToAscii(readBytes (in, 2))); c.setFieldNumber (fldno); c.setValue (new String (readBytes (in, len))); }
public void unpack (ISOComponent c, InputStream in) throws IOException, ISOException { if (!(c instanceof ISOField)) throw new ISOException (c.getClass().getName() + " is not an ISOField"); int len = Integer.parseInt(ISOUtil.ebcdicToAscii(readBytes (in, prefixerPackedLength))) - TAG_HEADER_LENGTH; int fldno = Integer.parseInt(ISOUtil.ebcdicToAscii(readBytes (in, TAG_HEADER_LENGTH))); c.setFieldNumber (fldno); c.setValue (readBytes(in, len)); } public int getMaxPackedLength() {
/** * moves a field (renumber) * @param oldFieldNumber old field number * @param newFieldNumber new field number * @throws ISOException on error */ 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); }
@Override public synchronized void writeTo(ISOMsg isoMsg) throws ISOException { int maxField = isoMsg.getMaxField(); List<TagValue> tagValueList = getOrderedList(); int fieldNumber = 0; for (TagValue tagValue : tagValueList) { Object value = tagValue.getValue(); if (value != null) { ISOComponent subField; if (value instanceof byte[]) { subField = new ISOBinaryField(fieldNumber + maxField + 1, (byte[]) value); } else if (value instanceof String) { subField = new ISOField(fieldNumber + maxField + 1, (String) value); } else if (value instanceof TagSequence) { TagSequence subSequence = (TagSequence) tagValue; subField = new ISOMsg(fieldNumber + maxField + 1); subSequence.writeTo((ISOMsg) subField); } else if (value instanceof ISOMsg) { ISOMsgTagValue subSequence = (ISOMsgTagValue) tagValue; subField = subSequence.getValue(); subField.setFieldNumber(fieldNumber + maxField + 1); } else { throw new ISOException("Unknown TagValue subclass: " + tagValue.getClass()); } isoMsg.set(new ISOTaggedField(tagValue.getTag(), subField)); } fieldNumber++; } }
/** * Unpacks the byte array into the component. * @param c The component to unpack into. * @param b The byte array to unpack. * @param offset The index in the byte array to start unpacking from. * @return The number of bytes consumed unpacking the component. */ public int unpack(ISOComponent c, byte[] b, int offset) throws ISOException { try{ int tagLen = tagPrefixer.getPackedLength(); c.setFieldNumber(tagPrefixer.decodeLength(b, offset)); int len = prefixer.decodeLength(b, offset + tagLen); if (len == -1) { // The prefixer doesn't know how long the field is, so use // maxLength instead len = getLength(); } else if (getLength() > 0 && len > getLength()) throw new ISOException("Field length " + len + " too long. Max: " + getLength()); int lenLen = prefixer.getPackedLength(); String unpacked = interpreter.uninterpret(b, offset + tagLen + lenLen, len); c.setValue(unpacked); return tagLen + lenLen + interpreter.getPackedLength(len); } catch(Exception e){ throw new ISOException(makeExceptionMessage(c, "unpacking"), e); } }
/** * Unpacks the byte array into the component. * @param c The component to unpack into. * @param b The byte array to unpack. * @param offset The index in the byte array to start unpacking from. * @return The number of bytes consumed unpacking the component. */ @Override public int unpack(ISOComponent c, byte[] b, int offset) throws ISOException { try{ int tagLen = tagPrefixer.getPackedLength(); c.setFieldNumber(tagPrefixer.decodeLength(b, offset)); int len = prefixer.decodeLength(b, offset + tagLen); if (len == -1) { // The prefixer doesn't know how long the field is, so use // maxLength instead len = getLength(); } else if (getLength() > 0 && len > getLength()) throw new ISOException("Field length " + len + " too long. Max: " + getLength()); int lenLen = prefixer.getPackedLength(); byte[] unpacked = interpreter.uninterpret(b, offset + tagLen + lenLen, len); c.setValue(unpacked); return tagLen + lenLen + interpreter.getPackedLength(len); } catch(Exception e){ throw new ISOException(makeExceptionMessage(c, "unpacking"), e); } }
/** * Unpack the input stream into the component. * @param c The Component to unpack into. * @param in Input stream where the packed bytes come from. * @exception IOException Thrown if there's a problem reading the input stream. */ @Override public void unpack (ISOComponent c, InputStream in) throws IOException, ISOException { try{ int tagLen = tagPrefixer.getPackedLength(); c.setFieldNumber(tagPrefixer.decodeLength(readBytes (in, tagLen), 0)); int lenLen = prefixer.getPackedLength (); int len; if (lenLen == 0) len = getLength(); else { len = prefixer.decodeLength (readBytes (in, lenLen), 0); if (getLength() > 0 && len > 0 && len > getLength()) throw new ISOException("Field length " + len + " too long. Max: " + getLength()); } int packedLen = interpreter.getPackedLength(len); byte[] unpacked = interpreter.uninterpret(readBytes (in, packedLen), 0, len); c.setValue(unpacked); } catch(ISOException e){ throw new ISOException(makeExceptionMessage(c, "unpacking"), e); } }
/** * Unpack the input stream into the component. * @param c The Component to unpack into. * @param in Input stream where the packed bytes come from. * @exception IOException Thrown if there's a problem reading the input stream. */ @Override public void unpack (ISOComponent c, InputStream in) throws IOException, ISOException { try{ int tagLen = tagPrefixer.getPackedLength(); c.setFieldNumber(tagPrefixer.decodeLength(readBytes (in, tagLen), 0)); int lenLen = prefixer.getPackedLength (); int len; if (lenLen == 0) len = getLength(); else { len = prefixer.decodeLength (readBytes (in, lenLen), 0); if (getLength() > 0 && len > 0 && len > getLength()) throw new ISOException("Field length " + len + " too long. Max: " + getLength()); } int packedLen = interpreter.getPackedLength(len); String unpacked = interpreter.uninterpret(readBytes (in, packedLen), 0, len); c.setValue(unpacked); } catch(ISOException e){ throw new ISOException(makeExceptionMessage(c, "unpacking"), e); } }