org.xsocket
Class ByteBufferQueue

Package class diagram package ByteBufferQueue
java.lang.Object
  extended by org.xsocket.ByteBufferQueue

public final class ByteBufferQueue
extends java.lang.Object

A ByteBuffer queue for framework-internal usage


Constructor Summary
ByteBufferQueue()
           
 
Method Summary
 void addFirst(java.nio.ByteBuffer buffer)
          add a byte buffer at the first position
 void addFirst(java.util.LinkedList<java.nio.ByteBuffer> bufs)
          add a list of byte buffer to the first position.
 void addFirstSilence(java.util.LinkedList<java.nio.ByteBuffer> bufs)
          add a list of byte buffer to the first position.
 void append(java.nio.ByteBuffer data)
          append a byte buffer to this queue.
 void append(java.util.LinkedList<java.nio.ByteBuffer> bufs)
          append a list of byte buffer to this queue.
 java.util.LinkedList<java.nio.ByteBuffer> drain()
          drain the queue
 int getFirstBufferSize()
          get the size of the first ByteBuffer in queue
 int getInsertVersionVersion()
          return a int, which represent the insert version.
 int getSize()
          return the current size
 boolean isEmpty()
          returns true, if empty
 java.nio.ByteBuffer read(int length)
          read bytes
 java.nio.ByteBuffer removeFirst()
          remove the first ByteBuffer
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteBufferQueue

public ByteBufferQueue()
Method Detail

isEmpty

public boolean isEmpty()
returns true, if empty

Returns:
true, if empty

getSize

public int getSize()
return the current size

Returns:
the current size

getFirstBufferSize

public int getFirstBufferSize()
get the size of the first ByteBuffer in queue

Returns:
the size of the first ByteBuffer

append

public void append(java.nio.ByteBuffer data)
append a byte buffer to this queue.

Parameters:
data - the ByteBuffer to append

append

public void append(java.util.LinkedList<java.nio.ByteBuffer> bufs)
append a list of byte buffer to this queue. By adding a list, the list becomes part of to the buffer, and shouldn`t be modified outside the buffer to avoid side effects

Parameters:
bufs - the list of ByteBuffer

addFirst

public void addFirst(java.nio.ByteBuffer buffer)
add a byte buffer at the first position

Parameters:
buffer - the ByteBuffer to add

addFirst

public void addFirst(java.util.LinkedList<java.nio.ByteBuffer> bufs)
add a list of byte buffer to the first position. By adding a list, the list becomes part of to the buffer, and shouldn`t be modified outside the buffer to avoid side effects.

Parameters:
bufs - the list of ByteBuffer to add

addFirstSilence

public void addFirstSilence(java.util.LinkedList<java.nio.ByteBuffer> bufs)
add a list of byte buffer to the first position. By adding a list, the list becomes part of to the buffer, and shouldn`t be modified outside the buffer to avoid side effects. Buffers will be added silence, which means the insertVersion will not be modified

Parameters:
bufs - the list of ByteBuffer to add

drain

public java.util.LinkedList<java.nio.ByteBuffer> drain()
drain the queue

Returns:
the queue content

removeFirst

public java.nio.ByteBuffer removeFirst()
remove the first ByteBuffer

Returns:
the first ByteBuffer

getInsertVersionVersion

public int getInsertVersionVersion()
return a int, which represent the insert version. this value will increase with each insert modification

Returns:
the modify version

read

public java.nio.ByteBuffer read(int length)
                         throws java.nio.BufferUnderflowException
read bytes

Parameters:
length - the length
Returns:
the read bytes
Throws:
java.nio.BufferUnderflowException - if the buffer`s limit has been reached

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object