org.geotools.filter
Class LiteralExpressionImpl

java.lang.Object
  extended byorg.geotools.filter.DefaultExpression
      extended byorg.geotools.filter.LiteralExpressionImpl
All Implemented Interfaces:
Expression, ExpressionType, 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,v 1.10 2003/07/23 19:56:07 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 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
 void accept(FilterVisitor visitor)
          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 getLiteral()
          Retrieves the literal of this expression.
 short getType()
          Returns the literal type.
 java.lang.Object getValue(Feature feature)
          Gets the value of this literal.
 int hashCode()
          Override of hashCode method.
 void setLiteral(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
isAttributeExpression, isExpression, isFunctionExpression, isGeometryExpression, isLiteralExpression, isMathExpression
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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
Sets the literal.

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 java.lang.Object getLiteral()
Retrieves the literal of this expression.

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

getValue

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

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