net.refractions.udig.ui.operations
Interface OpFilter

All Known Implementing Classes:
AbstractOpFilter, AdaptsToFilter, And, LazyOpFilter, Not, Or

public interface OpFilter

Represents the filter element in the operation extension point.

Since:
1.1.0
Author:
jones

Field Summary
static OpFilter FALSE
           
static OpFilter TRUE
           
 
Method Summary
 boolean accept(java.lang.Object object)
          Returns true if the object is accepted by the filter
 void addListener(IOpFilterListener listener)
          Adds a listener to listen for events indicating the value has changed.
 boolean canCacheResult()
          Returns true if the results can be cached.
 boolean isBlocking()
          Returns true if processing this filter may block when accept(Object) is called or takes a large amount of time to execute.
 void removeListener(IOpFilterListener listener)
          Removes a listeners
 

Field Detail

TRUE

static final OpFilter TRUE

FALSE

static final OpFilter FALSE
Method Detail

accept

boolean accept(java.lang.Object object)
Returns true if the object is accepted by the filter

Parameters:
object - object to test
Returns:
true if the object is accepted by the filter

canCacheResult

boolean canCacheResult()
Returns true if the results can be cached.

A result can be cached if

  1. The value will never change
  2. It is possible for the filter to listen for changes and update listeners added via the addListener(IOpFilterListener) method

Therefore this method only returns false if it must be calculated each time because there is no way to listen for state changes. If it is non-blocking that is fine, if it is blocking then try to do this rarely.

WARNING: If this returns true then the listeners must be notified for the new value to be recognized

Returns:
true if the results can be cached.

isBlocking

boolean isBlocking()
Returns true if processing this filter may block when accept(Object) is called or takes a large amount of time to execute.

Returns:
true if processing this filter may block when accept(Object) is called.

addListener

void addListener(IOpFilterListener listener)
Adds a listener to listen for events indicating the value has changed. Listeners should only be added if canCacheResult() returns true.

Parameters:
listener - listener to add

removeListener

void removeListener(IOpFilterListener listener)
Removes a listeners

Parameters:
listener - listener to remove