Class MapVariableInterpolator

java.lang.Object
org.apache.wicket.util.string.interpolator.VariableInterpolator
org.apache.wicket.util.string.interpolator.MapVariableInterpolator
All Implemented Interfaces:
Serializable, IClusterable
Direct Known Subclasses:
SystemVariableInterpolator

Interpolates variables into a String from a Map.
Since:
1.2.6
Author:
Jonathan Locke
See Also:
  • Constructor Details

    • MapVariableInterpolator

      public MapVariableInterpolator(String string, Map<?,?> variables)
      Constructor.
      Parameters:
      string - a String to interpolate into
      variables - the variables to substitute
    • MapVariableInterpolator

      public MapVariableInterpolator(String string, 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 Details

    • setVariables

      public final void setVariables(Map<?,?> variables)
      Sets the Map of variables.
      Parameters:
      variables - the Map of variables
    • getValue

      protected String getValue(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 String interpolate(String string, 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