Drag[en]gine Script Module DragonScript
1.23
|
Rule for resolving variables in text. More...
Public Member Functions | |
void | forEach (Block ablock) |
Visit variables with block. More... | |
String | getAt (String variable, String defaultValue) |
Value of variable or default value if absent. More... | |
int | getCount () |
Count of variables. More... | |
Array | getKeys () |
List of all variables names. More... | |
byte | getSeparatorDefaultValue () |
Separate character between variable name and default value. More... | |
bool | has (String variable) |
Variable is present. More... | |
TRRVariable | new () |
Create resolve variable rule with empty variable table. More... | |
TRRVariable | new (TRRVariable rule) |
Create copy of resolve variable rule. More... | |
void | remove (String variable) |
Remove value if present. More... | |
void | removeAll () |
Remove all variables. More... | |
String | resolveTag (String parameters, Object context) |
Resolve tag returning text to output instead of the tag. More... | |
void | setAt (String variable, String value) |
Set value of variable. More... | |
void | setSeparatorDefaultValue (byte separator) |
Set separate character between variable name and default value. More... | |
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 named 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 your variable names.
The variable name can use any character except the default value separator (default ",") and "{" or "}" 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 the 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.
String Dragengine.Utils.TRRVariable.getAt | ( | String | variable, |
String | defaultValue | ||
) |
Value of variable or default value if absent.
int Dragengine.Utils.TRRVariable.getCount | ( | ) |
Count of variables.
Array Dragengine.Utils.TRRVariable.getKeys | ( | ) |
List of all variables names.
Returns Array with String for each key.
byte Dragengine.Utils.TRRVariable.getSeparatorDefaultValue | ( | ) |
Separate character between variable name and default value.
bool Dragengine.Utils.TRRVariable.has | ( | String | variable | ) |
Variable is present.
TRRVariable Dragengine.Utils.TRRVariable.new | ( | ) |
Create resolve variable rule with empty variable table.
TRRVariable Dragengine.Utils.TRRVariable.new | ( | TRRVariable | rule | ) |
Create copy of resolve variable rule.
void Dragengine.Utils.TRRVariable.remove | ( | String | variable | ) |
Remove value if present.
void Dragengine.Utils.TRRVariable.removeAll | ( | ) |
Remove all variables.
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.
void Dragengine.Utils.TRRVariable.setAt | ( | String | variable, |
String | value | ||
) |
Set value of variable.
void Dragengine.Utils.TRRVariable.setSeparatorDefaultValue | ( | byte | separator | ) |
Set separate character between variable name and default value.
byte Dragengine.Utils.TRRVariable.pSeparatorDefaultValue |
Dictionary Dragengine.Utils.TRRVariable.pVariables |