org.xsocket.connection
Interface AbstractNonBlockingStream.ISource

Package class diagram package AbstractNonBlockingStream.ISource
Enclosing class:
AbstractNonBlockingStream

public static interface AbstractNonBlockingStream.ISource


Method Summary
 void addFirst(ByteBuffer[] bufs)
           
 void append(ByteBuffer[] bufs, int size)
          append a byte buffer array to this source.
 ByteBuffer[] copy()
           
 ByteBuffer[] drain()
          drain the source
 int getSize()
          return the current size
 int getVersion(boolean mark)
          return a int, which represent the version.
 ByteBuffer[] readByteBufferByDelimiter(byte[] delimiter, int maxLength)
           
 ByteBuffer[] readByteBufferByLength(int length)
           
 ByteBuffer readSingleByteBuffer(int length)
          read bytes
 void reset()
          clean the source
 int retrieveIndexOf(byte[] delimiter, int maxReadSize)
          return the index of the delimiter or -1 if the delimiter has not been found
 void setVersion(int version)
           
 String toString(String encoding)
           
 

Method Detail

reset

void reset()
clean the source


getVersion

int getVersion(boolean mark)
return a int, which represent the version. this value will increase with modification

Returns:
the modify version

setVersion

void setVersion(int version)

getSize

int getSize()
return the current size

Returns:
the current size

append

void append(ByteBuffer[] bufs,
            int size)
append a byte buffer array to this source. By adding a array, the array becomes part of to the buffer, and should not be modified outside the buffer to avoid side effects

Parameters:
bufs - the ByteBuffers
size - the size

addFirst

void addFirst(ByteBuffer[] bufs)

drain

ByteBuffer[] drain()
drain the source

Returns:
the content

copy

ByteBuffer[] copy()

readSingleByteBuffer

ByteBuffer readSingleByteBuffer(int length)
                                throws BufferUnderflowException
read bytes

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

readByteBufferByLength

ByteBuffer[] readByteBufferByLength(int length)
                                    throws BufferUnderflowException
Throws:
BufferUnderflowException

readByteBufferByDelimiter

ByteBuffer[] readByteBufferByDelimiter(byte[] delimiter,
                                       int maxLength)
                                       throws IOException,
                                              BufferUnderflowException,
                                              MaxReadSizeExceededException
Throws:
IOException
BufferUnderflowException
MaxReadSizeExceededException

retrieveIndexOf

int retrieveIndexOf(byte[] delimiter,
                    int maxReadSize)
                    throws IOException,
                           MaxReadSizeExceededException
return the index of the delimiter or -1 if the delimiter has not been found

Parameters:
delimiter - the delimiter
maxReadSize - the max read size
Returns:
the position of the first delimiter byte
Throws:
IOException - in an exception occurs
MaxReadSizeExceededException - if the max read size has been reached

toString

String toString(String encoding)


Copyright 2010 xSocket.org