org.xlightweb
Class BodyDataSink

Package class diagram package BodyDataSink
java.lang.Object
  extended by org.xlightweb.BodyDataSink
All Implemented Interfaces:
Closeable, Flushable, Channel, GatheringByteChannel, WritableByteChannel, IDataSink, IDestroyable

public abstract class BodyDataSink
extends Object
implements IDataSink, IDestroyable, Flushable, Closeable, WritableByteChannel, GatheringByteChannel

I/O resource capable of sending the body data.


Method Summary
abstract  void addDestroyListener(IBodyDestroyListener destroyListener)
          add a destroy listener
 void close()
          
abstract  void closeQuitly()
          closes this connection by swallowing io exceptions
abstract  void destroy()
          destroys this data sink
abstract  void flush()
          
abstract  Object getAttachment()
          Retrieves the current attachment.
abstract  String getEncoding()
          gets the default encoding
abstract  IConnection.FlushMode getFlushmode()
          see IConnection#getFlushmode()
abstract  String getId()
           
abstract  boolean isAutoflush()
          get autoflush
 boolean isMultipart()
           
abstract  boolean isOpen()
          returns true if the data sink is open
abstract  void markWritePosition()
          Marks the write position in the connection.
abstract  void removeWriteMark()
          remove the write mark
abstract  boolean resetToWriteMark()
          Resets to the marked write position.
abstract  void setAttachment(Object obj)
          Attaches the given object to this connection
abstract  void setAutoflush(boolean autoflush)
          set autoflush.
abstract  void setEncoding(String defaultEncoding)
          sets the default encoding
abstract  void setFlushmode(IConnection.FlushMode flushMode)
          see IConnection#setFlushmode(FlushMode)
abstract  void setSendTimeoutMillis(long sendTimeoutMillis)
          set the sendtimout
abstract  long transferFrom(BodyDataSource source)
          transfer all data from the data source
abstract  long transferFrom(BodyDataSource source, int length)
          transfer data from the data source
abstract  long transferFrom(FileChannel fileChannel)
          
 long transferFrom(InputStream is)
          transfer all data from the data source
abstract  long transferFrom(NonBlockingBodyDataSource source)
          transfer the available data from the data source
abstract  long transferFrom(NonBlockingBodyDataSource source, int length)
          transfer the available data from the data source
 long transferFrom(ReadableByteChannel source)
          
abstract  long transferFrom(ReadableByteChannel source, int chunkSize)
          
 int write(byte... bytes)
          
 int write(byte b)
          
 int write(byte[] bytes, int offset, int length)
          
abstract  int write(ByteBuffer buffer)
          
abstract  long write(ByteBuffer[] buffers)
          
 long write(ByteBuffer[] srcs, int offset, int length)
          
abstract  void write(ByteBuffer[] buffers, IWriteCompletionHandler writeCompletionHandler)
          writes a buffer array
 int write(double d)
          
 int write(int i)
          
 long write(List<ByteBuffer> buffers)
          
 int write(long l)
          
 int write(short s)
          
 int write(String message)
          
 BodyDataSink writePart(IHeader partHeader)
           
 void writePart(IPart part)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isMultipart

public boolean isMultipart()

setSendTimeoutMillis

public abstract void setSendTimeoutMillis(long sendTimeoutMillis)
set the sendtimout

Parameters:
sendTimeoutMillis - the send timeout

flush

public abstract void flush()
                    throws IOException

Specified by:
flush in interface Flushable
Throws:
IOException

close

public final void close()
                 throws IOException

Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Throws:
IOException

closeQuitly

public abstract void closeQuitly()
closes this connection by swallowing io exceptions


write

public abstract void write(ByteBuffer[] buffers,
                           IWriteCompletionHandler writeCompletionHandler)
                    throws IOException
writes a buffer array

Parameters:
buffers - the buffers to write
writeCompletionHandler - the completion handler
Throws:
IOException - if an exception occurs

write

public abstract int write(ByteBuffer buffer)
                   throws IOException,
                          BufferOverflowException

Specified by:
write in interface WritableByteChannel
Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public abstract long write(ByteBuffer[] buffers)
                    throws IOException,
                           BufferOverflowException

Specified by:
write in interface GatheringByteChannel
Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

transferFrom

public abstract long transferFrom(ReadableByteChannel source,
                                  int chunkSize)
                           throws IOException,
                                  BufferOverflowException

Specified by:
transferFrom in interface IDataSink
Throws:
IOException
BufferOverflowException

transferFrom

public abstract long transferFrom(FileChannel fileChannel)
                           throws IOException,
                                  BufferOverflowException

