org.geotools.filter
Class LiteralExpressionImpl

java.lang.Object
  extended byorg.geotools.filter.expression.ExpressionAbstract
      extended byorg.geotools.filter.DefaultExpression
          extended byorg.geotools.filter.LiteralExpressionImpl
All Implemented Interfaces:
org.opengis.filter.expression.Expression, Expression, ExpressionType, org.opengis.filter.expression.Literal, LiteralExpression
Direct Known Subclasses:
BBoxExpressionImpl

public class LiteralExpressionImpl
extends DefaultExpression
implements LiteralExpression

Defines an expression that holds a literal for return.

Version:
$Id: LiteralExpressionImpl.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 LiteralExpressionImpl()
          Constructor with literal.
protected LiteralExpressionImpl(double value)
          Constructor with literal.
protected LiteralExpressionImpl(int value)
          Constructor with literal.
protected LiteralExpressionImpl(java.lang.Object literal)
          Constructor with literal.
protected LiteralExpressionImpl(java.lang.String value)
          Constructor with literal.
 
Method Summary
 java.lang.Object accept(org.opengis.filter.expression.ExpressionVisitor visitor, java.lang.Object extraData)
          Used by FilterVisitors to perform some action on this filter instance.
 boolean equals(java.lang.Object obj)
          Compares this filter to the specified object.
 java.lang.Object evaluate(Feature feature)
          Gets the value of this literal.
 java.lang.Object getLiteral()
          Deprecated. use getValue().
 short getType()
          Returns the literal type.
 java.lang.Object getValue()
          Retrieves the literal of this expression.
 int hashCode()
          Override of hashCode method.
 void setLiteral(java.lang.Object literal)
          Deprecated. use setValue(Object).
 void setValue(java.lang.Object literal)
          Sets the literal.
 java.lang.String toString()
          Return this filter as a string.
 
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
eval
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.geotools.filter.expression.LiteralExpression
getValue
 
Methods inherited from interface org.geotools.filter.expression.Expression
accept
 
Methods inherited from interface org.opengis.filter.expression.Expression
evaluate
 

Constructor Detail

LiteralExpressionImpl

protected LiteralExpressionImpl()
Constructor with literal.


LiteralExpressionImpl

protected LiteralExpressionImpl(java.lang.Object literal)
                         throws IllegalFilterException
Constructor with literal.

Parameters:
literal - The literal to store inside this expression.
Throws:
IllegalFilterException - This literal type is not in scope.

LiteralExpressionImpl

protected LiteralExpressionImpl(int value)
Constructor with literal. This alternative constructor is a convinience one for integers an Integer object will be constructed, and no IllegalFilterException can ever be thrown.

Parameters:
value - The integer to store inside this expression.

LiteralExpressionImpl

protected LiteralExpressionImpl(double value)
Constructor with literal. This alternative constructor is a convinience one for doubles an Double object will be constructed, and no IllegalFilterException can ever be thrown.

Parameters:
value - The double to store inside this expression.

LiteralExpressionImpl

protected LiteralExpressionImpl(java.lang.String value)
Constructor with literal. This alternative constructor is a convinience one for doubles an Double object will be constructed, and no IllegalFilterException can ever be thrown.

Parameters:
value - The double to store inside this expression.
Method Detail

getType

public short getType()
Returns the literal type.

Specified by:
getType in interface LiteralExpression
Overrides:
getType in class DefaultExpression
Returns:
the short representation of the expression type.

setLiteral

public final void setLiteral(java.lang.Object literal)
                      throws IllegalFilterException
Deprecated. use setValue(Object).

This method calls setValue(Object).

Specified by:
setLiteral in interface LiteralExpression
Parameters:
literal - The literal to store inside this expression.
Throws:
IllegalFilterException - This literal type is not in scope.

getLiteral

public final java.lang.Object getLiteral()
Deprecated. use getValue().

This method calls getValue().

Specified by:
getLiteral in interface LiteralExpression
Returns:
the literal held by this expression.

getValue

public java.lang.Object getValue()
Retrieves the literal of this expression.

Specified by:
getValue in interface org.opengis.filter.expression.Literal
Returns:
the literal held by this expression.

setValue

public final void setValue(java.lang.Object literal)
Sets the literal.

Specified by:
setValue in interface org.opengis.filter.expression.Literal
Parameters:
literal - The literal to store inside this expression.
Throws:
IllegalFilterException - This literal type is not in scope.

evaluate

public java.lang.Object evaluate(Feature feature)
                          throws java.lang.IllegalArgumentException
Gets the value of this literal.

Specified by:
evaluate in interface Expression
Overrides:
evaluate in class DefaultExpression
Parameters:
feature - Required by the interface but not used.
Returns:
the literal held by this expression. Ignores the passed in feature.
Throws:
java.lang.IllegalArgumentException - Feature does not match declared schema.

toString

public java.lang.String toString()
Return this filter as a string.

Returns:
String representation of this geometry filter.

equals

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

Parameters:
obj - - the object to compare this ExpressionLiteral against.
Returns:
true if specified object is equal to this expression; false otherwise.
Task:
REVISIT: missmatched types now considered not equal. This may be a problem when comparing Doubles and Integers

hashCode

public int hashCode()
Override of hashCode method.

Returns:
the hash code for this literal expression

accept

public java.lang.Object accept(org.opengis.filter.expression.ExpressionVisitor visitor,
                               java.lang.Object extraData)
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 org.opengis.filter.expression.Expression
Overrides:
accept in class ExpressionAbstract
Parameters:
visitor - The visitor which requires access to this filter, the method must call visitor.visit(this);


Copyright © GeoTools. All Rights Reserved.