@Test public void testInterpretPositive() throws Exception { byte[] expectedRawData = new byte[] { (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0xf1, (byte) 0xf3, (byte) 0xf5, (byte) 0xf7, (byte) 0xf8, (byte) 0xf6, (byte) 0x12, (byte) 0x9a }; byte[] rawData = new byte[] { (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x12, (byte) 0x9a }; int offset = 3; String string = "135786"; signedEbcdicNumberInterpreter.interpret(string, rawData, offset); assertTrue(Arrays.equals(expectedRawData, rawData), "Expected " + ISOUtil.hexdump(expectedRawData) + " but was " + ISOUtil.hexdump(rawData)); }
public void interpret(String data, byte[] targetArray, int offset) { boolean negative = data.startsWith("-"); if (negative) { ISOUtil.asciiToEbcdic(data.substring(1), targetArray, offset); targetArray[offset + data.length() - 2] = (byte) (targetArray[offset + data.length() - 2] & 0xDF); } else { ISOUtil.asciiToEbcdic(data, targetArray, offset); } }
SignedEbcdicNumberInterpreter implements Interpreter { public void interpret(String data, byte[] targetArray, int offset) { boolean negative = data.startsWith("-"); if (negative) { ISOUtil.asciiToEbcdic(data.substring(1), targetArray, offset); targetArray[offset + data.length() - 2] = (byte) (targetArray[offset + data.length() - 2] & 0xDF); } else { ISOUtil.asciiToEbcdic(data, targetArray, offset); } } }
SignedEbcdicNumberInterpreter implements Interpreter { public void interpret(String data, byte[] targetArray, int offset) { boolean negative = data.startsWith("-"); if (negative) { ISOUtil.asciiToEbcdic(data.substring(1), targetArray, offset); targetArray[offset + data.length() - 2] = (byte) (targetArray[offset + data.length() - 2] & 0xDF); } else { ISOUtil.asciiToEbcdic(data, targetArray, offset); } }  }
SignedEbcdicNumberInterpreter implements Interpreter { public void interpret(String data, byte[] targetArray, int offset) { boolean negative = data.startsWith("-"); if (negative) { ISOUtil.asciiToEbcdic(data.substring(1), targetArray, offset); targetArray[offset + data.length() - 2] = (byte) (targetArray[offset + data.length() - 2] & 0xDF); } else { ISOUtil.asciiToEbcdic(data, targetArray, offset); } }  void interpret(String data, byte[] targetArray, int offset); String uninterpret(byte[] rawData, int offset, int length); int getPackedLength(int nDataUnits); }
SignedEbcdicNumberInterpreter implements Interpreter { public void interpret(String data, byte[] targetArray, int offset) { boolean negative = data.startsWith("-"); if (negative) { ISOUtil.asciiToEbcdic(data.substring(1), targetArray, offset); targetArray[offset + data.length() - 2] = (byte) (targetArray[offset + data.length() - 2] & 0xDF); } else { ISOUtil.asciiToEbcdic(data, targetArray, offset); } }  void interpret(String data, byte[] targetArray, int offset); String uninterpret(byte[] rawData, int offset, int length); int getPackedLength(int nDataUnits); static final SignedEbcdicNumberInterpreter INSTANCE; }