| 
 |   | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--sunlabs.brazil.properties.ExprPropsHandler
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:
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
 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=truewill 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=1The choice of the name "true" is arbitrary, it could be any valiable whose value is "1".
ExprProps, 
Request| Constructor Summary | |
| ExprPropsHandler() | |
| Method Summary | |
|  boolean | init(Server server,
     String prefix)Initializes the handler. | 
|  boolean | respond(Request request)Creates an instance of ExprPropsthat usesrequest.propsfor the wrappedCalculator's symbol table. | 
| Methods inherited from class java.lang.Object | 
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
public ExprPropsHandler()
| Method Detail | 
public boolean init(Server server,
                    String prefix)
Handler
init in interface Handlerserver - The HTTP server that created this Handler.
		Typical Handlers will use Server.props
		to obtain run-time configuration information.prefix - The handlers name.
		The string this Handler may prepend to all
		of the keys that it uses to extract configuration information
		from Server.props.  This is set (by the Server
		and ChainHandler) to help avoid configuration parameter
		namespace collisions.
true if this Handler initialized
		successfully, false otherwise.  If
		false is returned, this Handler
		should not be used.
public boolean respond(Request request)
                throws IOException
ExprProps that uses
 request.props for the wrapped
 Calculator's symbol table.
respond in interface Handlerrequest - The Request object that represents the HTTP
		request.
IOException - if there was an I/O error while sending the response to
		the client.  Typically, in that case, the Server
		will (try to) send an error message to the client and then
		close the client's connection.
		
		The IOException should not be used to silently
		ignore problems such as being unable to access some
		server-side resource (for example getting a
		FileNotFoundException due to not being able
		to open a file).  In that case, the Handler's
		duty is to turn that IOException into a
		HTTP response indicating, in this case, that a file could
		not be found.
Calculator| 
 | Version 2.1, Generated 12/30/04 Copyright (c) 2001-2004, Sun Microsystems. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||