DoubleCodec implements BlockCodec<Double> { @Override public byte[] encode(Double data, int bitLength) throws BlockCodecException { try { double value = data.doubleValue(); return ByteBuffer.allocate(8).putDouble(value).array(); } catch (Exception ex) { throw new BlockCodecException("double encode failure. " + ex.getMessage(), ex); } }  @Override Double zeroValue(); @Override Double decode(byte[] data, int bitLength); @Override byte[] encode(Double data, int bitLength); @Override void reset(); @Override String getValueType();  }
@Test public void testEncode() throws Exception { DoubleCodec codec = new DoubleCodec(); Assert.assertArrayEquals( new byte[] { (byte) 0x40, (byte) 0x28, (byte) 0x98, (byte) 0x92, (byte) 0x25, (byte) 0x31, (byte) 0x11, (byte) 0xf1 }, codec.encode(new Double(12.29799d), 8)); }