org.xsocket
Interface IDataSink

Package class diagram package IDataSink
All Known Subinterfaces:
IBlockingConnection, INonBlockingConnection
All Known Implementing Classes:
BlockingConnection, NonBlockingConnection, UserDatagram

public interface IDataSink

A data sink is an I/O resource capable of receiving data.

Author:
grro@xsocket.org

Method Summary
 long transferFrom(FileChannel source)
          transfer the data of the source file channel to this data sink
 long transferFrom(ReadableByteChannel source)
          transfer the data of the source channel to this data sink by using the default chunk size
 long transferFrom(ReadableByteChannel source, int chunkSize)
          transfer the data of the source channel to this data sink
 int write(byte... bytes)
          writes bytes to the data sink
 int write(byte b)
          writes a byte to the data sink
 int write(byte[] bytes, int offset, int length)
          writes bytes to the data sink
 int write(ByteBuffer buffer)
          see WritableByteChannel.write(ByteBuffer)
 long write(ByteBuffer[] buffers)
          see GatheringByteChannel.write(ByteBuffer[])
 long write(ByteBuffer[] srcs, int offset, int length)
          see GatheringByteChannel.write(ByteBuffer[], int, int)
 int write(double d)
          writes a double to the data sink
 int write(int i)
          writes a int to the data sink
 long write(List<ByteBuffer> buffers)
          writes a list of bytes to the data sink
 int write(long l)
          writes a long to the data sink
 int write(short s)
          writes a short to the data sink
 int write(String message)
          writes a message
 

Method Detail

write

int write(byte b)
          throws IOException,
                 BufferOverflowException
writes a byte to the data sink

Parameters:
b - the byte to write
Returns:
the number of written bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

write

int write(byte... bytes)
          throws IOException,
                 BufferOverflowException
writes bytes to the data sink

Parameters:
bytes - the bytes to write
Returns:
the number of written bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

write

int write(byte[] bytes,
          int offset,
          int length)
          throws IOException,
                 BufferOverflowException
writes bytes to the data sink

Parameters:
bytes - the bytes to write
offset - The offset of the sub array to be used; must be non-negative and no larger than array.length. The new buffer`s position will be set to this value.
length - The length of the sub array to be used; must be non-negative and no larger than array.length - offset. The new buffer`s limit will be set to offset + length.
Returns:
the number of written bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

write

int write(ByteBuffer buffer)
          throws IOException,
                 BufferOverflowException
see WritableByteChannel.write(ByteBuffer)

Throws:
IOException
BufferOverflowException

write

long write(ByteBuffer[] buffers)
           throws IOException,
                  BufferOverflowException
see GatheringByteChannel.write(ByteBuffer[])

Throws:
IOException
BufferOverflowException

write

long write(ByteBuffer[] srcs,
           int offset,
           int length)
           throws IOException
see GatheringByteChannel.write(ByteBuffer[], int, int)

Throws:
IOException

write

long write(List<ByteBuffer> buffers)
           throws IOException,
                  BufferOverflowException
writes a list of bytes to the data sink

Parameters:
buffers - the bytes to write
Returns:
the number of written bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

write

int write(int i)
          throws IOException,
                 BufferOverflowException
writes a int to the data sink

Parameters:
i - the int value to write
Returns:
the number of written bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

write

int write(short s)
          throws IOException,
                 BufferOverflowException
writes a short to the data sink

Parameters:
s - the short value to write
Returns:
the number of written bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

write

int write(long l)
          throws IOException,
                 BufferOverflowException
writes a long to the data sink

Parameters:
l - the int value to write
Returns:
the number of written bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

write

int write(double d)
          throws IOException,
                 BufferOverflowException
writes a double to the data sink

Parameters:
d - the int value to write
Returns:
the number of written bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

write

int write(String message)
          throws IOException,
                 BufferOverflowException
writes a message

Parameters:
message - the message to write
Returns:
the number of written bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

transferFrom

long transferFrom(FileChannel source)
                  throws IOException,
                         BufferOverflowException
transfer the data of the source file channel to this data sink

Parameters:
source - the source channel
Returns:
the number of transfered bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

transferFrom

long transferFrom(ReadableByteChannel source)
                  throws IOException,
                         BufferOverflowException
transfer the data of the source channel to this data sink by using the default chunk size

Parameters:
source - the source channel
Returns:
the number of transfered bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs

transferFrom

long transferFrom(ReadableByteChannel source,
                  int chunkSize)
                  throws IOException,
                         BufferOverflowException
transfer the data of the source channel to this data sink

Parameters:
source - the source channel
chunkSize - the chunk size to use
Returns:
the number of transfered bytes
Throws:
BufferOverflowException - If the no enough space is available
IOException - If some other I/O error occurs


Copyright 2010 xSocket.org