org.geotools.filter
Class MathExpressionImpl

java.lang.Object
  extended byorg.geotools.filter.DefaultExpression
      extended byorg.geotools.filter.MathExpressionImpl
All Implemented Interfaces:
Expression, ExpressionType, MathExpression

public 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,v 1.7 2003/07/23 18:13:32 cholmesny Exp $
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.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(short expType)
          Constructor with expression type.
 
Method Summary
 void accept(FilterVisitor visitor)
          Used by FilterVisitors to perform some action on this filter instance.
 void addLeftValue(Expression leftValue)
          Adds the 'left' value to this expression.
 void addRightValue(Expression rightValue)
          Adds the 'right' value to this expression.
 boolean equals(java.lang.Object obj)
          Compares this expression to the specified object.
 Expression getLeftValue()
          Gets the left expression.
 Expression getRightValue()
          Gets the right expression.
 short getType()
          Gets the type of this expression.
 java.lang.Object getValue(Feature feature)
          Returns the value for this expression.
 int hashCode()
          Override of hashCode method.
 java.lang.String toString()
          Returns a string representation of this expression
 
Methods inherited from class org.geotools.filter.DefaultExpression
isAttributeExpression, isExpression, isFunctionExpression, isGeometryExpression, isLiteralExpression, isMathExpression
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MathExpressionImpl

protected MathExpressionImpl()
No argument constructor.


MathExpressionImpl

protected MathExpressionImpl(short expType)
                      throws IllegalFilterException
Constructor with expression type.

Parameters:
expType - The mathematical relationship between values.
Throws:
IllegalFilterException - Attempting to declare illegal type.
Method Detail

addLeftValue

public void addLeftValue(Expression leftValue)
                  throws IllegalFilterException
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 void addRightValue(Expression rightValue)
                   throws IllegalFilterException
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 Expression getLeftValue()
Gets the left expression.

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

getRightValue

public Expression getRightValue()
Gets the right expression.

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

getType

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

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

getValue

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

Specified by:
getValue in interface MathExpression
Overrides:
getValue 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.

toString

public java.lang.String toString()
Returns a string representation of this expression

Returns:
String representation of the math expression.

equals

public boolean equals(java.lang.Object obj)
Compares this expression to the specified object. Returns true if the passed in object is the same as this expression. Checks to make sure the expression types as well as the left and right values are equal.

Parameters:
obj - - the object to compare this ExpressionLiteral against.
Returns:
true if specified object is equal to this expression; false otherwise.

hashCode

public int hashCode()
Override of hashCode method.

Returns:
a hash code value for this math expression.

accept

public void accept(FilterVisitor visitor)
Used by FilterVisitors to perform some action on this filter instance. Typicaly used by Filter decoders, but may also be used by any thing which needs infomration from filter structure. Implementations should always call: visitor.visit(this); It is importatant that this is not left to a parent class unless the parents API is identical.

Specified by:
accept in interface Expression
Parameters:
visitor - The visitor which requires access to this filter, the method must call visitor.visit(this);


Copyright © GeoTools. All Rights Reserved.