| 
 |   | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--sunlabs.brazil.properties.SubstPropsHandler
Handler that performs value conversions on ${...} substitutions. For any property whose name matches the supplied regular expression, The source value is "converted" based on a token in the regular expression.
 This Handler is a generalization of the convert attribute
 of the get tag of the SetTemplate.  Unlike
 the implementation in the SetTemplate that implements a 
 small, fixed set of conversions of property values in the context of
 get, this handler allows plug-able conversion filters, and
 performs the conversions any time ${...} substitutions are resolved, not
 just in the context of the get tag.
 
 This requires the addition of new syntax in ${...}
 substitutions to specify the both the
 conversion (or filter) to apply, and the value to apply it to.
 This new syntax is configurable using the match,
 key, and token attributes, but defaults to:
 ${filter(value)} where filter represents the conversion
 filter, and value represents the property name whose contents
 is filtered.
 
 Any class that implements the Convert interface can be 
 loaded and called to perform filtering.  Filters that implement all the
 options of the <get ... convert=xxx> conversion options
 are included.
 
See the examples, below for the details.
^([a-z]+)\([^)]+\)$
 \\2
 \\1
 
 Using the defaults for "match", "key", and "token", a property named
 "foo" would be represented as ${xxx(foo)} where
 "xxx" is the name of the conversion filter.
 
 This class contains sample implementations of the convert
 interface.  See below for their functions.
Properties| Nested Class Summary | |
| static interface | SubstPropsHandler.ConvertClass that maps strings to strings. | 
| static class | SubstPropsHandler.HtmlHTML escape a value. | 
| static class | SubstPropsHandler.LowerCaseConvert a value to lowercase. | 
| static class | SubstPropsHandler.ResubDo a regexp substitution on a value. | 
|  class | SubstPropsHandler.SubstPropsThis class implements a properties object that knows how to extract the "name" and "filter" from a properly constructed name, and to invoke the filter on the value of the encoded name. | 
| static class | SubstPropsHandler.UrlURL encode a String. | 
| Constructor Summary | |
| SubstPropsHandler() | |
| Method Summary | |
|  boolean | init(Server server,
     String prefix)Initializes the handler. | 
|  boolean | respond(Request request)Responds to an HTTP request. | 
|  String | toString() | 
| Methods inherited from class java.lang.Object | 
| equals, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
public SubstPropsHandler()
| 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
Handler
respond in interface Handlerrequest - The Request object that represents the HTTP
		request.
true if the request was handled.  A request was
		handled if a response was supplied to the client, typically
		by calling Request.sendResponse() or
		Request.sendError.
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.
public String toString()
toString in class Object| 
 | 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 | ||||||||