Specified by:
transferFrom in interface IDataSink
Throws:
IOException
BufferOverflowException

transferFrom

public abstract long transferFrom(NonBlockingBodyDataSource source)
                           throws IOException
transfer the available data from the data source

Parameters:
source - the data source
Returns:
the transfered size
Throws:
IOException - if an exception occurs

transferFrom

public abstract long transferFrom(NonBlockingBodyDataSource source,
                                  int length)
                           throws IOException
transfer the available data from the data source

Parameters:
source - the data source
length - the length to transfer
Returns:
the transfered size
Throws:
IOException - if an exception occurs

transferFrom

public abstract long transferFrom(BodyDataSource source)
                           throws IOException
transfer all data from the data source

Parameters:
source - the data source
Returns:
the transfered size
Throws:
IOException - if an exception occurs

transferFrom

public abstract long transferFrom(BodyDataSource source,
                                  int length)
                           throws IOException
transfer data from the data source

Parameters:
source - the data source
length - the length to transfer
Returns:
the transfered size
Throws:
IOException - if an exception occurs

transferFrom

public final long transferFrom(InputStream is)
                        throws IOException
transfer all data from the data source

Parameters:
source - the data source
Returns:
the transfered size
Throws:
IOException - if an exception occurs

transferFrom

public final long transferFrom(ReadableByteChannel source)
                        throws IOException,
                               BufferOverflowException

Specified by:
transferFrom in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public final int write(byte b)
                throws IOException,
                       BufferOverflowException

Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public final int write(byte... bytes)
                throws IOException,
                       BufferOverflowException

Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public final int write(byte[] bytes,
                       int offset,
                       int length)
                throws IOException,
                       BufferOverflowException

Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public final long write(ByteBuffer[] srcs,
                        int offset,
                        int length)
                 throws IOException

Specified by:
write in interface GatheringByteChannel
Specified by:
write in interface IDataSink
Throws:
IOException

write

public final long write(List<ByteBuffer> buffers)
                 throws IOException,
                        BufferOverflowException

Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public final int write(int i)
                throws IOException,
                       BufferOverflowException

Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public final int write(short s)
                throws IOException,
                       BufferOverflowException

Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public final int write(long l)
                throws IOException,
                       BufferOverflowException

Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public final int write(double d)
                throws IOException,
                       BufferOverflowException

Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

write

public final int write(String message)
                throws IOException,
                       BufferOverflowException

Specified by:
write in interface IDataSink
Throws:
IOException
BufferOverflowException

writePart

public final BodyDataSink writePart(IHeader partHeader)
                             throws IOException,
                                    BufferOverflowException
Throws:
IOException
BufferOverflowException

writePart

public final void writePart(IPart part)
                     throws IOException,
                            BufferOverflowException
Throws:
IOException
BufferOverflowException

setEncoding

public abstract void setEncoding(String defaultEncoding)
sets the default encoding

Parameters:
defaultEncoding - the default encoding

getEncoding

public abstract String getEncoding()
gets the default encoding

Returns:
the default encoding

setFlushmode

public abstract void setFlushmode(IConnection.FlushMode flushMode)
see IConnection#setFlushmode(FlushMode)


getFlushmode

public abstract IConnection.FlushMode getFlushmode()
see IConnection#getFlushmode()


setAutoflush

public abstract void setAutoflush(boolean autoflush)
set autoflush. If autoflush is activated, each write call will cause a flush.

Parameters:
autoflush - true if autoflush should be activated

isAutoflush

public abstract boolean isAutoflush()
get autoflush

Returns:
true, if autoflush is activated

markWritePosition

public abstract void markWritePosition()
Marks the write position in the connection.


resetToWriteMark

public abstract boolean resetToWriteMark()
Resets to the marked write position. If the connection has been marked, then attempt to reposition it at the mark.

Returns:
true, if reset was successful

removeWriteMark

public abstract void removeWriteMark()
remove the write mark


setAttachment

public abstract void setAttachment(Object obj)
Attaches the given object to this connection

Parameters:
obj - The object to be attached; may be null

getAttachment

public abstract Object getAttachment()
Retrieves the current attachment.

Returns:
The object currently attached to this key, or null if there is no attachment

isOpen

public abstract boolean isOpen()
returns true if the data sink is open

Specified by:
isOpen in interface Channel
Returns:
true if the data sink is open

getId

public abstract String getId()

destroy

public abstract void destroy()
destroys this data sink

Specified by:
destroy in interface IDestroyable

addDestroyListener

public abstract void addDestroyListener(IBodyDestroyListener destroyListener)
add a destroy listener

Parameters:
destroyListener - the destroy listener to add