Package org.apache.mina.core.buffer

Examples of org.apache.mina.core.buffer.IoBuffer.limit()


        try {
            buffer.getString(Charset.forName("ASCII").newDecoder());
            fail();
        } catch (Exception e) {
            assertEquals(oldLimit, buffer.limit());
            assertEquals(oldPos, buffer.position());
        }
    }

    @Test
View Full Code Here


            buf.put((byte) 0x1);
            buf.put((byte) 0x2);
            buf.put((byte) 0x3);
            buf.put((byte) 0x4);
            buf.position(2);
            buf.limit(5);

            assertEquals(4, buf.indexOf((byte) 0x1));
            assertEquals(-1, buf.indexOf((byte) 0x2));
            assertEquals(2, buf.indexOf((byte) 0x3));
            assertEquals(3, buf.indexOf((byte) 0x4));
View Full Code Here

        entries.add( getEntry1() );

        Keytab writer = Keytab.getInstance();
        writer.setEntries( entries );
        IoBuffer buffer = writer.write();
        assertEquals( "Expected file size.", 130, buffer.limit() );
    }


    private KeytabEntry getEntry1() throws ParseException
    {
View Full Code Here

        IoBuffer msg = (IoBuffer)message;
        IoBuffer buf = (IoBuffer)session.getAttribute("buffer");
        if (buf.remaining() < msg.limit()) {
          int bufCapacity = buf.capacity() + (msg.limit() - buf.remaining());
          buf.capacity(bufCapacity);
          buf.limit(bufCapacity);
        }
        buf.put((IoBuffer)message);
       
        if(currSession.getId() == session.getId()){
         
View Full Code Here

    }
     
    IoBuffer buf = (IoBuffer)currSession.getAttribute("buffer");
   
    int pos = buf.position();
    int limit = buf.limit();
   
    buf.flip();
    buf.position(0);
    int len = buf.remaining();
    byte [] bytes = new byte[len];
View Full Code Here

    int len = buf.remaining();
    byte [] bytes = new byte[len];
    buf.get(bytes);
   
    buf.position(pos);
    buf.limit(limit);   
    return bytes;
  }

}
View Full Code Here

        IoBuffer msg = (IoBuffer)message;
        IoBuffer buf = (IoBuffer)session.getAttribute("buffer");
        if (buf.remaining() < msg.limit()) {
          int bufCapacity = buf.capacity() + (msg.limit() - buf.remaining());
          buf.capacity(bufCapacity);
          buf.limit(bufCapacity);
        }
        buf.put((IoBuffer)message);
       
        if(currSession.getId() == session.getId()){
         
View Full Code Here

    }
     
    IoBuffer buf = (IoBuffer)currSession.getAttribute("buffer");
   
    int pos = buf.position();
    int limit = buf.limit();
   
    buf.flip();
    buf.position(0);
    int len = buf.remaining();
    byte [] bytes = new byte[len];
View Full Code Here

    int len = buf.remaining();
    byte [] bytes = new byte[len];
    buf.get(bytes);
   
    buf.position(pos);
    buf.limit(limit);   
    return bytes;
  }

}
View Full Code Here

        original.position(4);
        original.limit(10);
        duplicate = original.duplicate();
        original.put(4, (byte) 127);
        assertEquals(4, duplicate.position());
        assertEquals(10, duplicate.limit());
        assertEquals(16, duplicate.capacity());
        assertNotSame(original.buf(), duplicate.buf());
        assertSame(original.buf().array(), duplicate.buf().array());
        assertEquals(127, duplicate.get(4));
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.