@Test public void testEncodeShortLength() throws Exception { byte[] b = new byte[2]; AsciiPrefixer.LL.encodeLength(3, b); TestUtils.assertEquals(new byte[]{0x30, 0x33}, b); }
@Override public void encodeLength(int length, byte[] b) throws ISOException { int n = length; for (int i = nDigits - 1; i >= 0; i--) { b[i] = (byte)(n % 10 + '0'); n /= 10; } if (n != 0) { throw new ISOException("invalid len "+ length + ". Prefixing digits = " + nDigits); } }
AsciiPrefixer implements Prefixer { @Override public void encodeLength(int length, byte[] b) throws ISOException { int n = length; for (int i = nDigits - 1; i >= 0; i--) { b[i] = (byte)(n % 10 + '0'); n /= 10; } if (n != 0) { throw new ISOException("invalid len "+ length + ". Prefixing digits = " + nDigits); } } }
AsciiPrefixer implements Prefixer { @Override public void encodeLength(int length, byte[] b) throws ISOException { int n = length; for (int i = nDigits - 1; i >= 0; i--) { b[i] = (byte)(n % 10 + '0'); n /= 10; } if (n != 0) { throw new ISOException("invalid len "+ length + ". Prefixing digits = " + nDigits); } } AsciiPrefixer(int nDigits); }
AsciiPrefixer implements Prefixer { @Override public void encodeLength(int length, byte[] b) throws ISOException { int n = length; for (int i = nDigits - 1; i >= 0; i--) { b[i] = (byte)(n % 10 + '0'); n /= 10; } if (n != 0) { throw new ISOException("invalid len "+ length + ". Prefixing digits = " + nDigits); } } AsciiPrefixer(int nDigits); @Override void encodeLength(int length, byte[] b); @Override int decodeLength(byte[] b, int offset); @Override int getPackedLength(); }
AsciiPrefixer implements Prefixer { @Override public void encodeLength(int length, byte[] b) throws ISOException { int n = length; for (int i = nDigits - 1; i >= 0; i--) { b[i] = (byte)(n % 10 + '0'); n /= 10; } if (n != 0) { throw new ISOException("invalid len "+ length + ". Prefixing digits = " + nDigits); } } AsciiPrefixer(int nDigits); @Override void encodeLength(int length, byte[] b); @Override int decodeLength(byte[] b, int offset); @Override int getPackedLength(); static final AsciiPrefixer L; static final AsciiPrefixer LL; static final AsciiPrefixer LLL; static final AsciiPrefixer LLLL; static final AsciiPrefixer LLLLL; static final AsciiPrefixer LLLLLL; }