org.jppf.io
Class FileDataLocation

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

public class FileDataLocation
extends AbstractDataLocation

Data location backed by a file.

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
FileDataLocation(File file)
          Initialize this file location with the specified file and unknown size.
FileDataLocation(File file, int size)
          Initialize this file location with the specified file and size.
FileDataLocation(String path)
          Initialize this file location with the specified file path and an unknown size.
FileDataLocation(String path, int size)
          Initialize this file location with the specified file path and size.
 
Method Summary
 DataLocation copy()
          Make a shallow copy of this data location.
protected  void finalize()
          This method deletes the underlying file.
 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, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDataLocation

public FileDataLocation(String path)
Initialize this file location with the specified file path and an unknown size.

Parameters:
path - the path to the underlying file.

FileDataLocation

public FileDataLocation(String path,
                        int size)
Initialize this file location with the specified file path and size.

Parameters:
path - the path to the underlying file.
size - the size of the data represented by this file location.

FileDataLocation

public FileDataLocation(File file)
Initialize this file location with the specified file and unknown size.

Parameters:
file - an abstract path to the underlying file.

FileDataLocation

public FileDataLocation(File file,
                        int size)
Initialize this file location with the specified file and size.

Parameters:
file - an abstract path to the underlying file.
size - the size of the data represented by this file location.
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 from.
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.
See Also:
DataLocation.transferFrom(org.jppf.io.InputSource, boolean)

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.
See Also:
DataLocation.transferTo(org.jppf.io.OutputDestination, boolean)

finalize

protected void finalize()
                 throws Throwable
This method deletes the underlying file.

Overrides:
finalize in class Object
Throws:
Throwable - if an error occurs.
See Also:
Object.finalize()

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.
See Also:
DataLocation.getInputStream()

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.
See Also:
DataLocation.getOutputStream()

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.
See Also:
DataLocation.copy()


Copyright © 2005-2010 JPPF Team.