コード例 #1
0
  @Override
  public Object decode(BitBuffer bitBuffer, Resolver resolver, Builder builder)
      throws DecodingException {
    ArrayList<Object> ret = new ArrayList<Object>();

    while (bitBuffer.getBitPos() < bitBuffer.getBitBufBitSize()) {
      // read element
      ret.add(codec.decode(bitBuffer, resolver, builder));
    }

    return ret;
  }
コード例 #2
0
ファイル: LineStyle3Test.java プロジェクト: ciaranw/vultan
  @Test
  public void testParseRGB() throws DecodingException {
    VersionStack.INSTANCE.pushVersion(1);
    byte[] data = new byte[] {0x01, 0x01, 0x00, (byte) 0xaa, (byte) 0xff, (byte) 0xff};
    BitBuffer buffer = new DefaultBitBuffer(ByteBuffer.wrap(data));

    CodecFactory factory = CustomTypes.getCodecFactory(null);
    Codec<LineStyle> codec = factory.create(null, LineStyle.class, null);

    LineStyle result = codec.decode(buffer, null, new DefaultBuilder());

    assertNotNull(result.colorv1);
    assertEquals(Integer.valueOf(0), result.colorv1.red);
    assertEquals(Integer.valueOf(170), result.colorv1.green);
    assertEquals(Integer.valueOf(255), result.colorv1.blue);
  }