org.clapper.util.text
Class MultipleMapVariableDereferencer

java.lang.Object
  extended by 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.)

Version:
$Revision: 6735 $
Author:
Copyright © 2004-2007 Brian M. Clapper
See Also:
VariableDereferencer, VariableSubstituter, MapVariableDereferencer

Constructor Summary
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
 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.
 java.lang.String getVariableValue(java.lang.String varName, java.lang.Object context)
          Get the value associated with a given variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipleMapVariableDereferencer

public MultipleMapVariableDereferencer()
Creates a new instance of MultipleMapVariableDereferencer that has no associated Map objects. Map objects can be added with the addMap(java.util.Map) 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:
getVariableValue in interface VariableDereferencer
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.


Copyright © 2004-2007 Brian M. Clapper. All Rights Reserved.