Package com.nuix.nx.misc
Class PlaceholderResolver
- java.lang.Object
-
- com.nuix.nx.misc.PlaceholderResolver
-
public class PlaceholderResolver extends java.lang.Object
This class provides a way to allow user input to make use of place holder values which will be substituted at run time with appropriate values.
-
-
Constructor Summary
Constructors Constructor Description PlaceholderResolver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
cleanPathString(java.lang.String input)
Helper method to strip common illegal path characters from a stringvoid
clear()
Clears all currently associated place holders (keys and values)java.lang.String
get(java.lang.String key)
Get the value currently associated for a given placeholderjava.util.Map<java.lang.String,java.lang.String>
getPlaceholderData()
Gets the Map containing all the current place holder datajava.lang.String
resolveTemplate(java.lang.String template)
Resolves place holders into a string based on the currently associated valuesjava.lang.String
resolveTemplatePath(java.lang.String template)
Resolves place holders into a path string based on the currently associated values.void
set(java.lang.String key, java.lang.String value)
Set they value for a given placeholdervoid
setPath(java.lang.String key, java.lang.String value)
Similar to theset(java.lang.String, java.lang.String)
method except this has logic to appropriately handle file paths.
-
-
-
Method Detail
-
set
public void set(java.lang.String key, java.lang.String value)
Set they value for a given placeholder- Parameters:
key
- The placeholder name without '{' or '}'value
- The value to associate
-
setPath
public void setPath(java.lang.String key, java.lang.String value)
Similar to theset(java.lang.String, java.lang.String)
method except this has logic to appropriately handle file paths.- Parameters:
key
- The placeholder name without '{' or '}'value
- The file/directory path value to associate
-
get
public java.lang.String get(java.lang.String key)
Get the value currently associated for a given placeholder- Parameters:
key
- The placeholder name without '{' or '}'- Returns:
- The currently associated placeholder value
-
clear
public void clear()
Clears all currently associated place holders (keys and values)
-
getPlaceholderData
public java.util.Map<java.lang.String,java.lang.String> getPlaceholderData()
Gets the Map containing all the current place holder data- Returns:
- A Map containing all the current place holder data
-
resolveTemplate
public java.lang.String resolveTemplate(java.lang.String template)
Resolves place holders into a string based on the currently associated values- Parameters:
template
- The input string containing place holders- Returns:
- The input string in which place holders have been replaced with associated values
-
resolveTemplatePath
public java.lang.String resolveTemplatePath(java.lang.String template)
Resolves place holders into a path string based on the currently associated values. Contains logic to sterilize the resulting path string so that it does not contain common illegal path characters.- Parameters:
template
- A file/directory path string containing place holders- Returns:
- The input string in which place holders have been replaced with associated values
-
cleanPathString
public static java.lang.String cleanPathString(java.lang.String input)
Helper method to strip common illegal path characters from a string- Parameters:
input
- The string to clean up- Returns:
- The string with illegal path characters replaced with '_'
-
-