Just checked in a full implementation of in-memory evaluation of
Cayenne expressions. Expressions can be used to filter collections of
DataObjects and regular java beans. This will be released in 1.0.6:
http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-80
Expression class had "eval" and "filterObjects" methods since the first
release, but the design behind them was rather weak, so the
implementation was provided only for a very limited subset of
expressions (AND, OR, "=" and their combinations). Currently these
methods would support all non-aggregate expressions (including pattern
matching with LIKE and LIKE_IGNORE_CASE; IN, BETWEEN, etc.).
Expression package features a simple compiler that takes an Expression
(essentially a tree) and produces a chain of ASTNode objects ("AST" is
"Abstract Syntax Tree") forming an expression representation using a
Reverse Polish Notation - an ideal for linear evaluation. It has some
optimizations, such as lazy AND and OR evaluation, and can be optimized
even further in the future.
As a reminder, there was a big expressions discussion a few months
back:
http://objectstyle.org/cayenne/lists/cayenne-devel/2003/10/0011.html .
The main points made by Giulio Cesare in that discussion were that to
stay truly object-oriented and extendable Expressions should:
1. know how to evaluate themselves in-memory
2. know how to translate themselves to SQL
And one thing that hasn't been fully figured out was how to customize
expressions by DbAdapter.
My latest additions are not yet compatible with (1) and do not deal
with (2), but any future implementation of (1) will be able to take
advantage of the evaluation logic present in the ASTNode subclasses.
Andrus
This archive was generated by hypermail 2.0.0 : Mon Jan 26 2004 - 01:14:07 EST