Class ContentVariableReplacementUtil

java.lang.Object
com.adobe.acs.commons.ccvar.util.ContentVariableReplacementUtil

public class ContentVariableReplacementUtil extends Object
Util class used to provide helper methods for finding and replacing the tokens used in this feature.
  • Method Details

    • getPlaceholder

      public static String getPlaceholder(String key)
      Takes the current key and returns it wrapped with the placeholder containers
      Parameters:
      key - The full input key
      Returns:
      The substring of the placeholder
    • hasKey

      public static boolean hasKey(Map<String,Object> contentVariableReplacements, String key)
      Checks if the passed map of variable replacements contains the key passed. It has an additional check for when the key contains an action.
      Parameters:
      contentVariableReplacements - Current map of content variable keys and values
      key - Current property key
      Returns:
      Whether the map contains the key
    • getValue

      public static Object getValue(Map<String,Object> contentVariableReplacements, String key)
      Returns the value from the map based on the key. Handles the special case of when the key contains an action.
      Parameters:
      contentVariableReplacements - Current map of content variable keys and values
      key - Current property key
      Returns:
      The value in the map
    • getKeys

      public static List<String> getKeys(String string)
      Takes the current string and returns the placeholder value. Ex: ((value))
      Parameters:
      string - The full input string
      Returns:
      A list of placeholders
    • doReplacement

      public static String doReplacement(String input, String key, String replacement, TransformAction action)
      Utility method to replace values and optionally execute actions on the values to be replaced. The default output of this method will include base escaping of volatile HTML entities. Actions can define whether they explicitly disable this base escaping.
      Parameters:
      input - The input string containing the placeholders
      key - The key containing the property name and an optional action
      replacement - The value to be replaced and optionally transformed
      action - The action found in the placeholder key
      Returns:
      The fully replaced value