@Override public byte[] getBytes() throws ISOException { return delegate.getBytes(); }
/** * @param c - a component * @return packed component * @throws org.jpos.iso.ISOException */ public byte[] pack(ISOComponent c) throws ISOException { int len; byte[] s = c.getBytes(); if ((len = s.length) > getLength()) { throw new ISOException( "Invalid length " + len + " packing IF_FSTBINARY field " + c.getKey() + " max length=" + getLength() ); } byte[] b = new byte[s.length + 1]; System.arraycopy(s, 0, b, 0, s.length); b[b.length - 2] = terminator; return b; }
/** * Convert the component into a byte[]. * @return byte array representation of component * @throws org.jpos.iso.ISOException */ @Override public byte[] pack(ISOComponent c) throws ISOException { try { String data; if(c.getValue() instanceof byte[]) data = new String(c.getBytes(), ISOUtil.CHARSET); // transparent handling of complex fields else data = (String)c.getValue(); if (data.length() > getLength()) { throw new ISOException("Field length " + data.length() + " too long. Max: " + getLength()); } String paddedData = padder.pad(data, getLength()); byte[] rawData = new byte[prefixer.getPackedLength() + interpreter.getPackedLength(paddedData.length())]; prefixer.encodeLength(paddedData.length(), rawData); interpreter.interpret(paddedData, rawData, prefixer.getPackedLength()); return rawData; } catch(Exception e) { throw new ISOException(makeExceptionMessage(c, "packing"), e); } }
packedValue = c.getBytes();
/** * Convert the component into a byte[]. */ public byte[] pack(ISOComponent c) throws ISOException { try { byte[] data = c.getBytes(); int packedLength = prefixer.getPackedLength(); if (packedLength == 0 && data.length != getLength()) { throw new ISOException("Binary data length not the same as the packager length (" + data.length + "/" + getLength() + ")"); } byte[] ret = new byte[interpreter.getPackedLength(data.length) + packedLength]; prefixer.encodeLength(data.length, ret); interpreter.interpret(data, ret, packedLength); return ret; } catch(Exception e) { throw new ISOException(makeExceptionMessage(c, "packing"), e); } }