it.geosolutions.tools.commons.listener
Class ProgressList<T extends Serializable>

java.lang.Object
  extended by it.geosolutions.tools.commons.listener.ProgressList<T>
Type Parameters:
T - the serializable type for tasks
All Implemented Interfaces:
Progress<T>

public final class ProgressList<T extends Serializable>
extends Object
implements Progress<T>

Thread-safe implementation of list of Progress Listener can be used to propagate events to all the registered list of progress listeners

Author:
Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
See Also:
DefaultProgress

Constructor Summary
ProgressList()
           
 
Method Summary
 boolean addListener(Progress<T> listener)
           
 void onCancel()
          Indicates that task should be cancelled.
 void onCompleted()
          Notifies this listener that the operation has finished.
 void onDispose()
          Releases any resources used by this listener.
 void onExceptionOccurred(Throwable exception)
          Reports an exception.
 void onNewTask(T task)
          Sets the description of the current task being performed.
 void onStart()
          Notifies this listener that the operation begins.
 void onUpdateProgress(float percent)
          Notifies this listener of progress in the lengthly operation.
 void onWarningOccurred(String source, String location, String warning)
          Reports a warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressList

public ProgressList()
Method Detail

addListener

public boolean addListener(Progress<T> listener)
Parameters:
listener - the listener to add
Returns:
as specified Collection.add(Object)

onNewTask

public void onNewTask(T task)
Description copied from interface: Progress
Sets the description of the current task being performed. This method is usually invoked before any progress begins. However, it is legal to invoke this method at any time during the operation, in which case the description display is updated without any change to the percentage accomplished.

Specified by:
onNewTask in interface Progress<T extends Serializable>
Parameters:
task - Description of the task being performed, or null if none.

onStart

public void onStart()
Description copied from interface: Progress
Notifies this listener that the operation begins.

Specified by:
onStart in interface Progress<T extends Serializable>

onUpdateProgress

public void onUpdateProgress(float percent)
Description copied from interface: Progress
Notifies this listener of progress in the lengthly operation. Progress are reported as a value between 0 and 100 inclusive. Values out of bounds will be clamped.

Specified by:
onUpdateProgress in interface Progress<T extends Serializable>
Parameters:
percent - The progress as a value between 0 and 100 inclusive.

onCompleted

public void onCompleted()
Description copied from interface: Progress
Notifies this listener that the operation has finished. The progress indicator will shows 100% or disappears, at implementor choice. If warning messages were pending, they will be displayed now.

Specified by:
onCompleted in interface Progress<T extends Serializable>

onDispose

public void onDispose()
Description copied from interface: Progress
Releases any resources used by this listener. If the progress were reported in a window, this window may be disposed.

Specified by:
onDispose in interface Progress<T extends Serializable>

onCancel

public void onCancel()
Description copied from interface: Progress
Indicates that task should be cancelled.

Specified by:
onCancel in interface Progress<T extends Serializable>

onWarningOccurred

public void onWarningOccurred(String source,
                              String location,
                              String warning)
Description copied from interface: Progress
Reports a warning. This warning may be logged, printed to the standard error stream, appears in a windows or be ignored, at implementor choice.

Specified by:
onWarningOccurred in interface Progress<T extends Serializable>
Parameters:
source - Name of the warning source, or null if none. This is typically the filename in process of being parsed or the URL of the data being processed
location - Text to write on the left side of the warning message, or null if none. This is typically the line number where the error occured in the source file or the feature ID of the feature that produced the message
warning - The warning message.

onExceptionOccurred

public void onExceptionOccurred(Throwable exception)
Description copied from interface: Progress
Reports an exception. This method may prints the stack trace to the standard error stream or display it in a dialog box, at implementor choice.

Specified by:
onExceptionOccurred in interface Progress<T extends Serializable>
Parameters:
exception - The exception to report.


Copyright © 2011-2012 GeoSolutions. All Rights Reserved.