Examples of BitBuffer


Examples of com.slytechs.utils.memory.BitBuffer

   * (non-Javadoc)
   *
   * @see org.jnetstream.packet.Packet#getBuffer()
   */
  public BitBuffer getBuffer() throws IOException {
    final BitBuffer buffer = getRecordBitBuffer();
    buffer.position(buffer.position() + PcapPacketRecord.HEADER_LENGTH * 8);

    return buffer;
  }
View Full Code Here

Examples of com.slytechs.utils.memory.BitBuffer

   * point at the packet data portion of the buffer referenced as a view.
   *
   * @see com.slytechs.packet.AbstractPacket#getBuffer()
   */
  public BitBuffer getBuffer() throws IOException {
    final BitBuffer b = handle.getBitBuffer();

    if (bits != b) {
      b.position(b.position() + getRecordHeaderLength());
      bits = BitBuffer.wrap(b.toByteBuffer());
    }

    return bits;
  }
View Full Code Here

Examples of com.slytechs.utils.memory.BitBuffer

  public BitBuffer getRecordBitBuffer() throws IOException {
    if (bits != null) {
      return bits;
    }

    final BitBuffer b = this.handle.getBitBuffer();
    this.offset = b.position();

    return b;
  }
View Full Code Here

Examples of com.slytechs.utils.memory.BitBuffer

   * (non-Javadoc)
   *
   * @see org.jnetstream.packet.Packet#getBuffer()
   */
  public BitBuffer getBuffer() throws IOException {
    final BitBuffer b = getRecordBitBuffer();
    b.position(b.position() + SnoopPacketRecord.HEADER_LENGTH * 8);

    return b;
  }
View Full Code Here

Examples of com.slytechs.utils.memory.BitBuffer

    if (headers.isEmpty()) {
      return getBuffer();
    }

    BitBuffer b = getBuffer();

    Header last = headers.getHeader(headers.size() - 1);
    int p = b.position() + last.getOffset() + last.getLength();
    p = (p > b.limit() ? b.limit() : p);

    // Now position the buffer
    b.position(p);

    return b;
  }
View Full Code Here

Examples of org.codehaus.preon.buffer.BitBuffer

        this.wrapped = wrapped;
    }

    public T decode(BitBuffer buffer, Resolver resolver, Builder builder)
            throws DecodingException {
        BitBuffer slice = buffer
                .slice(sizeExpr.eval(resolver));
        return wrapped.decode(slice, resolver, builder);
    }
View Full Code Here

Examples of org.codehaus.preon.buffer.BitBuffer

        };
    }

    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

Examples of org.codehaus.preon.buffer.BitBuffer

        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

Examples of org.codehaus.preon.buffer.BitBuffer

        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

Examples of org.codehaus.preon.buffer.BitBuffer

                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
Copyright © 2018 www.massapi.com. 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.