SVL Variables

Variables are defined through the {@link oaj.svl.Var} API.
The API comes with several predefined variables and is easily extensible.

The following is an example of a variable that performs URL-Encoding on strings.

// First create our var. public class UrlEncodeVar extends SimpleVar { // Must have a no-arg constructor! public UrlEncodeVar() { super("UE"); } // The method we must implement @Override public String resolve(VarResolverSession session, String key) { return URLEncoder.encode(key, "UTF-8"); } } // Next create a var resolver that extends the existing DEFAULT resolver // that supports resolving system properties. VarResolver r = VarResolver.DEFAULT .builder() .vars(UrlEncodeVar.class) .build(); // Retrieve a system property and URL-encode it if necessary. String myProperty = r.resolve("$UE{$S{my.property}}");

The following shows the class hierarchy of the {@link oaj.svl.Var} class:

- {@link oaj.svl.Var} - Superclass of all vars.
  - {@link oaj.svl.SimpleVar} - Superclass of all vars that return strings.
    - {@link oaj.svl.DefaultingVar} - Variables that define a default value if the resolve method returns null.
      - {@link oaj.svl.MapVar} - Variables that pull values from maps.
    - {@link oaj.svl.MultipartVar} - Variables that consist of 2 or more comma-delimited arguments.
  - {@link oaj.svl.StreamedVar} - Superclass of all vars that stream their value to writers.

The following is the list of default variables defined in all modules:

Module | Class | Pattern
--- | --- | ---
juneau-svl | {@link oaj.svl.vars.EnvVariablesVar} | $E{key[,default]}
{@link oaj.svl.vars.SystemPropertiesVar} | $S{key[,default]}
{@link oaj.svl.vars.ArgsVar} | $A{key[,default]}
{@link oaj.svl.vars.ManifestFileVar} | $MF{key[,default]}
{@link oaj.svl.vars.IfVar} | $IF{arg,then[,else]}
{@link oaj.svl.vars.SwitchVar} | $SW{arg,pattern1:then1[,pattern2:then2...]}
{@link oaj.svl.vars.CoalesceVar} | $CO{arg1[,arg2...]}
{@link oaj.svl.vars.PatternMatchVar} | $PM{arg,pattern}
{@link oaj.svl.vars.NotEmptyVar} | $NE{arg}
{@link oaj.svl.vars.UpperCaseVar} | $UC{arg}
{@link oaj.svl.vars.LowerCaseVar} | $LC{arg}
juneau-config | {@link oaj.config.vars.ConfigVar} | $C{key[,default]}
juneau-rest-server | {@link oajr.vars.FileVar} | $F{path[,default]}}
{@link oajr.vars.ServletInitParamVar} | $I{name[,default]}
{@link oajr.vars.LocalizationVar} | $L{key[,args...]}
{@link oajr.vars.RequestAttributeVar} | $RA{key1[,key2...]}
{@link oajr.vars.RequestFormDataVar} | $RF{key1[,key2...]}
{@link oajr.vars.RequestHeaderVar} | $RH{key1[,key2...]}
{@link oajr.vars.RequestHeaderVar} | $RI{key}
{@link oajr.vars.RequestPathVar} | $RP{key1[,key2...]}
{@link oajr.vars.RequestQueryVar} | $RQ{key1[,key2...]}
{@link oajr.vars.RequestVar} | $R{key1[,key2...]}
{@link oajr.vars.SerializedRequestAttrVar} | $SA{contentType,key[,default]}
{@link oajr.vars.SwaggerVar} | $SS{key1[,key2...]}
{@link oajr.vars.UrlVar} | $U{uri}>
{@link oajr.vars.UrlEncodeVar} | $UE{uriPart}
{@link oajr.vars.WidgetVar} | $W{name}