sunlabs.brazil.properties
public class SubstPropsHandler extends Object implements Handler
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.
Version: 1.5
See Also: java.util.Properties
Nested Class Summary | |
---|---|
interface | SubstPropsHandler.Convert
Class that maps strings to strings. |
static class | SubstPropsHandler.Html
HTML escape a value. |
static class | SubstPropsHandler.LowerCase
Convert a value to lowercase. |
static class | SubstPropsHandler.Resub
Do a regexp substitution on a value.
|
class | SubstPropsHandler.SubstProps
This 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.Url
URL encode a String. |
Method Summary | |
---|---|
boolean | init(Server server, String prefix) |
boolean | respond(Request request) |
String | toString() |