Package | ch.capi.utils |
Class | public class VariableReplacer |
Inheritance | VariableReplacer Object |
IMap
to
store the pairs of key/values.
Property | Defined By | ||
---|---|---|---|
defaultVariableRegexp : RegExp [static]
Defines the regular expression for the variables. | VariableReplacer | ||
regexp : RegExp
Defines the regular expression of the variables. | VariableReplacer | ||
replacementCount : uint [read-only]
Defines the number of replacements done on the last String. | VariableReplacer | ||
variables : IMap
Defines the IMap that contains all pairs variable/value. | VariableReplacer |
Method | Defined By | ||
---|---|---|---|
VariableReplacer(variables:IMap = null, regexp:RegExp = null)
Creates a new VariableReplacer object. | VariableReplacer | ||
[static]
Replaces the variables in the source String using the specified regular expression. | VariableReplacer | ||
replaceVar(source:String, variableName:String, value:String, regexp:RegExp = null):String [static]
Replaces the specified variable in the source String using the specified regular expression. | VariableReplacer | ||
replaceVars(source:String):String
Replaces all the variables contained in the source String using the specified
IMap as source for the variables. | VariableReplacer |
defaultVariableRegexp | property |
public static var defaultVariableRegexp:RegExp
Defines the regular expression for the variables. By default, a variable is always of the form ${VARIABLE_NAME}. The allowed characters for a variable name are A-Z, a-z, 0-9 and _.
regexp | property |
regexp:RegExp
[read-write] Defines the regular expression of the variables. This regular expression must have at least one parenthesis matching group.
public function get regexp():RegExp
public function set regexp(value:RegExp):void
replacementCount | property |
replacementCount:uint
[read-only]
Defines the number of replacements done on the last String
.
public function get replacementCount():uint
variables | property |
variables:IMap
[read-write]
Defines the IMap
that contains all pairs variable/value.
public function get variables():IMap
public function set variables(value:IMap):void
VariableReplacer | () | Constructor |
public function VariableReplacer(variables:IMap = null, regexp:RegExp = null)
Creates a new VariableReplacer
object.
variables:IMap (default = null ) — The variables of the replacer. If no IMap is specified, then
a DictionnaryMap will be used.
| |
regexp:RegExp (default = null ) — The regular expression for the variables. This regular expression must
have at least one parenthesis matching group.
|
replace | () | method |
public static function replace(source:String, variables:IMap, regexp:RegExp = null):String
Replaces the variables in the source String
using the specified regular expression. This
is a utility method for a fast useablility.
Parameters
source:String — The source String .
| |
variables:IMap — The variables.
| |
regexp:RegExp (default = null ) — The regular expression of the variable.
|
String — The String with the replaced variables.
|
replaceVar | () | method |
public static function replaceVar(source:String, variableName:String, value:String, regexp:RegExp = null):String
Replaces the specified variable in the source String
using the specified regular expression.
This is a utility method for a fast useablility.
Parameters
source:String — The source String .
| |
variableName:String — The name of the variable (ID in ${ID} with the default RegExp).
| |
value:String — The value to set in place of the variable.
| |
regexp:RegExp (default = null ) — The regular expression of the variable.
|
String — The String with the replaced variables.
|
replaceVars | () | method |
public function replaceVars(source:String):String
Replaces all the variables contained in the source String
using the specified
IMap
as source for the variables. If a variable is not defined, then an Error
will be thrown.
Parameters
source:String — The source String to do the replacement.
|
String — The updated String with values.
|
Error If — a variable is not defined.
|