Class NullFilterVisitor

Object
NullFilterVisitor
All Implemented Interfaces:
ExpressionVisitor, FilterVisitor
Direct Known Subclasses:
ExtractBoundsFilterVisitor, TimeRangeVisitor

public abstract class NullFilterVisitor extends Object implements FilterVisitor, ExpressionVisitor
Abstract implementation of FilterVisitor simple returns the provided data.

This class can be used as is as a placeholder that does nothing:


 Integer one = (Integer) filter.accepts( NullFilterVisitor.NULL_VISITOR, 1 );
 
The class can also be used as an alternative to DefaultFilterVisitor if you want to only walk part of the data structure:

 FilterVisitor allFids = new NullFilterVisitor(){
     public Object visit( Id filter, Object data ) {
         if( data == null) return null;
         Set set = (Set) data;
         set.addAll(filter.getIDs());
         return set;
     }
 };
 Set set = (Set) myFilter.accept(allFids, new HashSet());
 Set set2 = (Set) myFilter.accept(allFids, null ); // set2 will be null
 
The base class provides implementations for:
  • walking And, Or, and Not data structures, returning null at any point will exit early
  • a default implementation for every other construct that will return the provided data
Author:
Jody Garnett (Refractions Research)