dawidwys commented on a change in pull request #11070: [FLINK-16013][core] Make 
complex type config options could be parsed correctly
URL: https://github.com/apache/flink/pull/11070#discussion_r383137746
 
 

 ##########
 File path: 
flink-core/src/main/java/org/apache/flink/configuration/StructuredOptionsSplitter.java
 ##########
 @@ -52,6 +59,37 @@
                return processTokens(tokens);
        }
 
+       /**
+        * When write a string out, it is always needs to escaped. If the input 
string contains double quote or specified
+        * escape chars, then it will be escaped by single quote. The single 
quote will be escaped by doubling.
+        *
+        * <p>Given that the escapeChar is (;)
+        *
+        * <p>Examples:
+        * <ul>
+        *     <li>A,B,C,D => A,B,C,D</li>
+        *     <li>A;BCD => 'A;BCD'</li>
+        *     <li>AB"C"D => 'AB"C"D'</li>
+        *     <li>AB'"D:B => 'AB''"D:B'</li>
+        * </ul>
+        *
+        * @param value a string which needs to be escaped
+        * @param escapeChars escape chars for the escape conditions
+        * @return escaped string with single quote
+        */
+       static String escapeWithSingleQuote(String value, String... 
escapeChars) {
 
 Review comment:
   How about:
   ```
        /**
         * Escapes the given string with single quotes, if the input string 
contains a double quote or any of the
         * given {@code charsToEscape}. Any single quotes in the input string 
will be escaped by doubling.
         *
         * <p>Given that the escapeChar is (;)
         *
         * <p>Examples:
         * <ul>
         *     <li>A,B,C,D => A,B,C,D</li>
         *     <li>A;BCD => 'A;BCD'</li>
         *     <li>AB"C"D => 'AB"C"D'</li>
         *     <li>AB'"D:B => 'AB''"D:B'</li>
         * </ul>
         *
         * @param string a string which needs to be escaped
         * @param charsToEscape escape chars for the escape conditions
         * @return escaped string by single quote
         */
        static String escapeWithSingleQuote(String string, String... 
charsToEscape) {
                boolean escape = 
Arrays.stream(charsToEscape).anyMatch(string::contains) || 
string.contains("\"");
   
                if (escape) {
                        return "'" + string.replaceAll("'", "''") + "'";
                }
   
                return string;
        }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to