@Override public Object getValue() throws ISOException { return delegate.getValue(); }
/** * @param c - a component * @return packed component * @exception ISOException */ @Override public byte[] pack (ISOComponent c) throws ISOException { String s = c.getValue() + getToken() ; return s.getBytes(ISOUtil.CHARSET); } /**
/** * @param c - a component * @return packed component * @exception ISOException */ public byte[] pack (ISOComponent c) throws ISOException { return ISOUtil.bitSet2byte ((BitSet) c.getValue()); } /**
@Override public void pack(ISOComponent c, ObjectOutput out) throws IOException, ISOException { if (c.getValue() != null) { super.pack(c, out); } }
/** * Return the object value associated with the given field number * @param fldno the Field Number * @return the field Object */ public Object getValue(int fldno) { ISOComponent c = getComponent(fldno); try { return c != null ? c.getValue() : null; } catch (ISOException ex) { return null; //never happens for the given arguments of getValue method } } /**
/** * @param c - a component * @return packed component * @exception ISOException */ public byte[] pack (ISOComponent c) throws ISOException { byte[] b = ISOUtil.bitSet2byte ((BitSet) c.getValue()); return ISOUtil.hexString(b).getBytes(); } /**
@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; }
/** * @param c - a component * @return packed component * @exception ISOException */ public byte[] pack (ISOComponent c) throws ISOException { BitSet b = (BitSet) c.getValue(); int len = getLength() >= 8 ? b.length()+62 >>6 <<3 : getLength(); return ISOUtil.hexString(ISOUtil.bitSet2byte (b, len)).getBytes(); }
/** * @param c - a component * @return packed component * @exception ISOException */ public byte[] pack (ISOComponent c) throws ISOException { BitSet b = (BitSet) c.getValue(); int len = // bytes needed to encode BitSet (in 8-byte chunks) getLength() >= 8 ? b.length()+62 >>6 <<3 : getLength(); // +62 because we don't use bit 0 in the BitSet return ISOUtil.bitSet2byte (b, len); } /**
/** * @param c - a component * @return packed component * @exception ISOException */ public byte[] pack (ISOComponent c) throws ISOException { String s = ISOUtil.strpad ((String) c.getValue(), getLength()); return ISOUtil.asciiToEbcdic(s); } /**
public void test16ByteBitmapWithDataWith2ndBitMapBitOFF() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = sixteenBytes.unpack(c, DataWith2ndBitMapBitOff,0); assertEquals("16 bytes bitmap with data with 2nd bit map bit off: unpack of 8 bytes bitmap should consume 32 bytes in characters as the 2nd bitmap indicator is off",16,consumed); assertEquals("16 bytes bitmap with data with 2nd bit map bit off: 16 byte bitmap with 2nd bitmap idicator is off should have a maximum field of 64",64,((BitSet)c.getValue()).length() - 1); outBytes = sixteenBytes.pack(c); assertEquals("16 bytes bitmap with data with 2nd bit map bit off: pack of 64 bits bitmap with 16 bytes packager must produce a result 16 bytes long",16,outBytes.length); assertEquals("16 bytes bitmap with data with 2nd bit map bit off: pack of upacked value should be the same as original", ISOUtil.hexString(DataWith2ndBitMapBitOff,0,16),ISOUtil.hexString(outBytes)); } /*
@Test public void test24ByteBitmapWithOnly8BytesUsed() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = twentyfourBytes.unpack(c, eightByteBitMapIn24Bytes,0); assertEquals("8 bytes should be consumed as the 2nd bitmap indicator if off",8,consumed); assertEquals("24 byte bitmap with just 8 bytes used should have a maximum field of ",64,((BitSet)c.getValue()).length() - 1); outBytes = twentyfourBytes.pack(c); assertEquals("24 Byte (8 bytes used) bitmap pack should reflect unpack",ISOUtil.hexString(eightByteBitMapIn24Bytes,0,8),ISOUtil.hexString(outBytes)); }
@Test public void test24ByteBitmapWithOnly16BytesUsed() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = twentyfourBytes.unpack(c, sixteenByteBitMapIn24Bytes,0); assertEquals("16 bytes should be consumed as the 2nd bitmap indicator is on, 3rd is off",16,consumed); assertEquals("24 byte bitmap with just 16 bytes used should have a maximum field of ",128,((BitSet)c.getValue()).length() - 1); outBytes = twentyfourBytes.pack(c); assertEquals("24 Byte (16 bytes used) bitmap pack should reflect unpack",ISOUtil.hexString(sixteenByteBitMapIn24Bytes,0,16),ISOUtil.hexString(outBytes)); }
@Test public void test48ByteBitmapWithOnly16BytesUsed() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = fortyeightBytes.unpack(c, sixteenByteBitMapIn48Bytes,0); assertEquals("16 bytes should be consumed as the 2nd bitmap indicator is off",16,consumed); assertEquals("48 byte bitmap with just 16 bytes used should have a maximum field of ",64,((BitSet)c.getValue()).length() - 1); outBytes = fortyeightBytes.pack(c); assertEquals("48 Byte (16 bytes used) bitmap pack should reflect unpack",ISOUtil.hexString(sixteenByteBitMapIn48Bytes,0,16),ISOUtil.hexString(outBytes)); } @Test public void testThirdBitmapPack() throws Exception {
@Test public void test01ByteBitmap() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = oneByte.unpack(c, inBytes,0); assertEquals("1 byte should be consumed irrespective of 2nd, 3rd or any bitmap indicators",1,consumed); assertEquals("1 byte can only result in a bitmap holding fields up to 8",8,((BitSet)c.getValue()).length() - 1); outBytes = oneByte.pack(c); assertEquals("1 byte bitmap pack should reflect unpack",ISOUtil.hexString(inBytes,0,1),ISOUtil.hexString(outBytes)); }
@Test public void test16ByteBitmapWithOnly8BytesUsed() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = sixteenBytes.unpack(c, eightByteBitMapIn24Bytes,0); assertEquals("8 bytes should be consumed as the 2nd bitmap indicator if off",8,consumed); assertEquals("16 byte bitmap with just 8 bytes used should have a maximum field of ",64,((BitSet)c.getValue()).length() - 1); outBytes = sixteenBytes.pack(c); assertEquals("16 Byte (8 bytes used) bitmap pack should reflect unpack",ISOUtil.hexString(eightByteBitMapIn24Bytes,0,8),ISOUtil.hexString(outBytes)); }
@Test public void test32LByteBitmapWithOnly16BytesUsed() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = thirtytwoBytes.unpack(c, sixteenByteBitMapIn32Bytes,0); assertEquals("16 bytes should be consumed as the 2nd bitmap indicator is off",16,consumed); assertEquals("32 byte bitmap with just 16 bytes used should have a maximum field of ",64,((BitSet)c.getValue()).length() - 1); outBytes = sixteenBytes.pack(c); assertEquals("32 Byte (16 bytes used) bitmap pack should reflect unpack",ISOUtil.hexString(sixteenByteBitMapIn32Bytes,0,16),ISOUtil.hexString(outBytes)); }
public void test01ByteBitmapWithDataWith2ndBitMapBitOn() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = oneByte.unpack(c, DataWith2ndBitMapBitOn,0); assertEquals("1 bytes bitmap: unpack of 1 byte bitmap should consume 2 bytes in characters",2,consumed); assertEquals("1 bytes bitmap: 1 byte bitmap should result in a bitmap holding fields up to 8",8,((BitSet)c.getValue()).length() - 1); outBytes = oneByte.pack(c); assertEquals("1 bytes bitmap: pack of 1 byte bitmap must produce a result 2 bytes long",2,outBytes.length); assertEquals("1 bytes bitmap: pack of unpacked value should be the same as original", ISOUtil.hexString(DataWith2ndBitMapBitOn,0,2),ISOUtil.hexString(outBytes)); } public void test02ByteBitmapWithDataWith2ndBitMapBitOn() throws Exception
@Ignore("test currently failing - debug action required TODO: CCB") @Test public void test48ByteBitmapWithOnly32BytesUsed() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = fortyeightBytes.unpack(c, thirtytwoByteBitMapIn48Bytes,0); assertEquals("32 bytes should be consumed as the 2nd bitmap indicator is on, 3rd is off ",32,consumed); assertEquals("48 byte bitmap with just 32 bytes used should have a maximum field of ",128,((BitSet)c.getValue()).length() - 1); outBytes = fortyeightBytes.pack(c); assertEquals("48 Byte (32 bytes used) bitmap pack should reflect unpack",ISOUtil.hexString(thirtytwoByteBitMapIn48Bytes,0,32),ISOUtil.hexString(outBytes)); } @Test public void test48ByteBitmapWithOnly16BytesUsed() throws Exception
@Ignore("test currently failing - debug action required TODO: CCB") @Test public void test02ByteBitmap() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = twoBytes.unpack(c, inBytes,0); assertEquals("2 characters should be consumed irrespective of 2nd, 3rd or any bitmap indicators - actually consumes: "+consumed,2,consumed); assertEquals("2 characters can only result in a bitmap holding fields up to 8",8,((BitSet)c.getValue()).length() - 1); outBytes = twoBytes.pack(c); assertEquals("Pack of two bytes must produce a result 2 bytes long",2,outBytes.length); assertEquals("2 byte bitmap pack should reflect unpack", ISOUtil.hexString(inBytes,0,2),ISOUtil.hexString(outBytes)); }