|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.expr.Exprs
Filter/Expression construction kit - this class starts off chains.
I can't take Filter anymore, the turning point was the fact that I needed a FeatureType to make a AttributeExpression. Simply *no*, I cannot expect customer code to have to jump through hoops so that my impmentation is easier. Late binding is required.
The answer - while not completely forcing DataStores away from Expression/Filter is to make a class that captures all the same information and can do the late binding.
On the way there we are not going to have the difference between Filter/Expression. Expr can make an Expression, and Expr can make a Filter.
Example Expr:
Exprs.bbox( extent ).and( Exprs.attribute("cost").lt( 50 ) )
Example Filter:
Expression extentExpression = factory.createBBoxExpression( bbox );
Expression geomExpression = factory.createAttributeExpression( featureType, featureType.getDefaultGeometry().getName() );
GeometryFilter disjointExpression = factory.createGeometryFilter( GeometryFilter.GEOMETRY_DISJOINT );
disjointExpression.addLeftGeometry( geomExpression );
disjointExpression.addRightGeometry( extentExpression );
Filter bboxFilter = disjointExpression.not();
AttributeExpression costExpression = factory.createAttributeExpression( featureType, "cost" );
CompareFilter lessThanFilter = factory.createCompareFilter( CompareFilter.COMPARE_LESS_THAN );
lessThanFilter.addLeftValue( costExpression );
lessThanFilter.addRightValue( factory.createLiteralExpression( 50 ) );
LogicFilter filter = factory.createLogicFilter( bboxFilter, lessThanFilter, LogicFilter.LOGIC_AND);
BTW: just so we can have everything make sense
Exprs.bbox( extent ).fids( fidSet) ==
Exprs.bbox( extent ).and( Exprs.fids( fidSet ) )
- There are convience methods that make sense -
Exprs.bbox( extent ) == geom().disjoint( Expr.literal( extent)).not()
- "Or" you have to do by hand -
Exprs.fid( "road.1234" ).or( Exprs.fid("road.4321) )
Wild idea time: chaining parameters
Expr.fid( "road.1234" ).param( "road.4321" )
repository.view("road").as("name", "CUSTOMER_NAME").as( "addresss", "ADDRESS" )
Still does not look right - sigh.
- Author:
- Jody Garnett
Field Summary
protected static FilterFactory
factory
Constructor Summary
Exprs()
Method Summary
static MathExpr
add(MathExpr[] expr)
static Expr
and(Expr[] expr)
static Expr
attribute(java.lang.String attribute)
Attribute access.
static MathExpr
divide(MathExpr[] expr)
static Expr
fid(java.util.Set fids)
static Expr
fid(java.lang.String featureID)
Convience method for accessing a single fid
static Expr
fn(java.lang.String name,
Expr expr)
static Expr
fn(java.lang.String name,
Expr[] expr)
static Expr
fn(java.lang.String name,
Expr expr1,
Expr expr2)
static GeometryExpr
geom()
Default Geometry access.
static GeometryExpr
geom(java.lang.String attribute)
Geometry attribute access.
static Expr
literal(boolean b)
static MathExpr
literal(double number)
static GeometryExpr
literal(com.vividsolutions.jts.geom.Envelope extent)
Literal Geometry access.
static GeometryExpr
literal(com.vividsolutions.jts.geom.Geometry geom)
Literal Geometry access.
static MathExpr
literal(int number)
static MathExpr
literal(java.lang.Number number)
static Expr
literal(java.lang.Object literal)
static MathExpr
math(java.lang.String attribute)
static Expr
meta(java.lang.String xpath)
Metadata element access.
static Expr
multiply(MathExpr[] expr)
static Expr
or(Expr[] expr)
static MathExpr
subtract(MathExpr[] expr)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
factory
protected static FilterFactory factory
Constructor Detail
Exprs
public Exprs()
Method Detail
fid
public static Expr fid(java.lang.String featureID)
- Convience method for accessing a single fid
- Returns:
fid
public static Expr fid(java.util.Set fids)
and
public static Expr and(Expr[] expr)
or
public static Expr or(Expr[] expr)
literal
public static Expr literal(boolean b)
literal
public static MathExpr literal(int number)
literal
public static MathExpr literal(double number)
literal
public static MathExpr literal(java.lang.Number number)
literal
public static Expr literal(java.lang.Object literal)
literal
public static GeometryExpr literal(com.vividsolutions.jts.geom.Envelope extent)
- Literal Geometry access.
literal
public static GeometryExpr literal(com.vividsolutions.jts.geom.Geometry geom)
- Literal Geometry access.
add
public static MathExpr add(MathExpr[] expr)
subtract
public static MathExpr subtract(MathExpr[] expr)
divide
public static MathExpr divide(MathExpr[] expr)
multiply
public static Expr multiply(MathExpr[] expr)
attribute
public static Expr attribute(java.lang.String attribute)
- Attribute access.
Allows access to chained opperations.
- Parameters:
attribute
- xpath expression to attribute
- Returns:
- Expr
meta
public static Expr meta(java.lang.String xpath)
- Metadata element access.
Allows access to chained opperations.
- Returns:
- Expr
geom
public static GeometryExpr geom()
- Default Geometry access.
geom
public static GeometryExpr geom(java.lang.String attribute)
- Geometry attribute access.
Allows access to chained spatial opperations.
- Parameters:
attribute
- xpath expression to attribute
- Returns:
- GeometryAttribtue
math
public static MathExpr math(java.lang.String attribute)
fn
public static Expr fn(java.lang.String name,
Expr expr)
fn
public static Expr fn(java.lang.String name,
Expr expr1,
Expr expr2)
fn
public static Expr fn(java.lang.String name,
Expr[] expr)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright © GeoTools. All Rights Reserved.