org.jppf.io
Class MultipleBuffersLocation

java.lang.Object
  extended by org.jppf.io.AbstractDataLocation
      extended by org.jppf.io.MultipleBuffersLocation
All Implemented Interfaces:
DataLocation

public class MultipleBuffersLocation
extends AbstractDataLocation

Data location backed by a list of JPPFBuffer.

Author:
Laurent Cohen

Field Summary
 
Fields inherited from class org.jppf.io.AbstractDataLocation
size, transferring
 
Fields inherited from interface org.jppf.io.DataLocation
UNKNOWN_SIZE
 
Constructor Summary
MultipleBuffersLocation(int size)
          Initialize this location with the specified size.
MultipleBuffersLocation(JPPFBuffer buffer)
          Initialize this location from a single buffer.
MultipleBuffersLocation(List<JPPFBuffer> list, int size)
          Initialize this location with the specified list of buffers and size.
 
Method Summary
 DataLocation copy()
          Make a shallow copy of this data location.
 InputStream getInputStream()
          Get an input stream for this location.
 OutputStream getOutputStream()
          Get an output stream for this location.
 int transferFrom(InputSource source, boolean blocking)
          Transfer the content of this data location from the specified input source.
 int transferTo(OutputDestination dest, boolean blocking)
          Transfer the content of this data location to the specified output destination.
 
Methods inherited from class org.jppf.io.AbstractDataLocation
getSize, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipleBuffersLocation

public MultipleBuffersLocation(int size)
Initialize this location with the specified size.

Parameters:
size - the total size of the data.

MultipleBuffersLocation

public MultipleBuffersLocation(List<JPPFBuffer> list,
                               int size)
Initialize this location with the specified list of buffers and size.

Parameters:
list - the list of buffers that contain the data.
size - the total size of the data.

MultipleBuffersLocation

public MultipleBuffersLocation(JPPFBuffer buffer)
Initialize this location from a single buffer.

Parameters:
buffer - the buffer that contains the data.
Method Detail

transferFrom

public int transferFrom(InputSource source,
                        boolean blocking)
                 throws Exception
Transfer the content of this data location from the specified input source.

Parameters:
source - - the input source to transfer to.
blocking - - if true, the method will block until the entire content has been transferred.
Returns:
the number of bytes actually transferred.
Throws:
Exception - if an IO error occurs.

transferTo

public int transferTo(OutputDestination dest,
                      boolean blocking)
               throws Exception
Transfer the content of this data location to the specified output destination.

Parameters:
dest - - the output destination to transfer to.
blocking - - if true, the method will block until the entire content has been transferred.
Returns:
the number of bytes actually transferred.
Throws:
Exception - if an IO error occurs.

getInputStream

public InputStream getInputStream()
                           throws Exception
Get an input stream for this location.

Returns:
an InputStream instance.
Throws:
Exception - if an I/O error occurs.

getOutputStream

public OutputStream getOutputStream()
                             throws Exception
Get an output stream for this location.

Returns:
an OutputStream instance.
Throws:
Exception - if an I/O error occurs.

copy

public DataLocation copy()
Make a shallow copy of this data location. The data it points to is not copied.

Returns:
a new DataLocation instance pointing to the same data.


Copyright © 2005-2010 JPPF Team.