Class VariablesUtility
- java.lang.Object
-
- net.anotheria.anosite.content.variables.VariablesUtility
-
public class VariablesUtility extends Object
Utility for replacement of expressions with variables in texts. An expression consists of three parts: {prefix:name:defaultValue}. The prefix tells the variable utility which processor to use, the name and default value are submitted to the processor in question.- Author:
- lrosenberg
-
-
Constructor Summary
Constructors Constructor Description VariablesUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddLocalizationBundleProcessor(String variable, LocalizationBundleVariableProcessor processor)Add a processor for localization bundles.static voidaddProcessor(String prefix, VariablesProcessor processor)Adds a processor to this variable utility.static Map<String,VariablesProcessor>getDefaultProcessors()static List<net.anotheria.util.content.element.ContentElement>indexSource(String src)static StringreplaceLocalizationBundleVariables(String source)static StringreplaceVariables(jakarta.servlet.http.HttpServletRequest req, String src)Replaces variable expressions in the given string src with help of default processors.static StringreplaceVariables(jakarta.servlet.http.HttpServletRequest req, String src, Map<String,VariablesProcessor> processors)Replaces variable expressions in the given string src with the help of submitted processors.static StringreplaceVariables(jakarta.servlet.http.HttpServletRequest req, List<net.anotheria.util.content.element.ContentElement> index, Map<String,VariablesProcessor> processors)
-
-
-
Method Detail
-
addProcessor
public static void addProcessor(String prefix, VariablesProcessor processor)
Adds a processor to this variable utility.- Parameters:
prefix- prefix for processor mapping.processor- processor.
-
addLocalizationBundleProcessor
public static void addLocalizationBundleProcessor(String variable, LocalizationBundleVariableProcessor processor)
Add a processor for localization bundles.- Parameters:
variable- prefix for processor mappingprocessor-LocalizationBundleVariableProcessorprocessor
-
replaceLocalizationBundleVariables
public static String replaceLocalizationBundleVariables(String source)
-
getDefaultProcessors
public static Map<String,VariablesProcessor> getDefaultProcessors()
-
replaceVariables
public static String replaceVariables(jakarta.servlet.http.HttpServletRequest req, String src)
Replaces variable expressions in the given string src with help of default processors.- Parameters:
req- TODO dummy comment for javadoc.src- TODO dummy comment for javadoc.
-
replaceVariables
public static String replaceVariables(jakarta.servlet.http.HttpServletRequest req, String src, Map<String,VariablesProcessor> processors)
Replaces variable expressions in the given string src with the help of submitted processors. Useful for variable customization.- Parameters:
req- requestsrc- source stringprocessors- processors- Returns:
- returns a string with variables replaced.
-
replaceVariables
public static String replaceVariables(jakarta.servlet.http.HttpServletRequest req, List<net.anotheria.util.content.element.ContentElement> index, Map<String,VariablesProcessor> processors)
-
-