/** Produces an indented XML representation of this object. */
 public StringBuffer toXML() {
   StringBuffer sb = new StringBuffer(500);
   sb.append("<ogc:").append(getOperatorName()).append(">");
   sb.append(expr1.toXML());
   sb.append(expr2.toXML());
   sb.append("</ogc:").append(getOperatorName()).append(">");
   return sb;
 }
  /**
   * Calculates the <tt>ComparisonOperation</tt>'s logical value based on the certain property
   * values of the given <tt>Feature</tt>. TODO: Improve datatype handling.
   *
   * @param feature that determines the property values
   * @return true, if the <tt>FeatureFilter</tt> evaluates to true, else false
   * @throws FilterEvaluationException if the expressions to be compared are of different types
   */
  public boolean evaluate(Feature feature) throws FilterEvaluationException {

    Object value1 = expr1.evaluate(feature);
    Object value2 = expr2.evaluate(feature);

    // compare Strings
    if (value1 instanceof String && value2 instanceof String) {
      switch (getOperatorId()) {
        case OperationDefines.PROPERTYISEQUALTO:
          {
            if (value1 == null || value2 == null) return false;
            return value1.equals(value2);
          }
        case OperationDefines.PROPERTYISLESSTHAN:
        case OperationDefines.PROPERTYISGREATERTHAN:
        case OperationDefines.PROPERTYISLESSTHANOREQUALTO:
        case OperationDefines.PROPERTYISGREATERTHANOREQUALTO:
          {
            throw new FilterEvaluationException(
                "'" + getOperatorName() + "' can not be applied to " + "String values!");
          }
        default:
          {
            throw new FilterEvaluationException(
                "Unknown comparison operation: '" + getOperatorName() + "'!");
          }
      }
    }
    // compare Doubles
    else if ((value1 instanceof Number) && (value2 instanceof Number)) {

      double d1 = Double.parseDouble(value1.toString());
      double d2 = Double.parseDouble(value2.toString());
      switch (getOperatorId()) {
        case OperationDefines.PROPERTYISEQUALTO:
          return d1 == d2;
        case OperationDefines.PROPERTYISLESSTHAN:
          return d1 < d2;
        case OperationDefines.PROPERTYISGREATERTHAN:
          return d1 > d2;
        case OperationDefines.PROPERTYISLESSTHANOREQUALTO:
          return d1 <= d2;
        case OperationDefines.PROPERTYISGREATERTHANOREQUALTO:
          return d1 >= d2;
        default:
          {
            throw new FilterEvaluationException(
                "Unknown comparison operation: '" + getOperatorName() + "'!");
          }
      }
    } else {
      //            throw new FilterEvaluationException (
      //                "Can not apply operation '" + getOperatorName () + "' to "
      //              + "different datatypes!");
      return false;
    }
  }