Package com.google.code.yanf4j.buffer

Examples of com.google.code.yanf4j.buffer.IoBuffer.remaining()


    @Test
    public void testPutPrefixedString() throws Exception {
        CharsetEncoder encoder;
        IoBuffer buf = IoBuffer.allocate(16);
        buf.fillAndReset(buf.remaining());
        encoder = Charset.forName("ISO-8859-1").newEncoder();

        // Without autoExpand
        buf.putPrefixedString("ABC", encoder);
        assertEquals(5, buf.position());
View Full Code Here


    public void testAllocate() throws Exception {
        for (int i = 10; i < 1048576 * 2; i = i * 11 / 10) // increase by 10%
        {
            IoBuffer buf = IoBuffer.allocate(i);
            assertEquals(0, buf.position());
            assertEquals(buf.capacity(), buf.remaining());
            assertTrue(buf.capacity() >= i);
            assertTrue(buf.capacity() < i * 2);
        }
    }

View Full Code Here

    public IoBuffer encode(Object message, Session session) {
      final IoBuffer msgBuffer = (IoBuffer) message;
      if (msgBuffer == null) {
        return null;
      }
      if (msgBuffer.remaining() == 0) {
        return EMPTY_BUFFER;
      }
      byte[] bytes = new byte[msgBuffer.remaining()];
      msgBuffer.get(bytes);
      IoBuffer result = IoBuffer.allocate(bytes.length,
View Full Code Here

        return null;
      }
      if (msgBuffer.remaining() == 0) {
        return EMPTY_BUFFER;
      }
      byte[] bytes = new byte[msgBuffer.remaining()];
      msgBuffer.get(bytes);
      IoBuffer result = IoBuffer.allocate(bytes.length,
          ByteBufferCodecFactory.this.direct);
      result.put(bytes);
      result.flip();
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.