Class AbstractLocation<T>

java.lang.Object
org.jppf.location.AbstractLocation<T>
Type Parameters:
T - the type of this location.
All Implemented Interfaces:
Serializable, Location<T>
Direct Known Subclasses:
FileLocation, MemoryLocation, URLLocation

public abstract class AbstractLocation<T> extends Object implements Location<T>
Instances of this class represent the location of an artifact, generally a file or the data found at a url.
Author:
Laurent Cohen
See Also:
  • Field Details

    • path

      protected final T path
      The path for this location.
    • listeners

      protected final List<LocationEventListener> listeners
      The list of listeners to this location.
    • eventsEnabled

      protected boolean eventsEnabled
      Boolean flag that determines if at least one listener is registered. Used to minimize the overhead of sending events if there is no listener.
  • Constructor Details

    • AbstractLocation

      public AbstractLocation(T path)
      Initialize this location with the specified type and path.
      Parameters:
      path - the path for this location.
  • Method Details

    • getPath

      public T getPath()
      Description copied from interface: Location
      Get the path for this location.
      Specified by:
      getPath in interface Location<T>
      Returns:
      the path as a string.
    • copyTo

      public <V> Location<V> copyTo(Location<V> location) throws Exception
      Description copied from interface: Location
      Copy the content at this location to another location.
      Specified by:
      copyTo in interface Location<T>
      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.
    • toByteArray

      public byte[] toByteArray() throws Exception
      Description copied from interface: Location
      Get the content at this location as an array of bytes.
      Specified by:
      toByteArray in interface Location<T>
      Returns:
      a byte array.
      Throws:
      Exception - if an I/O error occurs.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addLocationEventListener

      public void addLocationEventListener(LocationEventListener listener)
      Description copied from interface: Location
      Add a listener to the list of location event listeners for this location.
      Specified by:
      addLocationEventListener in interface Location<T>
      Parameters:
      listener - the listener to add to the list.
    • removeLocationEventListener

      public void removeLocationEventListener(LocationEventListener listener)
      Description copied from interface: Location
      Remove a listener from the list of location event listeners for this location.
      Specified by:
      removeLocationEventListener in interface Location<T>
      Parameters:
      listener - the listener to remove from the list.
    • fireLocationEvent

      protected void fireLocationEvent(long n)
      Notify all listeners that a data transfer has occurred.
      Parameters:
      n - the size of the data that was transferred.