org.jppf.io
Class ChannelOutputDestination

java.lang.Object
  extended by org.jppf.io.ChannelOutputDestination
All Implemented Interfaces:
Closeable, IO, OutputDestination
Direct Known Subclasses:
FileOutputDestination

public class ChannelOutputDestination
extends Object
implements OutputDestination

Output destination backed by a WritableByteChannel.

Author:
Laurent Cohen

Field Summary
protected  WritableByteChannel channel
          The backing WritableByteChannel.
 
Constructor Summary
ChannelOutputDestination(WritableByteChannel channel)
          Initialize this output destination with the specified SocketWrapper.
 
Method Summary
 void close()
          This method does nothing.
 int write(byte[] data, int offset, int len)
          Write data to this output destination from an array of bytes.
 int write(ByteBuffer data)
          Write data to this output destination from a byte buffer.
 void writeInt(int value)
          Write an int value to this output destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channel

protected WritableByteChannel channel
The backing WritableByteChannel.

Constructor Detail

ChannelOutputDestination

public ChannelOutputDestination(WritableByteChannel channel)
Initialize this output destination with the specified SocketWrapper.

Parameters:
channel - the backing SocketWrapper.
Method Detail

write

public int write(byte[] data,
                 int offset,
                 int len)
          throws Exception
Write data to this output destination from an array of bytes.

Specified by:
write in interface OutputDestination
Parameters:
data - the buffer containing the data to write.
offset - the position in the buffer where to start reading the data.
len - the size in bytes of the data to write.
Returns:
the number of bytes actually written, or -1 if end of stream was reached.
Throws:
Exception - if an IO error occurs.
See Also:
OutputDestination.write(byte[], int, int)

write

public int write(ByteBuffer data)
          throws Exception
Write data to this output destination from a byte buffer.

Specified by:
write in interface OutputDestination
Parameters:
data - the buffer containing the data to write.
Returns:
the number of bytes actually written, or -1 if end of stream was reached.
Throws:
Exception - if an IO error occurs.
See Also:
OutputDestination.write(java.nio.ByteBuffer)

writeInt

public void writeInt(int value)
              throws Exception
Write an int value to this output destination.

Specified by:
writeInt in interface OutputDestination
Parameters:
value - the value to write.
Throws:
Exception - if an IO error occurs.
See Also:
OutputDestination.writeInt(int)

close

public void close()
           throws IOException
This method does nothing.

Specified by:
close in interface Closeable
Throws:
IOException - if an IO error occurs.
See Also:
Closeable.close()


Copyright © 2005-2010 JPPF Team.