JoSQL 1.4 review

Download
by rbytes.net on

JoSQL (SQL for Java Objects) provides the ability for a developer to apply a SQL statement to a collection of Java Objects

License: The Apache License 2.0
File size: 0K
Developer: Gary Bentley
0 stars award from rbytes.net

JoSQL (SQL for Java Objects) provides the ability for a developer to apply a SQL statement to a collection of Java Objects.

JoSQL provides the ability to search, order and group ANY Java objects and should be applied when you want to perform SQL-like queries on a collection of Java Objects.

Example:

// Get a list of java.io.File objects.
List myObjs = getMyObjects ();

// Create a new Query.
Query q = new Query ();

// Parse the SQL you are going to use, it is assumed here that
// "myObjs" contains instances of "java.io.File".
q.parse ("SELECT name,length " +
"FROM java.io.File " +
"WHERE fileExtension (name) = :fileExt " +
"ORDER BY length DESC, name " +
"EXECUTE ON RESULTS avg (:_allobjs, length) avgLength");

// Set the bind variable "fileExt".
q.setVariable ("fileExt", "java");

// Execute the query.
QueryResults qr = q.execute (myObjs);

// Get the average length, this is a save value, the result
// of executing the call "avg (:_allobjs, length)", it is saved against
// key: "avgLength".
Map saveValues = qr.getSaveValues ();
Number avg = (Number) saveValues.get ("avgLength");

// Cycle over the results.
List res = qr.getResults ();

for (int i = 0; i < res.size (); i++)
{

// This time there is a List for each row, index 0 holds the name of
// the file that matched, index 1 holds the length.
List r = (List) res.get (i);

System.out.println ("NAME: " + r.get (0));
System.out.println ("LENGTH: " + r.get (1) + ", AVG: " + avg);

}

What's New in This Release:
Provides a number of bugfixes, most notably the ability to use JoSQL keywords as and in Java identifiers.

JoSQL 1.4 search tags