Package org.jppf.io

Class MultipleBuffersLocation

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

public class MultipleBuffersLocation extends AbstractDataLocation
Data location backed by a list of JPPFBuffer.
Author:
Laurent Cohen
  • Constructor Details

    • 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(List<JPPFBuffer> buffers)
      Initialize this location with the specified list of buffers. The size is computed as the sum of used sizes of all buffers.
      Parameters:
      buffers - the list of buffers that contain the data.
    • MultipleBuffersLocation

      public MultipleBuffersLocation(JPPFBuffer... buffers)
      Initialize this location from an array of buffers.
      Parameters:
      buffers - the buffers that contain the data.
    • MultipleBuffersLocation

      public MultipleBuffersLocation(int size, JPPFBuffer... buffers)
      Initialize this location from an array of buffers.
      Parameters:
      size - the data total size.
      buffers - the buffers that contain the data.
    • MultipleBuffersLocation

      public MultipleBuffersLocation(byte[]... buffers)
      Initialize this location from an array of buffers.
      Parameters:
      buffers - the buffers that contain the data.
  • Method Details

    • transferFrom

      public int transferFrom(InputSource source, boolean blocking) throws Exception
      Description copied from interface: DataLocation
      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
      Description copied from interface: DataLocation
      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
      Description copied from interface: DataLocation
      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
      Description copied from interface: DataLocation
      Get an output stream for this location.
      Returns:
      an OutputStream instance.
      Throws:
      Exception - if an I/O error occurs.
    • copy

      public DataLocation copy()
      Description copied from interface: DataLocation
      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.
    • getBuffer

      public JPPFBuffer getBuffer(int n)
      Get the buffer at the specified index..
      Parameters:
      n - the index of the buffer to get.
      Returns:
      a list of JPPFBuffer instances.
    • reset

      public MultipleBuffersLocation reset()
      Reset the state of this location.
      Returns:
      this location, for method call chaining.
    • toString

      public String toString()
      Overrides:
      toString in class Object