Classes | Public Member Functions | Protected Member Functions | Protected Attributes

alma.acs.commandcenter.util.VariableString Class Reference

List of all members.

Classes

interface  IResolver
class  UnresolvableException

Public Member Functions

 VariableString (String source)
 VariableString (String source, boolean lenient)
String getSource ()
String toString () throws UnresolvableException
String toString (Map<?, Object > map) throws UnresolvableException
String toString (IResolver map) throws UnresolvableException

Protected Member Functions

String resolveVariables (IResolver res, String value) throws UnresolvableException

Protected Attributes

boolean lenient
String source

Detailed Description

Purpose of this class is to resolve embedded variables in a source string like "${user.home}/config/${policydir}".

Invocation of the toString() method will resolve the embedded variables using the Java system properties. By using the toString(Map) method you can specify which dictionary to use.

In both cases, the following holds: If a non-existing (or null-value) variable is encountered, it will either a) be resolved to the empty string, or b) an exception will be thrown. This depends on the boolean flag lenient.

Note: Relationship between alma.acs.commandcenter.util.PreparedString and alma.acs.commandcenter.util.VariableString:

alma.acs.commandcenter.util.PreparedString uses positional parameters to replace placeholders with the elements of a string array. alma.acs.commandcenter.util.VariableString uses named parameters to replace placeholders with values from a map.


Constructor & Destructor Documentation

alma.acs.commandcenter.util.VariableString.VariableString ( String  source  ) 

Constructs an instance with the given source, and a lenient way of dealing with unresolvable variables.

Parameters:
source string, e.g. "${user.home}/config/${policydir}".
alma.acs.commandcenter.util.VariableString.VariableString ( String  source,
boolean  lenient 
)

Constructs an instance with the given source.

Parameters:
source string, e.g. "${user.home}/config/${policydir}".
lenient whether unresolvable variables will provoke an exception

Member Function Documentation

String alma.acs.commandcenter.util.VariableString.getSource (  ) 

Returns the non-resolved (source) version of this instance.

Returns:
the non-resolved (source) version of this instance.

References alma.acs.commandcenter.util.VariableString.source.

String alma.acs.commandcenter.util.VariableString.resolveVariables ( IResolver  res,
String  value 
) throws UnresolvableException [protected]

Performs the replacement of embedded variable names, recursively. If a non-existing (or null-value) variable is encountered, this will either a) resolve to the empty string, or b) throw an exception, depending on the boolean flag lenient.

References alma.acs.commandcenter.util.VariableString.lenient.

Referenced by alma.acs.commandcenter.util.VariableString.toString().

String alma.acs.commandcenter.util.VariableString.toString ( IResolver  map  )  throws UnresolvableException

Returns a resolved version of this instance, resolving is done using the specified IResolver.

Returns:
the resolved version of this instance.
Exceptions:
UnresolvableException if variables cannot be resolved and we are non-lenient

References alma.acs.commandcenter.util.VariableString.resolveVariables(), and alma.acs.commandcenter.util.VariableString.source.

String alma.acs.commandcenter.util.VariableString.toString ( Map<?, Object >  map  )  throws UnresolvableException

Returns a resolved version of this instance, resolving is done using the specified map.

Returns:
the resolved version of this instance.
Exceptions:
UnresolvableException if variables cannot be resolved and we are non-lenient

References alma.acs.commandcenter.util.VariableString.resolveVariables(), and alma.acs.commandcenter.util.VariableString.source.

String alma.acs.commandcenter.util.VariableString.toString (  )  throws UnresolvableException

Returns a resolved version of this instance, resolving is done using the Java system properties.

Returns:
the resolved version of this instance.
Exceptions:
UnresolvableException if variables cannot be resolved and we are non-lenient

Member Data Documentation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties