27.7. Variables
This plug-in provides classes and interfaces to support the definition and contribution of variables for the purpose of string substitution. It supports the recursive replacement of variables referenced by name in arbitrary strings with the value of the variable. Two types of variables are provided: value variables (IValueVariable) and dynamic variables (IDynamicVariable). A value variable has a simple setter and getter for its value. A dynamic variable has an associated resolver that provides a variable's value each time it is referenced (replaced) in a string substitution. A dynamic variable may also provide an argument in its reference, which can be used by its resolver to determine its substitution value. A variable manager (IStringVariableManager) is provided to manage the set of defined variables. Value variables may be created via API on the variable manager, or contributed via the valueVariables extension point. Dynamic variables must be contributed via the dynamicVariables extension point. The variable manager provides change notification for value variables and an API for performing string substitution. Substitution simply takes a string containing variable patterns and returns that string with all the variables replaced by their associated variable values. Variables are referenced in strings by enclosing them in braces, preceded with a dollar sign. For example, "abc${foo}ghi" is composed of the strings "abc" and "ghi" sandwiching the variable "foo". If the value of foo is "def", string substitution gives "abcdefghi". In the case of dynamic variables, an optional argument is supplied by appending a colon and argument value after the variable name, for example, "${foo:bar}". In this case, the resolver associated with foo is given the referenced argument, bar, when asked to resolve a value for the variable foo. |
Tuesday, October 20, 2009
Section 27.7. Variables
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment