org.clapper.util.text
Class MultipleMapVariableDereferencer
- java.lang.Object
-
- org.clapper.util.text.MultipleMapVariableDereferencer
-
- All Implemented Interfaces:
- VariableDereferencer
public class MultipleMapVariableDereferencer extends java.lang.Object implements VariableDereferencer
/**The MultipleMapVariableDereferencer class implements the VariableDereferencer interface and resolves variable references by looking them up in one or more supplied Map objects.
The keys and values in the supplied Map objects must be String objects.
If more than one contained map has a value for a specific key, the first map's value will be used. ("First", in this case, means the first map added to the MultipleMapVariableDereference object.)
-
-
Constructor Summary
Constructors Constructor and Description MultipleMapVariableDereferencer()Creates a new instance of MultipleMapVariableDereferencer that has no associated Map objects.MultipleMapVariableDereferencer(java.util.Map<java.lang.String,java.lang.String>... maps)Creates a new instance of MultipleMapVariableDereferencer that is initialized with a specified set of maps.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddMap(java.util.Map<java.lang.String,java.lang.String> map)Add a map to the list of maps to use when dereferencing variable values.java.lang.StringgetVariableValue(java.lang.String varName, java.lang.Object context)Get the value associated with a given variable.
-
-
-
Constructor Detail
-
MultipleMapVariableDereferencer
public MultipleMapVariableDereferencer()
Creates a new instance of MultipleMapVariableDereferencer that has no associated Map objects. Map objects can be added with theaddMap(java.util.Map<java.lang.String, java.lang.String>)method.
-
MultipleMapVariableDereferencer
public MultipleMapVariableDereferencer(java.util.Map<java.lang.String,java.lang.String>... maps)
Creates a new instance of MultipleMapVariableDereferencer that is initialized with a specified set of maps.- Parameters:
maps- the maps to use
-
-
Method Detail
-
addMap
public final void addMap(java.util.Map<java.lang.String,java.lang.String> map)
Add a map to the list of maps to use when dereferencing variable values. The map is added to the end of the list.- Parameters:
map- The map to add
-
getVariableValue
public java.lang.String getVariableValue(java.lang.String varName, java.lang.Object context)Get the value associated with a given variable.- Specified by:
getVariableValuein interfaceVariableDereferencer- Parameters:
varName- The name of the variable for which the value is desired.context- a context object, passed through from the caller to the dereferencer, or null if there isn't one. Ignored here.- Returns:
- The variable's value. If the variable has no value, this method must return null.
-
-
DMelt 3.0 © DataMelt by jWork.ORG