Documentation of 'org.clapper.util.text.WindowsCmdVariableSubstituter' Java class
WindowsCmdVariableSubstituter
org.clapper.util.text

Class WindowsCmdVariableSubstituter

  • All Implemented Interfaces:
    VariableNameChecker, VariableSubstituter


    public class WindowsCmdVariableSubstituter
    extends AbstractVariableSubstituter

    The WindowsCmdVariableSubstituter class implements the VariableSubstituter interface and provides an inline variable substitution capability using a syntax that's reminiscent of the Microsoft Windows cmd.exe command interpreter. This syntax assumes that variable references are surrounded by "%" characters. For example, given the string (variables in bold):

     file:%user.home%/profiles/%PLATFORM%/config.txt
     

    and the variable values:

     user.home=/home/bmc
     PLATFORM=freebsd
     

    a WindowsCmdVariableSubstituter will produce the result string (substitutions noted in bold):

     file:/home/bmc/profiles/freebsd/config.txt
     
    Notes and Caveats
    1. To include a literal "%" character in a string, double it.
    2. If a variable doesn't have a value, its reference is replaced by an empty string.
    3. As with all VariableSubstituter classes, an instance of the WindowsCmdVariableSubstituter class enforces its own variable syntax but defers actual variable value resolution to a separate VariableDereferencer object. One consequence of that approach is that variable names may be case-sensitive or case-insensitive, depending on how the supplied VariableDereferencer object interprets variable names.

    It's also possible to configure a WindowsCmdVariableSubstituter to throw a UndefinedVariableException, rather than substituting a blank, if a variable is undefined and a default value is not specified. See the AbstractVariableSubstituter.setAbortOnUndefinedVariable(boolean) method.

    See Also:
    UnixShellVariableSubstituter, VariableDereferencer, VariableSubstituter, String

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.