sunlabs.brazil.properties

Class ExprPropsHandler

public class ExprPropsHandler extends Object implements Handler

The ExprPropsHandler installs an expression evaluator as a "smart properties" into the current request object, enabling arithmetic and logical expression evaluation in property name lookups.

The following configuration parameters are used:

prefix, suffix, glob, match
Only URL's that match are allowed. (See {@link sunlabs.brazil.handler.MatchString}).

Using the expression evaluator can be a bit tricky, as the evaluator works by interpreting a property name as an expression, and using its the expression result as its value. For example, the construct:

 "${x + 4 == 3}"
 
will evaluate to either "1" or "0", depending upon the value of "x". For use with the <if> constuct of the {@link sunlabs.brazil.template.BSLTemplate}, the following construct:
 <if name="${x + 4 == 3}"> ... [if expression] ... </if>
 
Will take (or not take) the "if expression" if there is a property named "1" that is set (to anything but 0 or false), but a property named "0" is not set. An entry in a server configuration file:
 1=true
 
will do the trick.

alternately, the construct:

 <if name=true value="${x + 4 == 3}"> ... [if expression] ... </if>
 
Will work as expected only if there is a configuration property:
 true=1
 
The choice of the name "true" is arbitrary, it could be any valiable whose value is "1".

Version: 2.5, 06/11/13

Author: Steve Drach <drach@sun.com>

See Also: ExprProps Request

Method Summary
booleaninit(Server server, String prefix)
booleanrespond(Request request)
Creates an instance of ExprProps that uses request.props for the wrapped Calculator's symbol table.

Method Detail

init

public boolean init(Server server, String prefix)

respond

public boolean respond(Request request)
Creates an instance of ExprProps that uses request.props for the wrapped Calculator's symbol table.

Returns: false

See Also: