This class provides the ability for a developer to apply an arbitrary SQL statement
(using suitable syntax) to a collection of Java objects.
Basic usage:
Query q = new Query ();
q.parse (myStatement);
List results = q.execute (myObjects);
An example statement would look like:
SELECT lastModified,
name
FROM java.io.File
WHERE name LIKE '%.html'
The JoSQL functionality is large and complex, whilst basic queries like the one above are
perfectly possible, very complex queries are also possible, for example:
SELECT name,
formatDate(lastModified),
formatNumber(length),
formatNumber(length - @avg_length),
formatTimeDuration(@max_last_modified - lastModified)
FROM java.io.File
WHERE lastModified > @avg_last_modified
AND length > @avg_length
AND lower(name) LIKE '%.html'
GROUP BY path
ORDER BY name, lastModified DESC
EXECUTE ON ALL avg (:_allobjs, length) avg_length,
avg (:_allobjs, lastModified) avg_last_modified,
max (:_allobjs, lastModified) max_last_modified
Note: the "EXECUTE ON ALL" syntax is an extension used by JoSQL because it has no notion
of "aggregate functions".
For full details of how a query works and what is possible, see the
JoSQL User Manual.
Please note that the package structure for JoSQL is deliberate, JoSQL is designed to be a
black box and lightweight thus only the Query object and associated exceptions
are exposed in the main package. |