org.geotools.util
Class DefaultProgressListener

Object
  extended by NullProgressListener
      extended by DefaultProgressListener
All Implemented Interfaces:
ProgressListener

public class DefaultProgressListener
extends NullProgressListener
implements ProgressListener, ProgressListener

Default Implementation of ProgressListener that does retain exceptions.

We do not put particular attention on the management of canceled, started, completed, this is a default implementation.

Since:
2.8
Author:
Simone Giannecchini, GeoSolutions SAS

Nested Class Summary
static class DefaultProgressListener.Warning
          Collector class for warnings.
 
Constructor Summary
DefaultProgressListener()
           
 
Method Summary
 void complete()
          Notifies this listener that the operation has finished.
 void dispose()
          Release any resources used by this listener.
 void exceptionOccurred(Throwable exception)
          Reports an exception.
 Queue<Throwable> getExceptions()
          Return a copy of the Queue of exceptions that had happened.
 float getProgress()
          Returns the current progress as a percent completed.
 InternationalString getTask()
          Returns the description of the current task being performed, or null if none.
 Queue<DefaultProgressListener.Warning> getWarnings()
          Retrieves a copy of the warnings occurred.
 boolean hasExceptions()
          It tells us if we have exceptions or not.
 boolean isCompleted()
          Is the task we are listening is completed.
 boolean isStarted()
          Is the task we are listening for started.
 void progress(float percent)
          Notifies this listener of progress in the lengthly operation.
 void setTask(InternationalString task)
          Sets the description of the current task being performed.
 void started()
          Notifies this listener that the operation begins.
 String toString()
           
 void warningOccurred(String source, String margin, String warning)
          Reports a warning.
 
Methods inherited from class NullProgressListener
getDescription, isCanceled, setCanceled, setDescription
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ProgressListener
getDescription, isCanceled, setCanceled, setDescription
 

Constructor Detail

DefaultProgressListener

public DefaultProgressListener()
Method Detail

toString

public String toString()
Overrides:
toString in class Object

complete

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

Specified by:
complete in interface ProgressListener
Overrides:
complete in class NullProgressListener

dispose

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

Specified by:
dispose in interface ProgressListener
Overrides:
dispose in class NullProgressListener

exceptionOccurred

public void exceptionOccurred(Throwable exception)
Description copied from interface: ProgressListener
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:
exceptionOccurred in interface ProgressListener
Overrides:
exceptionOccurred in class NullProgressListener
Parameters:
exception - The exception to report.

progress

public void progress(float percent)
Description copied from interface: ProgressListener
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:
progress in interface ProgressListener
Overrides:
progress in class NullProgressListener
Parameters:
percent - The progress as a value between 0 and 100 inclusive.

started

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

Specified by:
started in interface ProgressListener
Overrides:
started in class NullProgressListener

warningOccurred

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

Specified by:
warningOccurred in interface ProgressListener
Overrides:
warningOccurred in class NullProgressListener
Parameters:
source - The source of the warning, or null if none. This is typically the filename in process of being parsed.
margin - 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.
warning - The warning message.

getProgress

public float getProgress()
Description copied from interface: ProgressListener
Returns the current progress as a percent completed.

Specified by:
getProgress in interface ProgressListener
Overrides:
getProgress in class NullProgressListener
Returns:
Percent completed between 0 and 100 inclusive.

getTask

public InternationalString getTask()
Description copied from interface: ProgressListener
Returns the description of the current task being performed, or null if none. It is assumed that if the task is null applications may simply report that the process is "in progress" or "working" as represented in the current locale.

Specified by:
getTask in interface ProgressListener
Overrides:
getTask in class NullProgressListener
Returns:
Description of the task being performed, or null if none.

setTask

public void setTask(InternationalString task)
Description copied from interface: ProgressListener
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:
setTask in interface ProgressListener
Overrides:
setTask in class NullProgressListener
Parameters:
task - Description of the task being performed, or null if none.

isCompleted

public boolean isCompleted()
Is the task we are listening is completed.

Returns:
true if the task is completed, false if it is not.

getExceptions

public Queue<Throwable> getExceptions()
Return a copy of the Queue of exceptions that had happened.

Returns:
a copy of the Queue of exceptions that had happened.

hasExceptions

public boolean hasExceptions()
It tells us if we have exceptions or not.

Returns:
true if there are exceptions, false otherwise.

isStarted

public boolean isStarted()
Is the task we are listening for started.

Returns:
true if the task is started, false if it is not.

getWarnings

public Queue<DefaultProgressListener.Warning> getWarnings()
Retrieves a copy of the warnings occurred.

Returns:
a copy of the warnings occurred.


Copyright © 1996-2014 Geotools. All Rights Reserved.