Interface Location<T>

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

public interface Location<T> extends Serializable
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 Details

    • 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

      <V> Location<V> copyTo(Location<V> location) throws Exception
      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

      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:
      IllegalArgumentException - 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:
      IllegalArgumentException - if the listener object is null.