F3 Reflection and Query operators
By user12610627 on Dec 12, 2006
This seemed like a good test case for F3 reflection and for its query operators, so I decided to try to see how hard it would be to do the same kind of thing in F3.
Below is a (partial) F3 equivalent of this Exhibit example.
The above demo also displays the F3 source code.
This is actually a plain Swing program (the F3 Canvas isn't used), but demonstrates the use of HTML templating with F3.
All of the filtering and sorting is actually done in 3 lines of code (take a look at DB.f3 and AttributeValueAssertion.f3).
Some things to note:
Attributeis an F3 reflection class analagous to
- Reflective access to the value of an attribute uses the
operator with an operand of type
var bar = foo.class.Attributes[Name == 'bar']; foo[bar] = 2; // The above is analogous to the following Java code // Field bar = foo.getClass().getField("bar"); // bar.set(foo, 2);
is the reflective equivalent of
foo.bar = 2;
- The F3
order byoperator is a binary operator. The left-hand side is any list of objects. The right-hand side is an expression that must return a list of comparable objects. The right-hand expression is evaluated in the context of each element of the left hand side. The current element can be accessed with the
.(dot) operator (as in XPath).
[1, 2, 3] order by -.
[3, 2, 1]