Class PathUtils


  • public final class PathUtils
    extends Object
    • 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, like AbstractMap.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 returns null. 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 the InputProcessorResultsElement 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 the InputProcessorResultsElement 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