Package org.codehaus.preon.buffer

Examples of org.codehaus.preon.buffer.DefaultBitBuffer


     * @return The decoded object.
     * @throws DecodingException If the {@link Codec} fails to decode a value from the buffer passed in.
     */
    public static <T> T decode(Codec<T> codec, ByteBuffer buffer)
            throws DecodingException {
        return decode(codec, new DefaultBitBuffer(buffer), null, null);
    }
View Full Code Here


        return decode(codec, new DefaultBitBuffer(buffer), null, null);
    }

    public static <T> T decode(Codec<T> codec, ByteBuffer buffer, Builder builder)
            throws DecodingException {
        return decode(codec, new DefaultBitBuffer(buffer), builder, null);
    }
View Full Code Here

        };
    }

    public void testSelectFrom() throws DecodingException {
        BitBuffer buffer = new DefaultBitBuffer(ByteBuffer.wrap(new byte[]{0, 1, (byte) 255,
                (byte) 255, (byte) 255, (byte) 255}));

        // We expect all Codecs to be constructed
        expect(codecFactory.create(null, Float.class, context)).andReturn(floatCodec);
        expect(
View Full Code Here

        codec.encode(original, new OutputStreamBitChannel(out), resolver);
        byte[] encoded = out.toByteArray();
        assertThat(encoded.length, is(size));

        BitBuffer buffer = new DefaultBitBuffer(ByteBuffer.wrap(encoded));
        String result = codec.decode(buffer, resolver, builder);
        assertThat(result, is(original));
    }
View Full Code Here

        assertNull(factory.create(metadata, Boolean.class, null));
        verify(metadata);
    }

    public void testDecoding() throws DecodingException {
        BitBuffer buffer = new DefaultBitBuffer(ByteBuffer.wrap(new byte[]{(byte) 0xF0}));
        expect(metadata.isAnnotationPresent(Bound.class)).andReturn(true);
        replay(metadata);
        Codec<Boolean> codec = factory.create(metadata, Boolean.class, null);
        assertTrue(codec.decode(buffer, null, null));
        assertTrue(codec.decode(buffer, null, null));
View Full Code Here

                ByteOrder.LittleEndian);

        // Replay
        EasyMock.replay(metadata, boundNumber);
        EnumCodec.Factory factory = new EnumCodec.Factory();
        BitBuffer buffer = new DefaultBitBuffer(ByteBuffer.wrap(new byte[]{0,
                1}));
        Codec<Direction> codec = factory
                .create(metadata, Direction.class, null);
        assertNotNull(codec);
        assertEquals(Direction.Left, codec.decode(buffer, null, null));
View Full Code Here

TOP

Related Classes of org.codehaus.preon.buffer.DefaultBitBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.