|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.filter.Filters
Utility class for working with Filters & Expression.
To get the full benifit you will need to create an instanceof this Object (supports your own custom FilterFactory!). Additional methods to help create expressions are available.
Example use:
Filters filters = new Filters( factory );
filters.duplicate( origional );
The above example creates a copy of the provided Filter,
the factory provided will be used when creating the duplicated
content.
Expressions form an interesting little semi scripting languge, intended for queries. A interesting Feature of Filter as a language is that it is not strongly typed. This utility class many helper methods that ease the transition from Strongly typed Java to the more relaxed setting of Expression where most everything can be a string.
double sum = Filters.number( Object ) + Filters.number( Object );
The above example will support the conversion of many things into a format
suitable for addition - the complete list is something like:
We do our best to be forgiving, any Java class which takes a String as a constructor can be tried, and toString() assumed to be the inverse. This lets many things (like URL and Date) function without modification.
Field Summary | |
static int |
NOTFOUND
NOTFOUND indicates int value was unavailable |
Constructor Summary | |
Filters()
|
|
Filters(FilterFactory factory)
|
Method Summary | |
static double |
asDouble(Expression expr)
Uses number( expr ), will turn result into an interger, or NaN. |
static int |
asInt(Expression expr)
Uses number( expr ), will turn result into an interger, or NOTFOUND |
static java.lang.String |
asString(Expression expr)
Uses string( expr ), will turn result into a String |
static java.lang.Object |
asType(Expression expr,
java.lang.Class TYPE)
Navigate through the expression seaching for TYPE. |
Filter |
duplicate(Filter filter)
Deep copy the filter. |
static java.lang.Object |
gets(java.lang.String text,
java.lang.Class TYPE)
Used to upcovnert a "Text Value" into the provided TYPE. |
static double |
number(java.lang.Object value)
Treat provided value as a Number, used for math opperations. |
static java.lang.String |
puts(java.awt.Color color)
|
static java.lang.String |
puts(double number)
|
static java.lang.String |
puts(java.lang.Object obj)
Inverse of eval, used to softly type supported types into Text for use as literals. |
void |
setFilterFactory(FilterFactory factory)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NOTFOUND
NOTFOUND
indicates int value was unavailable
Constructor Detail |
public Filters()
public Filters(FilterFactory factory)
Method Detail |
public void setFilterFactory(FilterFactory factory)
public Filter duplicate(Filter filter)
Filter objects are mutable, when copying a rich data structure (like SLD) you will need to duplicate the Filters referenced therein.
public static int asInt(Expression expr)
expr
-
public static java.lang.String asString(Expression expr)
expr
-
public static double asDouble(Expression expr)
expr
-
public static java.lang.Object asType(Expression expr, java.lang.Class TYPE)
This will work even with dynamic expression that would normall require a feature. It works especially well when the Expression is a Literal literal (which is usually the case).
If you have a specific Feature, please do this:
Object value = expr.getValue( feature );
return value instanceof Color ? (Color) value : null;
expr
- TYPE
- DOCUMENT ME!
public static double number(java.lang.Object value)
This function allows for the non stongly typed Math Opperations favoured by the Expression standard.
Able to hanle:
value
-
java.lang.IllegalArgumentException
- For non numerical among us -- like Geometrypublic static java.lang.Object gets(java.lang.String text, java.lang.Class TYPE) throws java.lang.Throwable
Used to tread softly on the Java typing system, because Filter/Expression is not strongly typed. Values in in Expression land are often not the the real Java Objects we wish they were - it is reall a small, lax, query language and Java objects need a but of help getting through.
A couple notes:
text
- TYPE
-
open
- set of Throwable reflection for TYPE( String )
java.lang.Throwable
public static java.lang.String puts(double number)
public static java.lang.String puts(java.lang.Object obj)
public static java.lang.String puts(java.awt.Color color)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |