|
Drag[en]gine Script Module DragonScript 1.35
|
Rule for resolving variables in text. More...
Public Member Functions | |
| void | forEach (Block ablock) |
| Visit variables with block. | |
| String | getAt (String variable, String defaultValue) |
| Value of variable or default value if absent. | |
| int | getCount () |
| Count of variables. | |
| Array | getKeys () |
| List of all variables names. | |
| byte | getSeparatorDefaultValue () |
| Separate character between variable name and default value. | |
| bool | has (String variable) |
| Variable is present. | |
| TRRVariable | new () |
| Create resolve variable rule with empty variable table. | |
| TRRVariable | new (TRRVariable rule) |
| Create copy of resolve variable rule. | |
| void | remove (String variable) |
| Remove value if present. | |
| void | removeAll () |
| Remove all variables. | |
| String | resolveTag (String parameters, Object context) |
| Resolve tag returning text to output instead of the tag. | |
| void | setAt (String variable, String value) |
| Set value of variable. | |
| void | setSeparatorDefaultValue (byte separator) |
| Set separate character between variable name and default value. | |
Public Attributes | |
| byte | pSeparatorDefaultValue |
| Dictionary | pVariables |
Rule for resolving variables in text.
Supports tags of the form {action:variable name[,default value]}. "action" is the action name used while adding the rule. A typical value to use for action is "var" or "variable". The "variable name" parameter is the name of the variable to look up in the variable table. If the variable is present the value stored in the variable table is returned as resolved text. If the variable is absent the parameter "default value" is returned as resolved text. If the parameter "default value" is absent an empty string is returned as text. The "," separator between variable name and default value can be changed to any other character. This is useful if you need "," for something else than separating parameters.
The variable name can use any character except the value separator (default ",") and "{" or "}" (depending on the settings of TagResolver) which are used as tag boundaries. This class is not going to check the names of variables added to the list to follow this rules. If you do not follow this rule the variables will be ignored.
The typical way of using this rule is to store it aside in the scripts using the TagResolver. Before processing text set variables you want to be used to this rule.
| void Dragengine.Utils.TRRVariable.forEach | ( | Block | ablock | ) |
Visit variables with block.
Block receives as first argument String name and as second argument String value.
References new(), pVariables, and setAt().
Referenced by resolveTag().
| String Dragengine.Utils.TRRVariable.getAt | ( | String | variable, |
| String | defaultValue ) |
Value of variable or default value if absent.
Referenced by removeAll(), and resolveTag().
| int Dragengine.Utils.TRRVariable.getCount | ( | ) |
| Array Dragengine.Utils.TRRVariable.getKeys | ( | ) |
List of all variables names.
Returns Array with String for each key.
References pVariables, and remove().
Referenced by resolveTag().
| byte Dragengine.Utils.TRRVariable.getSeparatorDefaultValue | ( | ) |
Separate character between variable name and default value.
References new(), pSeparatorDefaultValue, and pVariables.
Referenced by setSeparatorDefaultValue().
| bool Dragengine.Utils.TRRVariable.has | ( | String | variable | ) |
Variable is present.
References pSeparatorDefaultValue, and setSeparatorDefaultValue().
Referenced by removeAll().
| TRRVariable Dragengine.Utils.TRRVariable.new | ( | ) |
Create resolve variable rule with empty variable table.
References new(), pSeparatorDefaultValue, and pVariables.
Referenced by forEach(), getSeparatorDefaultValue(), new(), and new().
| TRRVariable Dragengine.Utils.TRRVariable.new | ( | TRRVariable | rule | ) |
Create copy of resolve variable rule.
References new().
| void Dragengine.Utils.TRRVariable.remove | ( | String | variable | ) |
Remove value if present.
Referenced by getKeys().
| void Dragengine.Utils.TRRVariable.removeAll | ( | ) |
| String Dragengine.Utils.TRRVariable.resolveTag | ( | String | parameters, |
| Object | context ) |
Resolve tag returning text to output instead of the tag.
| parameters | Parameters inside tag. |
| context | Object in the context of which the resolving is done. Context is not used. |
Implements Dragengine.Utils.TagResolverRule.
References forEach(), getAt(), getKeys(), pVariables, removeAll(), and resolveTag().
Referenced by resolveTag().
| void Dragengine.Utils.TRRVariable.setAt | ( | String | variable, |
| String | value ) |
| void Dragengine.Utils.TRRVariable.setSeparatorDefaultValue | ( | byte | separator | ) |
Set separate character between variable name and default value.
References getSeparatorDefaultValue().
Referenced by has().
| byte Dragengine.Utils.TRRVariable.pSeparatorDefaultValue |
Referenced by getCount(), getSeparatorDefaultValue(), has(), and new().
| Dictionary Dragengine.Utils.TRRVariable.pVariables |
Referenced by forEach(), getKeys(), getSeparatorDefaultValue(), new(), removeAll(), resolveTag(), and setAt().