org.geotools.filter
Class ConstantExpression

java.lang.Object
  extended by org.geotools.filter.ConstantExpression
All Implemented Interfaces:
java.lang.Cloneable, ExpressionType, LiteralExpression, org.opengis.filter.expression.Expression, org.opengis.filter.expression.Literal
Direct Known Subclasses:
OverlapBehavior

public class ConstantExpression
extends java.lang.Object
implements LiteralExpression, java.lang.Cloneable

The Expression class is not immutable!

However we do have a need for immutable literal expressions when defining our API for SLD, and any other standards based on Expression.

Author:
Jody Garnett, Refractions Research

Field Summary
static ConstantExpression BLACK
           
static ConstantExpression NULL
           
static ConstantExpression ONE
           
static ConstantExpression TWO
           
static ConstantExpression UNNAMED
           
static ConstantExpression ZERO
           
 
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_LONG, LITERAL_STRING, LITERAL_UNDECLARED, MATH_ADD, MATH_DIVIDE, MATH_MULTIPLY, MATH_SUBTRACT
 
Fields inherited from interface org.opengis.filter.expression.Expression
NIL
 
Constructor Summary
protected ConstantExpression(java.lang.Object value)
           
protected ConstantExpression(short type, java.lang.Object value)
           
 
Method Summary
 java.lang.Object accept(org.opengis.filter.expression.ExpressionVisitor visitor, java.lang.Object extraData)
           
 void accept(FilterVisitor visitor)
          Deprecated. use accept(ExpressionVisitor, Object).
protected  java.lang.Object clone()
           
static ConstantExpression color(java.awt.Color color)
          Encode provided color as a String
static ConstantExpression constant(double number)
           
static ConstantExpression constant(int number)
           
static ConstantExpression constant(java.lang.Object value)
           
 boolean equals(java.lang.Object obj)
           
 java.lang.Object evaluate(java.lang.Object object)
           
<T> T
evaluate(java.lang.Object object, java.lang.Class<T> context)
           
 java.lang.Object evaluate(org.opengis.feature.simple.SimpleFeature feature)
          Evaluates the expression against an instance of Feature.
 java.lang.Object getLiteral()
          Deprecated. use getValue()
 short getType()
          Returns the literal type.
 java.lang.Object getValue()
           
 java.lang.Object getValue(org.opengis.feature.simple.SimpleFeature feature)
          Deprecated. use #evaluate(Feature)
 int hashCode()
           
 void setLiteral(java.lang.Object literal)
          Deprecated. use setValue(Object)
 void setValue(java.lang.Object constant)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final ConstantExpression NULL

BLACK

public static final ConstantExpression BLACK

ZERO

public static final ConstantExpression ZERO

ONE

public static final ConstantExpression ONE

TWO

public static final ConstantExpression TWO

UNNAMED

public static final ConstantExpression UNNAMED
Constructor Detail

ConstantExpression

protected ConstantExpression(java.lang.Object value)

ConstantExpression

protected ConstantExpression(short type,
                             java.lang.Object value)
Method Detail

setLiteral

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

Description copied from interface: LiteralExpression
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.

getValue

public final java.lang.Object getValue(org.opengis.feature.simple.SimpleFeature feature)
Deprecated. use #evaluate(Feature)

Description copied from interface: LiteralExpression
Gets the value of this literal.

Specified by:
getValue in interface LiteralExpression
Parameters:
feature - Required by the interface but not used.
Returns:
the literal held by this expression. Ignores the passed in feature.

evaluate

public java.lang.Object evaluate(org.opengis.feature.simple.SimpleFeature feature)
Description copied from interface: Expression
Evaluates the expression against an instance of Feature.

Parameters:
feature - The feature being evaluated.
Returns:
The result.

evaluate

public java.lang.Object evaluate(java.lang.Object object)
Specified by:
evaluate in interface org.opengis.filter.expression.Expression

evaluate

public <T> T evaluate(java.lang.Object object,
                      java.lang.Class<T> context)
Specified by:
evaluate in interface org.opengis.filter.expression.Expression

getValue

public java.lang.Object getValue()
Specified by:
getValue in interface org.opengis.filter.expression.Literal

setValue

public void setValue(java.lang.Object constant)

getType

public short getType()
Description copied from interface: LiteralExpression
Returns the literal type.

Specified by:
getType in interface LiteralExpression
Returns:
the short representation of the literal expression type.

getLiteral

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

Description copied from interface: LiteralExpression
Retrieves the literal of this expression.

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

accept

public void accept(FilterVisitor visitor)
Deprecated. use accept(ExpressionVisitor, Object).

Description copied from interface: Expression
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.

Parameters:
visitor - The visitor which requires access to this filter, the method must call visitor.visit(this);

accept

public java.lang.Object accept(org.opengis.filter.expression.ExpressionVisitor visitor,
                               java.lang.Object extraData)
Specified by:
accept in interface org.opengis.filter.expression.Expression

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

color

public static ConstantExpression color(java.awt.Color color)
Encode provided color as a String


constant

public static ConstantExpression constant(double number)

constant

public static ConstantExpression constant(int number)

constant

public static ConstantExpression constant(java.lang.Object value)


Copyright © 1996-2010 Geotools. All Rights Reserved.