public class Variables
extends java.lang.Object
implements org.pfsw.textx.VariableContainer
Constructor and Description |
---|
Variables()
Initialize the new instance with default values.
|
Modifier and Type | Method and Description |
---|---|
void |
add(org.pfsw.util.NamedText namedText) |
void |
addFrom(java.util.Map<?,?> vars)
Adds all key value pairs from the given map to the variables, if the
key is a String.
|
java.util.Map<java.lang.String,java.lang.String> |
asHashMap() |
protected java.lang.String[] |
asStringArray(java.util.Collection<java.lang.String> coll) |
Variables |
copy()
Returns a copy of the variables which ensures that changes to it won't
effect the original variables.
|
java.lang.String |
getValue(java.lang.String varName) |
java.lang.String |
getValueOf(java.lang.String varName)
Returns the current value of the variable with the given name
or null if the variable is not set.
|
protected org.pfsw.util.NamedTextList |
getVarData() |
java.lang.String[] |
getVariableNames()
Returns all variable names.
|
boolean |
isKnownVariable(java.lang.String varName) |
java.util.Set<java.lang.String> |
knownVariableNames()
Returns all variable names as set.
|
org.pfsw.util.NamedText[] |
namedTextArray() |
org.pfsw.util.NamedText |
namedTextAt(int index) |
void |
remove(org.pfsw.util.NamedText varDef) |
void |
removeAll(java.util.Collection<org.pfsw.util.NamedText> coll) |
void |
removeVariable(java.lang.String varName) |
void |
setNamedTextAt(int index,
org.pfsw.util.NamedText namedText) |
void |
setValue(java.lang.String varName,
java.lang.String value) |
void |
setValueFor(java.lang.String varName,
java.lang.Object value) |
int |
size() |
protected org.pfsw.text.StringUtil |
str() |
protected java.util.List<java.lang.String> |
variableNameList() |
public Variables copy()
public void removeVariable(java.lang.String varName)
removeVariable
in interface org.pfsw.textx.VariableContainer
public void setValue(java.lang.String varName, java.lang.String value)
setValue
in interface org.pfsw.textx.VariableContainer
public void setValueFor(java.lang.String varName, java.lang.Object value)
setValueFor
in interface org.pfsw.textx.VariableContainer
public java.lang.String getValue(java.lang.String varName) throws org.pfsw.textx.UnknownVariableException
getValue
in interface org.pfsw.textx.VariableResolver
org.pfsw.textx.UnknownVariableException
public boolean isKnownVariable(java.lang.String varName)
isKnownVariable
in interface org.pfsw.textx.VariableResolver
public java.util.Set<java.lang.String> knownVariableNames()
knownVariableNames
in interface org.pfsw.textx.VariableResolver
public java.lang.String getValueOf(java.lang.String varName)
UnknownVariableException
!getValue(String)
public void addFrom(java.util.Map<?,?> vars)
public java.lang.String[] getVariableNames()
public int size()
public java.util.Map<java.lang.String,java.lang.String> asHashMap()
public void add(org.pfsw.util.NamedText namedText)
public void remove(org.pfsw.util.NamedText varDef)
public void removeAll(java.util.Collection<org.pfsw.util.NamedText> coll)
public org.pfsw.util.NamedText namedTextAt(int index)
public void setNamedTextAt(int index, org.pfsw.util.NamedText namedText)
public org.pfsw.util.NamedText[] namedTextArray()
protected java.util.List<java.lang.String> variableNameList()
protected java.lang.String[] asStringArray(java.util.Collection<java.lang.String> coll)
protected org.pfsw.util.NamedTextList getVarData()
protected org.pfsw.text.StringUtil str()