BetweenComparisonOperator.java

  1. package de.turnertech.ows.filter;

  2. import de.turnertech.ows.gml.IFeature;

  3. public class BetweenComparisonOperator implements ComparisonOperator {

  4.     private final Expression lowerBoundary;

  5.     private final Expression expression;

  6.     private final Expression upperBoundary;

  7.     public BetweenComparisonOperator(final Expression lowerBoundary, final Expression expression, final Expression upperBoundary) {
  8.         this.lowerBoundary = lowerBoundary;
  9.         this.expression = expression;
  10.         this.upperBoundary = upperBoundary;
  11.     }

  12.     /**
  13.      * @return the expression
  14.      */
  15.     public Expression getExpression() {
  16.         return expression;
  17.     }

  18.     /**
  19.      * @return the lowerBoundary
  20.      */
  21.     public Expression getLowerBoundary() {
  22.         return lowerBoundary;
  23.     }

  24.     /**
  25.      * @return the upperBoundary
  26.      */
  27.     public Expression getUpperBoundary() {
  28.         return upperBoundary;
  29.     }

  30.     @Override
  31.     public boolean test(IFeature feature) {
  32.         final Object testValue = expression.apply(feature);
  33.         return BinaryComparisonName.PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO.test(testValue, lowerBoundary.apply(feature)) &&
  34.                 BinaryComparisonName.PROPERTY_IS_LESS_THAN_OR_EQUAL_TO.test(testValue, upperBoundary.apply(feature));
  35.     }
  36.    
  37. }