org.geotools.filter
Class MathExpressionImpl

java.lang.Object
  extended byorg.geotools.filter.expression.ExpressionAbstract
      extended byorg.geotools.filter.DefaultExpression
          extended byorg.geotools.filter.MathExpressionImpl
All Implemented Interfaces:
org.opengis.filter.expression.BinaryExpression, org.opengis.filter.expression.Expression, Expression, ExpressionType, MathExpression
Direct Known Subclasses:
AddImpl, DivideImpl, MultiplyImpl, SubtractImpl

public abstract class MathExpressionImpl
extends DefaultExpression
implements MathExpression

Holds a mathematical relationship between two expressions. Note that the sub expressions must be math expressions. In other words, they must be a math literal, another math expression, or a feature attribute with a declared math type. You may create math expressions of arbitrary complexity by nesting other math expressions as sub expressions in one or more math expressions. This filter defines left and right values to clarify the sub expression precedence for non-associative operations, such as subtraction and division. For example, the left value is the numerator and the right is the denominator in an ExpressionMath division operation.

Version:
$Id: MathExpressionImpl.java 18021 2006-02-14 20:36:18Z jdeolive $
Author:
Rob Hranac, Vision for New York

Field Summary
 
Fields inherited from class org.geotools.filter.DefaultExpression
expressionType, permissiveConstruction
 
Fields inherited from interface org.geotools.filter.expression.ExpressionType
ATTRIBUTE, ATTRIBUTE_DOUBLE, ATTRIBUTE_GEOMETRY, ATTRIBUTE_INTEGER, ATTRIBUTE_STRING, ATTRIBUTE_UNDECLARED, FUNCTION, LITERAL_DOUBLE, LITERAL_GEOMETRY, LITERAL_INTEGER, LITERAL_STRING, MATH_ADD, MATH_DIVIDE, MATH_MULTIPLY, MATH_SUBTRACT
 
Constructor Summary
protected MathExpressionImpl()
          No argument constructor.
protected MathExpressionImpl(org.opengis.filter.expression.Expression e1, org.opengis.filter.expression.Expression e2)
           
 
Method Summary
 void addLeftValue(Expression leftValue)
          Deprecated. use setExpression1(org.opengis.filter.expression.Expression)
 void addRightValue(Expression rightValue)
          Deprecated. use setExpression2(org.opengis.filter.expression.Expression)
protected  void ensureOperandsSet()
          Convenience method which ensures that both expressions have been set.
abstract  java.lang.Object evaluate(Feature feature)
          Returns the value for this expression.
 org.opengis.filter.expression.Expression getExpression1()
          Gets the left or first expression.
 org.opengis.filter.expression.Expression getExpression2()
          Gets the second expression.
 Expression getLeftValue()
          Deprecated. use getExpression1().
 Expression getRightValue()
          Deprecated. use getExpression2().
 short getType()
          Gets the type of this expression.
protected  java.lang.Object number(double number)
           
 void setExpression1(org.opengis.filter.expression.Expression expression)
          Gets the left or first expression.
 void setExpression2(org.opengis.filter.expression.Expression expression)
          Gets the second expression.
 
Methods inherited from class org.geotools.filter.DefaultExpression
accept, evaluate, getValue, isAttributeExpression, isExpression, isGeometryExpression, isLiteralExpression, isMathExpression, isMathExpression
 
Methods inherited from class org.geotools.filter.expression.ExpressionAbstract
accept, eval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.filter.expression.MathExpression
getValue
 
Methods inherited from interface org.geotools.filter.expression.Expression
accept
 
Methods inherited from interface org.opengis.filter.expression.Expression
accept, evaluate
 

Constructor Detail

MathExpressionImpl

protected MathExpressionImpl()
No argument constructor.


MathExpressionImpl

protected MathExpressionImpl(org.opengis.filter.expression.Expression e1,
                             org.opengis.filter.expression.Expression e2)
Method Detail

addLeftValue

public final void addLeftValue(Expression leftValue)
                        throws IllegalFilterException
Deprecated. use setExpression1(org.opengis.filter.expression.Expression)

Adds the 'left' value to this expression.

Specified by:
addLeftValue in interface MathExpression
Parameters:
leftValue - Expression to add to this expression.
Throws:
IllegalFilterException - Attempting to add non-math expression.

addRightValue

public final void addRightValue(Expression rightValue)
                         throws IllegalFilterException
Deprecated. use setExpression2(org.opengis.filter.expression.Expression)

Adds the 'right' value to this expression.

Specified by:
addRightValue in interface MathExpression
Parameters:
rightValue - Expression to add to this expression.
Throws:
IllegalFilterException - Attempting to add non-math expression.

getLeftValue

public final Expression getLeftValue()
Deprecated. use getExpression1().

Gets the left or first expression.

Specified by:
getLeftValue in interface MathExpression
Returns:
the expression on the left of the comparison.

getExpression1

public org.opengis.filter.expression.Expression getExpression1()
Gets the left or first expression.

Specified by:
getExpression1 in interface org.opengis.filter.expression.BinaryExpression
Returns:
the expression on the first side of the comparison.

setExpression1

public void setExpression1(org.opengis.filter.expression.Expression expression)
Gets the left or first expression.

Specified by:
setExpression1 in interface org.opengis.filter.expression.BinaryExpression
Returns:
the expression on the first side of the comparison.
Throws:
IllegalFilterException

getRightValue

public final Expression getRightValue()
Deprecated. use getExpression2().

Gets the right expression.

Specified by:
getRightValue in interface MathExpression
Returns:
the expression on the right of the comparison.

getExpression2

public org.opengis.filter.expression.Expression getExpression2()
Gets the second expression.

Specified by:
getExpression2 in interface org.opengis.filter.expression.BinaryExpression
Returns:
the expression on the second side of the comparison.

setExpression2

public void setExpression2(org.opengis.filter.expression.Expression expression)
Gets the second expression.

Specified by:
setExpression2 in interface org.opengis.filter.expression.BinaryExpression
Returns:
the expression on the second side of the comparison.
Throws:
IllegalFilterException

getType

public short getType()
Gets the type of this expression.

Specified by:
getType in interface MathExpression
Overrides:
getType in class DefaultExpression
Returns:
Expression type.

evaluate

public abstract java.lang.Object evaluate(Feature feature)
                                   throws java.lang.IllegalArgumentException
Returns the value for this expression.

Specified by:
evaluate in interface Expression
Overrides:
evaluate in class DefaultExpression
Parameters:
feature - Feature to use when return sub expression values.
Returns:
Value of this expression.
Throws:
java.lang.IllegalArgumentException - Feature does not match declared schema.

ensureOperandsSet

protected void ensureOperandsSet()
                          throws java.lang.IllegalArgumentException
Convenience method which ensures that both expressions have been set. If any of operands not set an exception is thrown.

Throws:
java.lang.IllegalArgumentException

number

protected java.lang.Object number(double number)


Copyright © GeoTools. All Rights Reserved.