Package org.geotools.filter
Class LiteralExpressionImpl
- Object
-
- ExpressionAbstract
-
- DefaultExpression
-
- LiteralExpressionImpl
-
- All Implemented Interfaces:
Expression,Literal
public class LiteralExpressionImpl extends DefaultExpression implements Literal
Defines an expression that holds a literal for return.- Author:
- Rob Hranac, Vision for New York
-
-
Field Summary
-
Fields inherited from interface Expression
NIL
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLiteralExpressionImpl()Constructor with literal.protectedLiteralExpressionImpl(double value)Constructor with literal.protectedLiteralExpressionImpl(int value)Constructor with literal.protectedLiteralExpressionImpl(long value)LiteralExpressionImpl(Object literal)Constructor with literal.protectedLiteralExpressionImpl(String value)Constructor with literal.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectaccept(ExpressionVisitor visitor, Object extraData)Used by FilterVisitors to perform some action on this filter instance.booleanequals(Object obj)Compares this filter to the specified object.Objectevaluate(Object feature)Subclass should override, default implementation returns null.<T> Tevaluate(Object feature, Class<T> context)Default implementation delegates handling of context conversion to Converters utility class.ObjectgetValue()Retrieves the literal of this expression.inthashCode()Override of hashCode method.voidsetValue(Object literal)Sets the literal.StringtoString()Return this filter as a string.-
Methods inherited from class DefaultExpression
isAttributeExpression, isExpression, isFunctionExpression, isGeometryExpression, isLiteralExpression, isMathExpression
-
-
-
-
Constructor Detail
-
LiteralExpressionImpl
protected LiteralExpressionImpl()
Constructor with literal.
-
LiteralExpressionImpl
public LiteralExpressionImpl(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(long value)
-
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(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
-
getValue
public Object getValue()
Retrieves the literal of this expression.
-
setValue
public final void setValue(Object literal)
Sets the literal.- Parameters:
literal- The literal to store inside this expression.- Throws:
IllegalFilterException- This literal type is not in scope.
-
evaluate
public Object evaluate(Object feature)
Description copied from class:ExpressionAbstractSubclass should override, default implementation returns null.- Specified by:
evaluatein interfaceExpression- Overrides:
evaluatein classExpressionAbstract- Returns:
- default implementation returns null
-
evaluate
public <T> T evaluate(Object feature, Class<T> context)
Description copied from class:ExpressionAbstractDefault implementation delegates handling of context conversion to Converters utility class.Subclasses are expected to make use of the Converters utility class (as the easiest way to provide value morphing in conformance with the Filter specification).
- Specified by:
evaluatein interfaceExpression- Overrides:
evaluatein classExpressionAbstract- Type Parameters:
T- The type of the returned object.- Parameters:
feature- The object to evaluate the expression against.context- The type of the resulting value of the expression.- Returns:
- Evaluates the given expression based on the content of the given object an an instance of
context.
-
toString
public String toString()
Return this filter as a string.
-
equals
public boolean equals(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.- Overrides:
equalsin classObject- Parameters:
obj- - the object to compare this ExpressionLiteral against.- Returns:
- true if specified object is equal to this expression; false otherwise.
- TODO:
- 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.
-
accept
public Object accept(ExpressionVisitor visitor, 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:
acceptin interfaceExpression- Parameters:
visitor- The visitor which requires access to this filter, the method must call visitor.visit(this);
-
-