org.apache.activeio.packet
Class ByteBufferPacket

java.lang.Object
  extended by org.apache.activeio.packet.ByteBufferPacket
All Implemented Interfaces:
Packet

public final class ByteBufferPacket
extends Object
implements Packet

Provides a Packet implementation that is backed by a ByteBuffer

Version:
$Revision$

Field Summary
static int DEFAULT_BUFFER_SIZE
           
static int DEFAULT_DIRECT_BUFFER_SIZE
           
 
Constructor Summary
ByteBufferPacket(ByteBuffer buffer)
           
 
Method Summary
 ByteSequence asByteSequence()
           
 int capacity()
           
 void clear()
           
 Packet compact()
           
static ByteBufferPacket createDefaultBuffer(boolean direct)
           
 void dispose()
           
 Packet duplicate()
           
 Object duplicate(ClassLoader cl)
           
 void flip()
           
 Object getAdapter(Class target)
           
 ByteBuffer getByteBuffer()
           
 boolean hasRemaining()
           
 boolean isDirect()
           
 boolean isReadOnly()
           
 int limit()
           
 void limit(int arg0)
           
 Packet mark()
           
 int position()
           
 void position(int arg0)
           
 int read()
           
 int read(byte[] data, int offset, int length)
           
 int read(Packet dest)
           
 int remaining()
           
 void rewind()
           
 Packet slice()
           
 byte[] sliceAsBytes()
           
 String toString()
           
 int write(byte[] data, int offset, int length)
           
 boolean write(int data)
           
 void writeTo(DataOutput out)
           
 void writeTo(OutputStream out)
          Writes the remaing bytes in the packet to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE

DEFAULT_DIRECT_BUFFER_SIZE

public static final int DEFAULT_DIRECT_BUFFER_SIZE
Constructor Detail

ByteBufferPacket

public ByteBufferPacket(ByteBuffer buffer)
Method Detail

getByteBuffer

public ByteBuffer getByteBuffer()

createDefaultBuffer

public static ByteBufferPacket createDefaultBuffer(boolean direct)

writeTo

public void writeTo(OutputStream out)
             throws IOException
Description copied from interface: Packet
Writes the remaing bytes in the packet to the output stream.

Specified by:
writeTo in interface Packet
Throws:
IOException

writeTo

public void writeTo(DataOutput out)
             throws IOException
Specified by:
writeTo in interface Packet
Throws:
IOException

capacity

public int capacity()
Specified by:
capacity in interface Packet

clear

public void clear()
Specified by:
clear in interface Packet

compact

public Packet compact()

flip

public void flip()
Specified by:
flip in interface Packet

hasRemaining

public boolean hasRemaining()
Specified by:
hasRemaining in interface Packet

isDirect

public boolean isDirect()

isReadOnly

public boolean isReadOnly()

limit

public int limit()
Specified by:
limit in interface Packet

limit

public void limit(int arg0)
Specified by:
limit in interface Packet

mark

public Packet mark()

position

public int position()
Specified by:
position in interface Packet

position

public void position(int arg0)
Specified by:
position in interface Packet

remaining

public int remaining()
Specified by:
remaining in interface Packet

rewind

public void rewind()
Specified by:
rewind in interface Packet

slice

public Packet slice()
Specified by:
slice in interface Packet

duplicate

public Packet duplicate()
Specified by:
duplicate in interface Packet

duplicate

public Object duplicate(ClassLoader cl)
                 throws IOException
Specified by:
duplicate in interface Packet
Throws:
IOException

read

public int read()
Specified by:
read in interface Packet
See Also:
Packet.read()

read

public int read(byte[] data,
                int offset,
                int length)
Specified by:
read in interface Packet
See Also:
Packet.read(byte[], int, int)

write

public boolean write(int data)
Specified by:
write in interface Packet
See Also:
Packet.write(int)

write

public int write(byte[] data,
                 int offset,
                 int length)
Specified by:
write in interface Packet
See Also:
Packet.write(byte[], int, int)

asByteSequence

public ByteSequence asByteSequence()
Specified by:
asByteSequence in interface Packet
See Also:
Packet.asByteSequence()

sliceAsBytes

public byte[] sliceAsBytes()
Specified by:
sliceAsBytes in interface Packet
See Also:
Packet.sliceAsBytes()

read

public int read(Packet dest)
Specified by:
read in interface Packet
Parameters:
dest -
Returns:
the number of bytes read into the dest.

toString

public String toString()
Overrides:
toString in class Object

getAdapter

public Object getAdapter(Class target)
Specified by:
getAdapter in interface Packet

dispose

public void dispose()
Specified by:
dispose in interface Packet


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.