org.geotools.filter
Class LiteralExpressionImpl

Object
  extended by ExpressionAbstract
      extended by DefaultExpression
          extended by LiteralExpressionImpl
All Implemented Interfaces:
ExpressionType, LiteralExpression, Expression, Literal
Direct Known Subclasses:
BBoxExpressionImpl

public class LiteralExpressionImpl
extends DefaultExpression
implements LiteralExpression

Defines an expression that holds a literal for return.

Author:
Rob Hranac, Vision for New York
Module:

Field Summary
 
Fields inherited from class DefaultExpression
expressionType, permissiveConstruction
 
Fields inherited from interface ExpressionType
ATTRIBUTE, ATTRIBUTE_DOUBLE, ATTRIBUTE_GEOMETRY, ATTRIBUTE_INTEGER, ATTRIBUTE_STRING, ATTRIBUTE_UNDECLARED, FUNCTION, LITERAL_DOUBLE, LITERAL_GEOMETRY, LITERAL_INTEGER, LITERAL_LONG, LITERAL_STRING, LITERAL_UNDECLARED, MATH_ADD, MATH_DIVIDE, MATH_MULTIPLY, MATH_SUBTRACT
 
Fields inherited from interface Expression
NIL
 
Fields inherited from interface Expression
NIL
 
Constructor Summary
protected LiteralExpressionImpl()
          Constructor with literal.
protected LiteralExpressionImpl(double value)
          Constructor with literal.
protected LiteralExpressionImpl(int value)
          Constructor with literal.
protected LiteralExpressionImpl(long value)
           
protected LiteralExpressionImpl(Object literal)
          Constructor with literal.
protected LiteralExpressionImpl(String value)
          Constructor with literal.
 
Method Summary
 Object accept(ExpressionVisitor visitor, Object extraData)
          Used by FilterVisitors to perform some action on this filter instance.
 boolean equals(Object obj)
          Compares this filter to the specified object.
 Object evaluate(Object feature)
          This method checks if the object is an instance of Feature and if so, calls through to #evaluate(Feature).
 Object evaluate(Object feature, Class context)
          Default implementation delegates handling of context conversion to Value utility class.
 Object evaluate(SimpleFeature feature)
          Gets the value of this literal.
 Object getLiteral()
          Deprecated. use getValue().
 short getType()
          Returns the literal type.
 Object getValue()
          Retrieves the literal of this expression.
 int hashCode()
          Override of hashCode method.
 void setLiteral(Object literal)
          Deprecated. use setValue(Object).
 void setValue(Object literal)
          Sets the literal.
 String toString()
          Return this filter as a string.
 
Methods inherited from class DefaultExpression
accept, getValue, isAttributeExpression, isExpression, isFunctionExpression, isGeometryExpression, isLiteralExpression, isMathExpression, isMathExpression
 
Methods inherited from class ExpressionAbstract
eval, eval
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface LiteralExpression
getValue
 
Methods inherited from interface Expression
accept
 

Constructor Detail

LiteralExpressionImpl

protected LiteralExpressionImpl()
Constructor with literal.


LiteralExpressionImpl

protected 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

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(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 Object getLiteral()
Deprecated. use getValue().

This method calls getValue().

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

getValue

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

Specified by:
getValue in interface Literal
Returns:
the literal held by 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(SimpleFeature feature)
                throws IllegalArgumentException
Gets the value of this literal.

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. The literal held by this expression is almost invariably a java.lang.String (so that no leading-zeros are lost during a string-> Class conversion. This method will attempt to form the internal String into a Integer, Double or BigInteger, before failing and defaulting to a String. To speed things up significantly, use the evaluate(Object, Class) method so that we don't have to guess at what you expect back from this evaluate method!
Throws:
IllegalArgumentException - Feature does not match declared schema.

evaluate

public Object evaluate(Object feature)
Description copied from class: DefaultExpression
This method checks if the object is an instance of Feature and if so, calls through to #evaluate(Feature). This is done to maintain backwards compatability with previous version of Expression api which depended on Feature. If the object is not an instance of feature the super implementation is called.

Specified by:
evaluate in interface Expression
Overrides:
evaluate in class DefaultExpression

evaluate

public Object evaluate(Object feature,
                       Class context)
Description copied from class: ExpressionAbstract
Default implementation delegates handling of context conversion to Value utility class.

Subclasses are expected to make use of the Value utility class (as the easiest way to provide value morphing in confirmance with the Filter specification).

Specified by:
evaluate in interface Expression
Overrides:
evaluate in class ExpressionAbstract

toString

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

Overrides:
toString in class Object
Returns:
String representation of this geometry filter.

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:
equals in class Object
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.

Overrides:
hashCode in class Object
Returns:
the hash code for this literal expression

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:
accept in interface Expression
Overrides:
accept in class ExpressionAbstract
Parameters:
visitor - The visitor which requires access to this filter, the method must call visitor.visit(this);


Copyright © 1996-2009 Geotools. All Rights Reserved.