IntegerStringCodec implements BlockCodec<Integer> { @Override public Integer decode(byte[] data, int bitLength) throws BlockCodecException { try { return Integer.parseInt(new String(data).trim()); } catch (Exception ex) { throw new BlockCodecException("integerString decode failure. " + ex.getMessage(), ex); } }  @Override Integer decode(byte[] data, int bitLength); @Override Integer zeroValue(); @Override byte[] encode(Integer data, int bitLength); @Override void reset(); @Override String getValueType();  }
@Test public void testDecode() throws Exception { IntegerStringCodec codec = new IntegerStringCodec(); Assert.assertEquals(123, codec.decode("123".getBytes(), 24), 0); Assert.assertEquals(13, codec.decode("013".getBytes(), 24), 0); Assert.assertEquals(3, codec.decode("003".getBytes(), 24), 0); codec.reset(); }