jklustor-all-api-0.0.7-20140619012755 (ChemAxon)


com.chemaxon.calculations.common
Class ProgressObservers.CancelObserverImpl

Object
  extended by com.chemaxon.calculations.common.ProgressObservers.CancelObserverImpl
All Implemented Interfaces:
CancelObserver
Enclosing class:
ProgressObservers

public static class ProgressObservers.CancelObserverImpl
extends Object
implements CancelObserver

Implementation of CancelObserver.


Field Summary
 
Fields inherited from interface com.chemaxon.calculations.common.CancelObserver
FIRED_PROPERTY_NAME
 
Constructor Summary
ProgressObservers.CancelObserverImpl()
          Constructor for a cancellable observer implementation.
ProgressObservers.CancelObserverImpl(ProgressObservers.PollingCanceller sourceCanceller)
          Constructor with an underlying polling source.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a listener for cancellation.
 void cancel()
          Sign cancelling.
 boolean isCancelled()
          Returns whether cancellation of current operation has been requested.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a listener.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressObservers.CancelObserverImpl

public ProgressObservers.CancelObserverImpl()
Constructor for a cancellable observer implementation.


ProgressObservers.CancelObserverImpl

public ProgressObservers.CancelObserverImpl(ProgressObservers.PollingCanceller sourceCanceller)
Constructor with an underlying polling source.

Parameters:
sourceCanceller - canceller to poll
Method Detail

cancel

public void cancel()
Sign cancelling.

Note that this implementation is not thread safe, so this method must be invoked from the thread created/using this instance.


isCancelled

public boolean isCancelled()
Description copied from interface: CancelObserver
Returns whether cancellation of current operation has been requested.

Long running/memory intensive operations should poll to see if cancelation has been requested. Since time-out based cancelations might be implemented polling should not be done too often.

It is expected that implementations wont return false after a true value returned. It is also expected that implementations tolerate multiple calls regardless of the cancallation state.

Please note that test cases might check for too frequent invocations, so the propagation of any AssertionError thrown by this method should not be obstructed.

It is usually expected that the cancelled task should throw CancellationException and this behavior should be documented in their APIdocs.

Specified by:
isCancelled in interface CancelObserver
Returns:
true if cancellation has been requested, false otherwise.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: CancelObserver
Add a listener for cancellation.

The passed PropertyChangeListener will be called upon cancellation event. The fired PropertyChangeEvent conforms to the following contract:

It is guaranteed that one PropertyChangeEvent is fired at most once per additon count, only when cancellation occurs. In case cancellation occurs before listener addition then event will be fired upon addition.

Invocation count behaves according to the API contract stated in PropertyChangeSupport.addPropertyChangeListener(java.beans.PropertyChangeListener)

Specified by:
addPropertyChangeListener in interface CancelObserver
Parameters:
listener - Callback to invoke upon cancellation.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: CancelObserver
Remove a listener.

This method behaves according to the API contarct stated in PropertyChangeSupport.removePropertyChangeListener(java.beans.PropertyChangeListener)

Specified by:
removePropertyChangeListener in interface CancelObserver
Parameters:
listener - Listener to remove.

jklustor-all-api-0.0.7-20140619012755 (ChemAxon)