The main class for performing variable resolution is {@link oaj.svl.VarResolver}.
Two methods are provided for resolving variables:
- {@link oaj.svl.VarResolver}
- {@link oaj.svl.VarResolver#resolve(String) resolve(String)}
- Resolves variables and returns the results as a simple string.
- {@link oaj.svl.VarResolver#resolveTo(String,Writer) resolveTo(String,Writer)}
- Resolves variables and sends results to a writer.
Var resolvers can rely on the existence of other objects.
For example, {@link oaj.config.vars.ConfigVar} relies on the existence of a {@link oaj.config.Config}.
This is accomplished through the following method:
- {@link oaj.svl.VarResolver.Builder}
- {@link oaj.svl.VarResolver.Builder#bean(Class,Object) bean(Class<T>, T)} - Specify a bean for all sessions.
- {@link oaj.svl.VarResolverSession}
- {@link oaj.svl.VarResolverSession#bean(Class,Object) bean(Class<T>, T)} - Specify a bean for this session.
Beans are accessible through the following method:
- {@link oaj.svl.VarResolverSession#getBean(Class)}
Var resolvers can be cloned and extended by using the {@link oaj.svl.VarResolver#copy()} method.
Cloning a resolver will copy it's {@link oaj.svl.Var} class names and context objects.
| // Create a resolver that copies the default resolver and adds $C and $A vars.
| VarResolver myVarResolver = VarResolver
| .DEFAULT
| .copy()
| .vars(ConfigVar.class, ArgsVar.class)
| .build();