org.apache.wicket.util.string.interpolator
Class MapVariableInterpolator

java.lang.Object
  extended by org.apache.wicket.util.string.interpolator.VariableInterpolator
      extended by org.apache.wicket.util.string.interpolator.MapVariableInterpolator
Direct Known Subclasses:
SystemVariableInterpolator

public class MapVariableInterpolator
extends VariableInterpolator

Interpolates variables into a String from a Map.

Since:
1.2.6
Author:
Jonathan Locke

Field Summary
 
Fields inherited from class org.apache.wicket.util.string.interpolator.VariableInterpolator
string
 
Constructor Summary
MapVariableInterpolator(java.lang.String string, java.util.Map variables)
          Constructor.
MapVariableInterpolator(java.lang.String string, java.util.Map variables, boolean exceptionOnNullVarValue)
          Constructor.
 
Method Summary
protected  java.lang.String getValue(java.lang.String variableName)
          Retrieves a value for a variable name during interpolation.
static java.lang.String interpolate(java.lang.String string, java.util.Map variables)
          Interpolates a String with the arguments defined in the given Map.
 void setVariables(java.util.Map variables)
          Sets the Map of variables.
 
Methods inherited from class org.apache.wicket.util.string.interpolator.VariableInterpolator
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapVariableInterpolator

public MapVariableInterpolator(java.lang.String string,
                               java.util.Map variables)
Constructor.

Parameters:
string - a String to interpolate into
variables - the variables to substitute

MapVariableInterpolator

public MapVariableInterpolator(java.lang.String string,
                               java.util.Map variables,
                               boolean exceptionOnNullVarValue)
Constructor.

Parameters:
string - a String to interpolate into
variables - the variables to substitute
exceptionOnNullVarValue - if true an IllegalStateException will be thrown if getValue(String) returns null, otherwise the ${varname} string will be left in the String so that multiple interpolators can be chained
Method Detail

setVariables

public final void setVariables(java.util.Map variables)
Sets the Map of variables.

Parameters:
variables - the Map of variables

getValue

protected final java.lang.String getValue(java.lang.String variableName)
Retrieves a value for a variable name during interpolation.

Specified by:
getValue in class VariableInterpolator
Parameters:
variableName - the variable name
Returns:
the value

interpolate

public static java.lang.String interpolate(java.lang.String string,
                                           java.util.Map variables)
Interpolates a String with the arguments defined in the given Map.

Parameters:
string - a String to interpolate into
variables - the variables to substitute
Returns:
the interpolated String


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.