Package org.jppf.location
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
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 Summary
FieldsModifier and TypeFieldDescriptionprotected booleanBoolean flag that determines if at least one listener is registered.protected final List<LocationEventListener>The list of listeners to this location.protected final TThe path for this location. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractLocation(T path) Initialize this location with the specified type and path. -
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.protected voidfireLocationEvent(long n) Notify all listeners that a data transfer has occurred.getPath()Get the path for this location.voidRemove a listener from the list of location event listeners for this location.byte[]Get the content at this location as an array of bytes.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jppf.location.Location
getInputStream, getOutputStream, size
-
Field Details
-
path
The path for this location. -
listeners
The list of listeners to this location. -
eventsEnabled
protected boolean eventsEnabledBoolean 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
Initialize this location with the specified type and path.- Parameters:
path- the path for this location.
-
-
Method Details
-
getPath
Description copied from interface:LocationGet the path for this location. -
copyTo
Description copied from interface:LocationCopy the content at this location to another location. -
toByteArray
Description copied from interface:LocationGet the content at this location as an array of bytes.- Specified by:
toByteArrayin interfaceLocation<T>- Returns:
- a byte array.
- Throws:
Exception- if an I/O error occurs.
-
toString
-
addLocationEventListener
Description copied from interface:LocationAdd a listener to the list of location event listeners for this location.- Specified by:
addLocationEventListenerin interfaceLocation<T>- Parameters:
listener- the listener to add to the list.
-
removeLocationEventListener
Description copied from interface:LocationRemove a listener from the list of location event listeners for this location.- Specified by:
removeLocationEventListenerin interfaceLocation<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.
-