public class BasicVariableContainer extends java.lang.Object implements VariableContainer
Constructor and Description |
---|
BasicVariableContainer()
Initialize the new instance with default values.
|
BasicVariableContainer(java.util.Map<java.lang.String,java.lang.Object> mapping)
Initialize the new instance with the given mapping.
|
BasicVariableContainer(java.util.Properties properties)
Initialize the new instance with the given properties.
|
Modifier and Type | Method and Description |
---|---|
void |
addFrom(java.util.Map<java.lang.String,java.lang.Object> vars)
Adds all key value pairs from the given map to the variables, if the
key is a String.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
createNewMapping()
Returns a new instance for the mapping.
|
java.lang.Object |
getValue(java.lang.String varName)
Returns the value for the variable with the given name.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getVariableMapping() |
boolean |
isKnownVariable(java.lang.String varName)
Returns if the variable with the given name can be resolved by the receiver.
|
java.util.Set<java.lang.String> |
knownVariableNames()
Returns all variable name the resolver currently knows
|
void |
removeVariable(java.lang.String varName)
Remove the variable with the specified name.
|
void |
setValue(java.lang.String varName,
java.lang.String value)
Sets the value of the variable with the given name.
|
void |
setValueFor(java.lang.String varName,
boolean value)
Sets the boolean value of the variable with the given name.
|
void |
setValueFor(java.lang.String varName,
java.lang.Object value)
Sets the value of the variable with the given name.
|
protected void |
setVariableMapping(java.util.Map<java.lang.String,? extends java.lang.Object> aValue) |
public BasicVariableContainer()
public BasicVariableContainer(java.util.Map<java.lang.String,java.lang.Object> mapping)
mapping
- The instance of a Map interface compliant class.public BasicVariableContainer(java.util.Properties properties)
properties
- The properties to initialize the new instance with (must not be null).public java.util.Set<java.lang.String> knownVariableNames()
knownVariableNames
in interface VariableResolver
public java.lang.Object getValue(java.lang.String varName) throws UnknownVariableException
getValue
in interface VariableResolver
varName
- The case sensitive name of the variable.UnknownVariableException
- The receiver is not knowing the variable.public boolean isKnownVariable(java.lang.String varName)
isKnownVariable
in interface VariableResolver
varName
- The case sensitive name of the variable.public void setValueFor(java.lang.String varName, java.lang.Object value)
setValueFor
in interface VariableContainer
varName
- The case sensitive name of the variable. Must not be null !value
- The new value of the variable. Must not be null !public void setValueFor(java.lang.String varName, boolean value)
varName
- The case sensitive name of the variable. Must not be null !value
- The boolean valuepublic void setValue(java.lang.String varName, java.lang.String value)
setValue
in interface VariableContainer
varName
- The case sensitive name of the variable. Must not be null !value
- The new value of the variable. Must not be null !public void removeVariable(java.lang.String varName)
removeVariable
in interface VariableContainer
varName
- The name of the variable to be removedpublic void addFrom(java.util.Map<java.lang.String,java.lang.Object> vars)
protected java.util.Map<java.lang.String,java.lang.Object> createNewMapping()
protected java.util.Map<java.lang.String,java.lang.Object> getVariableMapping()
protected void setVariableMapping(java.util.Map<java.lang.String,? extends java.lang.Object> aValue)