Package org.activeio

Examples of org.activeio.Packet.position()


        if( dup.remaining() < payloadLength+RECORD_FOOTER_SIZE ) {
            return false;
        }
       
        // Set limit to create a slice of the payload.
        dup.limit(dup.position()+payloadLength);
        this.payload = dup.slice();       
      if( isChecksumingEnabled() ) {
          checksum(new DataInputStream(new PacketInputStream(payload)));
      }
     
View Full Code Here


          checksum(new DataInputStream(new PacketInputStream(payload)));
      }
     
      // restore the limit and seek to the footer.
        dup.limit(packet.limit());
        dup.position(dup.position()+payloadLength);
        readFooter(is);
       
        // If every thing went well.. advance the position of the orignal packet.
        packet.position(dup.position());
        dup.dispose();
View Full Code Here

          checksum(new DataInputStream(new PacketInputStream(payload)));
      }
     
      // restore the limit and seek to the footer.
        dup.limit(packet.limit());
        dup.position(dup.position()+payloadLength);
        readFooter(is);
       
        // If every thing went well.. advance the position of the orignal packet.
        packet.position(dup.position());
        dup.dispose();
View Full Code Here

        dup.limit(packet.limit());
        dup.position(dup.position()+payloadLength);
        readFooter(is);
       
        // If every thing went well.. advance the position of the orignal packet.
        packet.position(dup.position());
        dup.dispose();
        return true;       
    }
   
    /**
 
View Full Code Here

        Packet packet = createTestPacket(100);
        packet.position(5);
        packet.limit(95);
        Packet packet2 = packet.slice();
       
        assertEquals(0, packet2.position());
        assertEquals(90, packet2.capacity());
        assertEquals(90, packet2.limit());
    }

    public void testWriteAndReadByte() {
View Full Code Here

    abstract Packet createTestPacket(int capacity);
   
    public void testInit() {
        Packet packet = createTestPacket(100);
        assertEquals( 100, packet.capacity() );       
        assertEquals( 0, packet.position());       
        assertEquals( 100, packet.limit() );       
        assertEquals( 100, packet.remaining() );       
        assertTrue( packet.hasRemaining() );       
    }
   
View Full Code Here

        assertTrue( packet.hasRemaining() );       
    }
   
    public void testPosition() {
        Packet packet = createTestPacket(100);
        packet.position(10);
        assertEquals( 10, packet.position() );       
    }

    public void testLimit() {
        Packet packet = createTestPacket(100);
View Full Code Here

    }
   
    public void testPosition() {
        Packet packet = createTestPacket(100);
        packet.position(10);
        assertEquals( 10, packet.position() );       
    }

    public void testLimit() {
        Packet packet = createTestPacket(100);
        packet.limit(10);
View Full Code Here

        assertEquals( 10, packet.limit() );       
    }

    public void testRemaining() {
        Packet packet = createTestPacket(100);
        packet.position(5);
        packet.limit(95);
        assertEquals(90, packet.remaining());
        assertTrue(packet.hasRemaining());

        packet.position(5);
View Full Code Here

        packet.position(5);
        packet.limit(95);
        assertEquals(90, packet.remaining());
        assertTrue(packet.hasRemaining());

        packet.position(5);
        packet.limit(5);
        assertEquals(0, packet.remaining());
        assertFalse(packet.hasRemaining());
    }
   
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.