@Test public void testDecode() throws Exception { byte[] b = new byte[]{0x32, 0x35}; assertEquals(25, AsciiPrefixer.LL.decodeLength(b, 0)); }
@Override public int decodeLength(byte[] b, int offset) throws ISOException { int len = 0; for (int i = 0; i < nDigits; i++) { byte d = b[offset + i]; if(d < '0' || d > '9') { throw new ISOException("Invalid character found. Expected digit."); } len = len * 10 + d - (byte)'0'; } return len; }
AsciiPrefixer implements Prefixer { @Override public int decodeLength(byte[] b, int offset) throws ISOException { int len = 0; for (int i = 0; i < nDigits; i++) { byte d = b[offset + i]; if(d < '0' || d > '9') { throw new ISOException("Invalid character found. Expected digit."); } len = len * 10 + d - (byte)'0'; } return len; } }
AsciiPrefixer implements Prefixer { @Override public int decodeLength(byte[] b, int offset) throws ISOException { int len = 0; for (int i = 0; i < nDigits; i++) { byte d = b[offset + i]; if(d < '0' || d > '9') { throw new ISOException("Invalid character found. Expected digit."); } len = len * 10 + d - (byte)'0'; } return len; } AsciiPrefixer(int nDigits); }
AsciiPrefixer implements Prefixer { @Override public int decodeLength(byte[] b, int offset) throws ISOException { int len = 0; for (int i = 0; i < nDigits; i++) { byte d = b[offset + i]; if(d < '0' || d > '9') { throw new ISOException("Invalid character found. Expected digit."); } len = len * 10 + d - (byte)'0'; } return len; } 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 int decodeLength(byte[] b, int offset) throws ISOException { int len = 0; for (int i = 0; i < nDigits; i++) { byte d = b[offset + i]; if(d < '0' || d > '9') { throw new ISOException("Invalid character found. Expected digit."); } len = len * 10 + d - (byte)'0'; } return len; } 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; }