public void unpack (ISOComponent c, InputStream in) throws IOException, ISOException { int len = prefixer.decodeLength(readBytes (in, 2), 2); c.setValue (interpreter.uninterpret(readBytes (in, len+2 >> 1), 0, len)); } public int getMaxPackedLength() {
/** * @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); } /**
/** * Returns the prefixer's packed length and the interpreter's packed length. */ public int getMaxPackedLength() { return tagPrefixer.getPackedLength() + prefixer.getPackedLength() + interpreter.getPackedLength(getLength()); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x30, 0x30, 0x32, 0x12, 0x34}; IFA_LLLBINARY packager = new IFA_LLLBINARY(2, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "D123"); IFE_AMOUNT packager = new IFE_AMOUNT(6, "Should be C4F0F0F1F2F3"); TestUtils.assertEquals( ISOUtil.hex2byte ("C4F0F0F1F2F3"), packager.pack(field)); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x02, 0x12, 0x34}; IFB_LLBINARY packager = new IFB_LLBINARY(2, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
public void testUnpackWithPackagerWithoutDescription() throws Exception { byte[] raw = new byte[] {(byte)0x30, (byte)0x34, (byte)0xF1, (byte)0xF2, (byte)0xF3, (byte)0xF4}; IFAE_LLCHAR packager = new IFAE_LLCHAR(); packager.setLength(10); ISOField field = new ISOField(12); packager.unpack(field, raw, 0); assertEquals("1234", (String) field.getValue()); }
public void testReversability() throws Exception { String origin = "Abc123:.-"; ISOField field = new ISOField(12, origin); IFAE_LLCHAR packager = new IFAE_LLCHAR(10, "Should be Abc123:.-"); ISOField unpack = new ISOField(12); packager.unpack(unpack, packager.pack(field), 0); assertEquals(origin, (String) unpack.getValue()); }
public void testReversability() throws Exception { byte[] origin = new byte[] {0x12, 0x34, 0x56, 0x78}; ISOBinaryField f = new ISOBinaryField(12, origin); IFB_LLLBINARY packager = new IFB_LLLBINARY(100, "Should be 12345678"); ISOBinaryField unpack = new ISOBinaryField(12); packager.unpack(unpack, packager.pack(f), 0); TestUtils.assertEquals(origin, (byte[])unpack.getValue()); }
public void testReversability() throws Exception { String origin = "Abc123:.-"; ISOField f = new ISOField(12, origin); IFB_LLCHAR packager = new IFB_LLCHAR(10, "Should be Abc123:.-"); ISOField unpack = new ISOField(12); packager.unpack(unpack, packager.pack(f), 0); assertEquals(origin, (String) unpack.getValue()); } }
public void testReversability() throws Exception { String origin = "Abc123:.-"; ISOField f = new ISOField(12, origin); IFB_LLLHCHAR packager = new IFB_LLLHCHAR(10, "Should be Abc123:.-"); ISOField unpack = new ISOField(12); packager.unpack(unpack, packager.pack(f), 0); assertEquals(origin, (String) unpack.getValue()); } }
public void testPack() throws Exception { ISOBinaryField field = new ISOBinaryField(12, new byte[] {0x12, 0x34}); IFA_LLLBINARY packager = new IFA_LLLBINARY(2, "Should be 1234"); TestUtils.assertEquals(new byte[] {0x30, 0x30, 0x32, 0x12, 0x34}, packager.pack(field)); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x02, 0x12, 0x34, 0x00, 0x00}; IFB_LLHFBINARY packager = new IFB_LLHFBINARY(4, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x00, 0x04, (byte)0xC1, (byte)0xC2, (byte)0xC3, (byte)0xC4}; IFB_LLLHECHAR packager = new IFB_LLLHECHAR(10, "Should be 04ABCD"); ISOField field = new ISOField(12); packager.unpack(field, raw, 0); assertEquals("ABCD", (String) field.getValue()); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x00, 0x04, 0x41, 0x42, 0x43, 0x44}; IFB_LLLCHAR packager = new IFB_LLLCHAR(10, "Should be 04ABCD"); ISOField field = new ISOField(12); packager.unpack(field, raw, 0); assertEquals("ABCD", (String) field.getValue()); }
public void testPack() throws Exception { ISOField field = new ISOField(3, "0123456789ABCDEF"); IFB_HEX packager = new IFB_HEX(16, "Should be 0123456789ABCDEF", true); TestUtils.assertEquals( new byte[] {0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF} , packager.pack(field)); }
public void testPackTooMuch() throws Exception { ISOField field = new ISOField(12, "ABCDEFGHIJ"); IFB_LLHCHAR packager = new IFB_LLHCHAR(5, "Should be ABCDEFGHIJ"); try { packager.pack(field); fail("field is too long and should have thrown an exception"); } catch (Exception ignored) { } }
public void testPack() throws Exception { ISOField field = new ISOField(12, "ABCD"); IFB_LLLHECHAR packager = new IFB_LLLHECHAR(10, "Should be 04ABCD"); TestUtils.assertEquals(new byte[] {0x00, 0x04, (byte)0xC1, (byte)0xC2, (byte)0xC3, (byte)0xC4}, packager.pack(field)); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "1234"); IFB_LLLNUM packager = new IFB_LLLNUM(10, "Should be 00041234", true); TestUtils.assertEquals(new byte[]{0x00, 0x04, 0x12, 0x34}, packager.pack(field)); }
public void unpack (ISOComponent c, InputStream in) throws IOException, ISOException { byte[] b = readBytes (in, 2); int len = 100 * (((b[0] >> 4 & 0x0F) > 0x09 ? 0 : b[0] >> 4 & 0x0F) * 10 + (b[0] & 0x0F)) + ((b[1] >> 4 & 0x0F) > 0x09 ? 0 : b[1] >> 4 & 0x0F) * 10 + (b[1] & 0x0F); c.setValue (ISOUtil.bcd2str (readBytes (in, len), 0, 2*len, pad)); }