Package org.jppf.location
Interface Location<T>
- Type Parameters:
T- the type of this location.
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractLocation,FileLocation,MavenCentralLocation,MavenLocation,MemoryLocation,URLLocation
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 between a URL and File locations to download a file from the internet and save it locally.
- Author:
- Laurent Cohen
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener to the list of location event listeners for this location.<V> Location<V>Copy the content at this location to another location.Obtain an input stream to read from this location.Obtain an output stream to write to this location.getPath()Get the path for this location.voidRemove a listener from the list of location event listeners for this location.longsize()Get the size of the data this location points to.byte[]Get the content at this location as an array of bytes.
-
Method Details
-
getPath
T getPath()Get the path for this location.- Returns:
- the path as a string.
-
getInputStream
Obtain an input stream to read from this location.- Returns:
- an
InputStreaminstance. - Throws:
Exception- if an I/O error occurs.
-
getOutputStream
Obtain an output stream to write to this location.- Returns:
- an
OutputStreaminstance. - Throws:
Exception- if an I/O error occurs.
-
copyTo
Copy the content at this location to another location.- Type Parameters:
V- the type of path for the destination location.- Parameters:
location- the destination location to copy to.- Returns:
- the destination location.
- 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
Get the content at this location as an array of bytes.- Returns:
- a byte array.
- Throws:
Exception- if an I/O error occurs.
-
addLocationEventListener
Add a listener to the list of location event listeners for this location.- Parameters:
listener- the listener to add to the list.- Throws:
IllegalArgumentException- if the listener object is null.
-
removeLocationEventListener
Remove a listener from the list of location event listeners for this location.- Parameters:
listener- the listener to remove from the list.- Throws:
IllegalArgumentException- if the listener object is null.
-