org.jppf.server.protocol
Interface Location<T>

Type Parameters:
T - the type of this location.
All Known Implementing Classes:
AbstractLocation, FileLocation, MemoryLocation, URLLocation

public interface Location<T>

Abstraction of a block of data no matter how its actual location is referred to.

The idea is to enable I/O operations with a very simple API between Location instances, for instance bettween a URL and File locations to download a file from the internet and save it locally.

Author:
Laurent Cohen

Method Summary
 void addLocationEventListener(LocationEventListener listener)
          Add a listener to the list of location event listeners for this location.
 void copyTo(Location location)
          Copy the content at this location to another location.
 InputStream getInputStream()
          Obtain an input stream to read from this location.
 OutputStream getOutputStream()
          Obtain an output stream to write to this location.
 T getPath()
          Get the path for this location.
 void removeLocationEventListener(LocationEventListener listener)
          Remove a listener from the list of location event listeners for this location.
 long size()
          Get the size of the data this location points to.
 byte[] toByteArray()
          Get the content at this location as an array of bytes.
 

Method Detail

getPath

T getPath()
Get the path for this location.

Returns:
the path as a string.

getInputStream

InputStream getInputStream()
                           throws Exception
Obtain an input stream to read from this location.

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

getOutputStream

OutputStream getOutputStream()
                             throws Exception
Obtain an output stream to write to this location.

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

copyTo

void copyTo(Location location)
            throws Exception
Copy the content at this location to another location.

Parameters:
location - the location to copy to.
Throws:
Exception - if an I/O error occurs.

size

long size()
Get the size of the data this location points to.

Returns:
the size as a long value, or -1 if the size is not available.

toByteArray

byte[] toByteArray()
                   throws Exception
Get the content at this location as an array of bytes.

Returns:
a byte array.
Throws:
Exception - if an I/O error occurs.

addLocationEventListener

void addLocationEventListener(LocationEventListener listener)
Add a listener to the list of location event listeners for this location.

Parameters:
listener - the listener to add to the list.
Throws:
NullPointerException - if the listener object is null.

removeLocationEventListener

void removeLocationEventListener(LocationEventListener listener)
Remove a listener from the list of location event listeners for this location.

Parameters:
listener - the listener to remove from the list.
Throws:
NullPointerException - if the listener object is null.


Copyright © 2005-2010 JPPF Team.