sedadgn commented on a change in pull request #5458:
URL: https://github.com/apache/nifi/pull/5458#discussion_r740815019



##########
File path: 
nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/StringUtils.java
##########
@@ -510,4 +514,27 @@ public static String toTitleCase(String input) {
                 .map(word -> Character.toTitleCase(word.charAt(0)) + 
word.substring(1))
                 .collect(Collectors.joining(" "));
     }
+
+    /**
+     * Escape {@code str} by replacing occurrences of {@code charToEscape} 
with {@code escapeChar+charToEscape}
+     * @param str the input string
+     * @param escapeChar the character used for escaping
+     * @param charToEscape the character that needs to be escaped
+     * @return the escaped string
+     */
+    public static String escapeString(String str, char escapeChar, char 
charToEscape) {
+        if (str == null || str.isEmpty()) {
+            return null;
+        }
+        StringBuilder result = new StringBuilder();
+        for (int i=0; i<str.length(); i++) {
+            char curChar = str.charAt(i);
+            if (curChar == escapeChar || curChar == charToEscape) {
+                // special char
+                result.append(escapeChar);
+            }
+            result.append(curChar);

Review comment:
       I moved in ConsumeAmqp.java.Because only this class use the method. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to