org.geotools.gui.headless
Class ProgressMailer

java.lang.Object
  extended byorg.geotools.gui.headless.ProgressMailer
All Implemented Interfaces:
ProgressListener

public class ProgressMailer
extends java.lang.Object
implements ProgressListener

Reports progress by sending email to the specified address at regular interval.

Since:
2.0
Version:
$Id: ProgressMailer.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Constructor Summary
ProgressMailer(javax.mail.Session session, javax.mail.Address[] address)
          Creates an objects reporting progress to the specified email adresses.
ProgressMailer(java.lang.String host, java.lang.String address)
          Creates an objects reporting progress to the specified email address.
 
Method Summary
 void complete()
          Send an emails saying that the operation finished.
 void dispose()
          Releases any resource used by this object.
 void exceptionOccurred(java.lang.Throwable exception)
          Send an exception stack trace by email.
 java.lang.String getDescription()
          Returns the description for the lengthly operation to be reported, or if none.
 long getTimeInterval()
          Returns the time laps (in milliseconds) between two emails.
 boolean isCanceled()
          Is this job canceled?
 void progress(float percent)
          Notifies progress.
 void setCanceled(boolean canceled)
          Indicate that progress should is canceled.
 void setDescription(java.lang.String description)
          Set the description for the lenghtly operation to be reported. 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.
 void setTimeInterval(long interval)
          Set the time laps (in milliseconds) between two emails.
 void started()
          Send an emails saying that the operation started.
 void warningOccurred(java.lang.String source, java.lang.String margin, java.lang.String warning)
          Send a warning by email.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressMailer

public ProgressMailer(java.lang.String host,
                      java.lang.String address)
               throws javax.mail.internet.AddressException
Creates an objects reporting progress to the specified email address.

Parameters:
host - The server to use for sending emails.
address - Email adress where to send progress reports.
Throws:
javax.mail.internet.AddressException - if the specified address use an invalid syntax.

ProgressMailer

public ProgressMailer(javax.mail.Session session,
                      javax.mail.Address[] address)
Creates an objects reporting progress to the specified email adresses.

Parameters:
session - Session to use for sending emails.
address -
Method Detail

getTimeInterval

public long getTimeInterval()
Returns the time laps (in milliseconds) between two emails.


setTimeInterval

public void setTimeInterval(long interval)
Set the time laps (in milliseconds) between two emails. The default value is 3 hours.


getDescription

public java.lang.String getDescription()
Returns the description for the lengthly operation to be reported, or if none.

Specified by:
getDescription in interface ProgressListener

setDescription

public void setDescription(java.lang.String description)
Set the description for the lenghtly operation to be reported. 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:
setDescription in interface ProgressListener
Parameters:
description - The new description, or if none.

started

public void started()
Send an emails saying that the operation started.

Specified by:
started in interface ProgressListener

progress

public void progress(float percent)
Notifies progress. This method will send an email only if at least the amount of time specified by setTimeInterval(long) is ellapsed since the last email.

Specified by:
progress in interface ProgressListener

complete

public void complete()
Send an emails saying that the operation finished.

Specified by:
complete in interface ProgressListener

dispose

public void dispose()
Releases any resource used by this object.

Specified by:
dispose in interface ProgressListener

isCanceled

public boolean isCanceled()
Is this job canceled?

Specified by:
isCanceled in interface ProgressListener

setCanceled

public void setCanceled(boolean canceled)
Indicate that progress should is canceled.

Specified by:
setCanceled in interface ProgressListener

warningOccurred

public void warningOccurred(java.lang.String source,
                            java.lang.String margin,
                            java.lang.String warning)
Send a warning by email.

Specified by:
warningOccurred in interface ProgressListener
Parameters:
source - The source of the warning, or 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 if none. This is typically the line number where the error occured in the file.
warning - The warning message.

exceptionOccurred

public void exceptionOccurred(java.lang.Throwable exception)
Send an exception stack trace by email.

Specified by:
exceptionOccurred in interface ProgressListener


Copyright © GeoTools. All Rights Reserved.