Class PathUtils
- Object
-
- PathUtils
-
public final class PathUtils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PathUtils.ReplacementBiFunctionWrapper<T>
Internal class used to check if the value returned by the replacement BiFunction is null or not.static class
PathUtils.ReplacementFunctionWrapper
Internal class used to check if the value returned by the replacement Function is null or not.static class
PathUtils.ReplacementWrapper<T>
Internal class extended by the two functionWrappers that holds common code.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addAnnotationsToInputProcessorResultsElement(List<PathElement> _lPathElements, List<ChangedAnnotation> _lAnnotations)
Adds the given annotations data to theInputProcessorResultsElement
in the processing path.static String
changedScriptVariablesToString(Map<String,Object> _mChangedVariables)
Returns the string representation of the given map, likeAbstractMap.toString()
.static void
cleanSentencesAndAnnotations(List<PathElement> _lPathElements)
Cleans the sentences and the annotations in all path elements.static Map<String,String>
finalizeMetadata(Map<String,String> _m, ScriptEnvironmentI _scriptEnv)
Returns a copy of the given metadata, with script expressions in the values replaced by their evaluation result.static String
overlay(String _sStr, char _cMask, int _iStart, int _iEnd)
Overlays part of a String with another String.static void
redact(int _iBeginIndex, int _iEndIndex, char _cMask, List<PathElement> _lPathElements)
Redact text, wordData and useWords in all path elements.static void
removeMetadata(List<String> _lNames, List<PathElement> _lPathElements)
Remove all the _lNames metadata from all the maps int the pathElements.static void
removeOutputParameters(List<String> _lNames, List<PathElement> _lPathElements)
Removes all output parameters with the given names from answers/outputs.static void
removeVariables(List<String> _lNames, List<PathElement> _lPathElements)
Remove all the _lNames variables from the pathElements in the following maps: flowVariables, sessionVariables and annotationVariables.static void
replaceMetadata(BiFunction<String,String,String> _function, List<PathElement> _lPathElements)
Apply the given function to all metadata maps.static void
replaceOutputParameters(BiFunction<String,String,String> _function, List<PathElement> _lPathElements)
Applies the given function to all answer/output parameters.static void
replaceOutputText(Function<String,String> _function, List<PathElement> _lPathElements)
Applies the given function to all answer/output texts.static void
replaceOutputURL(Function<String,String> _function, List<PathElement> _lPathElements)
Applies the given function to all answer/output URLs.static void
replaceVariables(BiFunction<String,Object,Object> _function, List<PathElement> _lPathElements)
Applies the given function to all variable maps.static void
setInputProcessorResultsElementConsistencyError(List<PathElement> _lPathElements, String _sConsistencyError)
Sets the consistency error message on theInputProcessorResultsElement
in the processing path to the given text, if it isn't already set.
-
-
-
Method Detail
-
finalizeMetadata
public static Map<String,String> finalizeMetadata(Map<String,String> _m, ScriptEnvironmentI _scriptEnv)
Returns a copy of the given metadata, with script expressions in the values replaced by their evaluation result. If none of the Map's values contains a script expression, then the given Map object is returned.Note: If a value originally consists of a single script expression only and its evaluation results to
null
, then the mapping for this value will not be copied to the returned Map.
-
changedScriptVariablesToString
public static String changedScriptVariablesToString(Map<String,Object> _mChangedVariables)
Returns the string representation of the given map, likeAbstractMap.toString()
. Circular object graphs in values are detected and represented by a special value.
-
replaceMetadata
public static void replaceMetadata(BiFunction<String,String,String> _function, List<PathElement> _lPathElements)
Apply the given function to all metadata maps.- Parameters:
_function
- a function accepting two arguments (metadata key and value) producing the new value_lPathElements
- pathElements on which the function will be applied
-
replaceVariables
public static void replaceVariables(BiFunction<String,Object,Object> _function, List<PathElement> _lPathElements)
Applies the given function to all variable maps.- Parameters:
_function
- a function accepting two arguments (metadata key and value) producing the new value_lPathElements
- pathElements on which the function will be applied
-
replaceOutputURL
public static void replaceOutputURL(Function<String,String> _function, List<PathElement> _lPathElements)
Applies the given function to all answer/output URLs.- Parameters:
_function
- a function accepting one argument and produces the new value_lPathElements
- pathElements on which the function will be applied
-
replaceOutputText
public static void replaceOutputText(Function<String,String> _function, List<PathElement> _lPathElements)
Applies the given function to all answer/output texts.- Parameters:
_function
- a function accepting one argument and produces the new value_lPathElements
- pathElements on which the function will be applied
-
replaceOutputParameters
public static void replaceOutputParameters(BiFunction<String,String,String> _function, List<PathElement> _lPathElements)
Applies the given function to all answer/output parameters.- Parameters:
_function
- a function accepting one argument and produces the new value_lPathElements
- pathElements on which the function will be applied
-
removeMetadata
public static void removeMetadata(List<String> _lNames, List<PathElement> _lPathElements)
Remove all the _lNames metadata from all the maps int the pathElements.- Parameters:
_lNames
- the list of log metadata names to be removed_lPathElements
- pathElements from where the metadata will be removed
-
removeVariables
public static void removeVariables(List<String> _lNames, List<PathElement> _lPathElements)
Remove all the _lNames variables from the pathElements in the following maps: flowVariables, sessionVariables and annotationVariables.- Parameters:
_lNames
- the list of log variable names to be removed_lPathElements
- pathElements from where the variables will be removed
-
removeOutputParameters
public static void removeOutputParameters(List<String> _lNames, List<PathElement> _lPathElements)
Removes all output parameters with the given names from answers/outputs.- Parameters:
_lPathElements
- pathElements from where the output parameters will be removed
-
redact
public static void redact(int _iBeginIndex, int _iEndIndex, char _cMask, List<PathElement> _lPathElements)
Redact text, wordData and useWords in all path elements.- Parameters:
_iBeginIndex
- the index of the user-input where the redact starts_iEndIndex
- the index of the user-input before which the redact ends_cMask
- the char to be used for redaction_lPathElements
- the path elements
-
cleanSentencesAndAnnotations
public static void cleanSentencesAndAnnotations(List<PathElement> _lPathElements)
Cleans the sentences and the annotations in all path elements.- Parameters:
_lPathElements
- the path elements
-
overlay
public static String overlay(String _sStr, char _cMask, int _iStart, int _iEnd)
Overlays part of a String with another String.
A
null
string input returnsnull
. A negative index is treated as zero. An index greater than the string length is treated as the string length. The start index is always the smaller of the two indices.Str.overlay(null, *, *, *) = null Str.overlay("abcdef", 'z', 2, 4) = "abzzef" Str.overlay("abcdef", 'z', -1, 4) = "zzzzzef" Str.overlay("abcdef", 'z', 2, 8) = "abzzzzzz" Str.overlay("abcdef", 'z', 8, 10) = "abcdefzz"
- Parameters:
_sStr
- the String to do overlaying in, may be null_cMask
- the mask character to be used for redaction_iStart
- the position to start overlaying at_iEnd
- the position to stop overlaying before- Returns:
- overlayed String,
null
if null String input
-
addAnnotationsToInputProcessorResultsElement
public static void addAnnotationsToInputProcessorResultsElement(List<PathElement> _lPathElements, List<ChangedAnnotation> _lAnnotations)
Adds the given annotations data to theInputProcessorResultsElement
in the processing path.- Parameters:
_lPathElements
- the path elements to search for the InputProcessorResultsElement_lAnnotations
- the annotations to add to the InputProcessorResultsElement
-
setInputProcessorResultsElementConsistencyError
public static void setInputProcessorResultsElementConsistencyError(List<PathElement> _lPathElements, String _sConsistencyError)
Sets the consistency error message on theInputProcessorResultsElement
in the processing path to the given text, if it isn't already set.- Parameters:
_lPathElements
- the path elements to search for the InputProcessorResultsElement_sConsistencyError
- the error text to set
-
-