|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objectorg.xlightweb.NonBlockingBodyDataSource
public abstract class NonBlockingBodyDataSource
data source base implementation
| Method Summary | |
|---|---|
void |
addCompleteListener(IBodyCompleteListener listener)
adds a complete listener |
void |
addDestroyListener(IBodyDestroyListener destroyListener)
add a destroy listener |
int |
available()
returns the available bytes |
void |
close()
closes the body data source |
void |
closeQuitly()
closes this connection by swallowing io exceptions |
void |
destroy()
destroys the data source |
long |
getBodyDataReceiveTimeoutMillis()
returns body data receive timeout |
IBodyDataHandler |
getDataHandler()
returns the body data handler or null if no data handler is assigned |
int |
getReadBufferVersion()
get the version of read buffer. |
int |
indexOf(String str)
Returns the index of the first occurrence of the given string. |
int |
indexOf(String str,
String encoding)
Returns the index of the first occurrence of the given string. |
boolean |
isMultipart()
return true if the body is a mulipart |
protected abstract boolean |
isNetworkendpoint()
|
boolean |
isOpen()
returns true, if the body data source is open |
void |
markReadPosition()
Marks the read position in the connection. |
protected void |
onRead()
|
int |
read(ByteBuffer buffer)
see ReadableByteChannel.read(ByteBuffer) |
byte |
readByte()
read a byte |
ByteBuffer[] |
readByteBufferByDelimiter(String delimiter)
read a ByteBuffer by using a delimiter. |
ByteBuffer[] |
readByteBufferByDelimiter(String delimiter,
int maxLength)
read a ByteBuffer by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
ByteBuffer[] |
readByteBufferByLength(int length)
read a ByteBuffer |
byte[] |
readBytesByDelimiter(String delimiter)
read a byte array by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
byte[] |
readBytesByDelimiter(String delimiter,
int maxLength)
read a byte array by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes |
byte[] |
readBytesByLength(int length)
read bytes by using a length definition |
double |
readDouble()
read a double |
int |
readInt()
read an int |
long |
readLong()
read a long |
IPart |
readPart()
read the part of the multipart body. |
short |
readShort()
read a short value |
String |
readStringByDelimiter(String delimiter)
read a string by using a delimiter |
String |
readStringByDelimiter(String delimiter,
int maxLength)
read a string by using a delimiter |
String |
readStringByDelimiter(String delimiter,
String encoding)
read a string by using a delimiter |
String |
readStringByDelimiter(String delimiter,
String encoding,
int maxLength)
read a string by using a delimiter |
String |
readStringByLength(int length)
read a string by using a length definition |
String |
readStringByLength(int length,
String encoding)
read a string by using a length definition |
void |
removeReadMark()
remove the read mark |
boolean |
resetToReadMark()
Resets to the marked read position. |
void |
setBodyDataReceiveTimeoutMillis(long bodyDataReceiveTimeoutMillis)
set the body data receive timeout |
void |
setBodyPartHandler(IPartHandler partHandler)
set the part handler. |
void |
setDataHandler(IBodyDataHandler bodyDataHandler)
set the body handler |
String |
toString()
|
long |
transferTo(BodyDataSink dataSink)
transfer the available data of the this source channel to the given data sink |
long |
transferTo(BodyDataSink dataSink,
int length)
transfer the data of the this source channel to the given data sink |
void |
transferTo(File file,
org.xlightweb.NonBlockingBodyDataSource.ITransferResultHandler resultHandler)
transfer the data of the this source channel to the given file |
long |
transferTo(WritableByteChannel target,
int length)
transfer the data of the this source channel to the given data sink |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public final void addDestroyListener(IBodyDestroyListener destroyListener)
destroyListener - the destroy listener to addpublic final boolean isMultipart()
public void destroy()
public void addCompleteListener(IBodyCompleteListener listener)
listener - the complete listenerpublic final void setDataHandler(IBodyDataHandler bodyDataHandler)
bodyDataHandler - the body handler
public IPart readPart()
throws NoMultipartTypeException,
IOException,
BufferUnderflowException
BodyDataSource.isMultipart() can
be used to verify if the body is a multipart one
NoMultipartTypeException - if the body is not a multipart body
IOException - if an exception occurs
BufferUnderflowException - if not enough data is available
public void setBodyPartHandler(IPartHandler partHandler)
throws NoMultipartTypeException,
IOException
BodyDataSource.isMultipart() can
be used to verify if the body is a multipart one
bodyDataHandler - the body handler
IOException - if an exception occurs
NoMultipartTypeException - if the body is not a multipart bodypublic IBodyDataHandler getDataHandler()
null if no data handler is assigned
null if no data handler is assignedpublic final void setBodyDataReceiveTimeoutMillis(long bodyDataReceiveTimeoutMillis)
bodyDataReceiveTimeoutMillis - the timeout
public final int available()
throws ProtocolException,
IOException
ProtocolException - if a protocol error occurs
IOException - if some other exception occurs
public final void close()
throws IOException
close in interface Closeableclose in interface ChannelIOException - if an exception occurspublic final void closeQuitly()
public final boolean isOpen()
isOpen in interface Channel
public final int read(ByteBuffer buffer)
throws IOException
ReadableByteChannel.read(ByteBuffer)
read in interface ReadableByteChannelread in interface IDataSourceIOException
public long transferTo(BodyDataSink dataSink)
throws ProtocolException,
IOException,
ClosedChannelException
dataSink - the data sink
ClosedChannelException - If either this channel or the target channel is closed
IOException - If some other I/O error occurs
ProtocolException
public long transferTo(BodyDataSink dataSink,
int length)
throws ProtocolException,
IOException,
ClosedChannelException
dataSink - the data sinklength - the size to transfer
ClosedChannelException - If either this channel or the target channel is closed
IOException - If some other I/O error occurs
ProtocolException
public final long transferTo(WritableByteChannel target,
int length)
throws IOException,
ClosedChannelException
transferTo in interface IDataSourcedataSink - the data sinklength - the size to transfer
ClosedChannelException - If either this channel or the target channel is closed
IOException - If some other I/O error occurs
public final void transferTo(File file,
org.xlightweb.NonBlockingBodyDataSource.ITransferResultHandler resultHandler)
throws IOException,
FileNotFoundException,
ClosedChannelException
file - the fileresultHandler - the transferResultHandler
FileNotFoundException - If the file does not exist
ClosedChannelException - If either this channel or the target channel is closed
IOException - If some other I/O error occurs
public final ByteBuffer[] readByteBufferByDelimiter(String delimiter,
int maxLength)
throws IOException,
MaxReadSizeExceededException
readByteBufferByDelimiter in interface IDataSourcedelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn't been found
IOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is available
public final ByteBuffer[] readByteBufferByLength(int length)
throws IOException,
BufferUnderflowException
readByteBufferByLength in interface IDataSourcelength - the length could be negative, in this case a empty array will be returned
IOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is available
protected void onRead()
throws IOException
IOExceptionprotected abstract boolean isNetworkendpoint()
public final ByteBuffer[] readByteBufferByDelimiter(String delimiter)
throws IOException
IReadWriteableConnection#readByteBufferByDelimiter(String, int) method is generally preferable
readByteBufferByDelimiter in interface IDataSourcedelimiter - the delimiter
IOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is available
public final byte[] readBytesByDelimiter(String delimiter)
throws IOException
readBytesByDelimiter in interface IDataSourcedelimiter - the delimiter
IOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is available
public final byte[] readBytesByDelimiter(String delimiter,
int maxLength)
throws IOException,
MaxReadSizeExceededException
readBytesByDelimiter in interface IDataSourcedelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn�t been found
IOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is available
public final byte[] readBytesByLength(int length)
throws IOException
readBytesByLength in interface IDataSourcelength - the amount of bytes to read
IOException - If some other I/O error occurs
IllegalArgumentException, - if the length parameter is negative
BufferUnderflowException - if not enough data is available
public final String readStringByDelimiter(String delimiter)
throws IOException,
UnsupportedEncodingException
readStringByDelimiter in interface IDataSourcedelimiter - the delimiter
IOException - If some other I/O error occurs
UnsupportedEncodingException - if the default encoding is not supported
BufferUnderflowException - if not enough data is available
public final String readStringByDelimiter(String delimiter,
String encoding)
throws IOException,
UnsupportedEncodingException
delimiter - the delimiterencoding - encoding
IOException - If some other I/O error occurs
UnsupportedEncodingException - if the default encoding is not supported
BufferUnderflowException - if not enough data is available
public final String readStringByDelimiter(String delimiter,
int maxLength)
throws IOException,
UnsupportedEncodingException,
MaxReadSizeExceededException
readStringByDelimiter in interface IDataSourcedelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn�t been found
IOException - If some other I/O error occurs
UnsupportedEncodingException - If the given encoding is not supported
BufferUnderflowException - if not enough data is available
public final String readStringByDelimiter(String delimiter,
String encoding,
int maxLength)
throws IOException,
UnsupportedEncodingException,
MaxReadSizeExceededException
delimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrownencoding - the encoding
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn�t been found
IOException - If some other I/O error occurs
UnsupportedEncodingException - If the given encoding is not supported
BufferUnderflowException - if not enough data is available
public final String readStringByLength(int length)
throws IOException,
BufferUnderflowException
readStringByLength in interface IDataSourcelength - the amount of bytes to read
IOException - If some other I/O error occurs
UnsupportedEncodingException - if the given encoding is not supported
IllegalArgumentException, - if the length parameter is negative
BufferUnderflowException - if not enough data is available
public final String readStringByLength(int length,
String encoding)
throws IOException,
BufferUnderflowException
length - the amount of bytes to readencoding - the encoding
IOException - If some other I/O error occurs
UnsupportedEncodingException - if the given encoding is not supported
IllegalArgumentException, - if the length parameter is negative
BufferUnderflowException - if not enough data is available
public final double readDouble()
throws IOException
readDouble in interface IDataSourceIOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is available
public final long readLong()
throws IOException
readLong in interface IDataSourceIOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is available
public final int readInt()
throws IOException
readInt in interface IDataSourceIOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is available
public final short readShort()
throws IOException
readShort in interface IDataSourceIOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is available
public final byte readByte()
throws IOException
readByte in interface IDataSourceIOException - If some other I/O error occurs
BufferUnderflowException - if not enough data is availablepublic final void markReadPosition()
public final boolean resetToReadMark()
public final void removeReadMark()
public final int indexOf(String str)
throws IOException
str - any string
IOException - If some other I/O error occurs
public final int indexOf(String str,
String encoding)
throws IOException,
MaxReadSizeExceededException
str - any stringencoding - the encoding to use
IOException - If some other I/O error occurs
MaxReadSizeExceededException
public int getReadBufferVersion()
throws IOException
IOException - if an exception occurspublic long getBodyDataReceiveTimeoutMillis()
nullpublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||