Class StringQuoteHelper


  • public final class StringQuoteHelper
    extends Object
    Utility class for parsing quoted string which is intended for parameters, separated by comma.
    • Method Detail

      • quote

        public static String quote​(String text,
                                   String quote)
        Wraps the text in the given quote text
        Parameters:
        text - the text to wrap in quotes
        quote - the quote text added to the prefix and postfix of the text
        Returns:
        the text wrapped in the given quotes
      • splitSafeQuote

        public static String[] splitSafeQuote​(String input,
                                              char separator)
        Splits the input safely honoring if values is enclosed in quotes.

        Though this method does not support double quoting values. A quoted value must start with the same start and ending quote, which is either a single quote or double quote value.

        Will trim each split value by default.

        Parameters:
        input - the input
        separator - the separator char to split the input, for example a comma.
        Returns:
        the input split, or null if the input is null.
      • splitSafeQuote

        public static String[] splitSafeQuote​(String input,
                                              char separator,
                                              boolean trim)
        Splits the input safely honoring if values is enclosed in quotes.

        Though this method does not support double quoting values. A quoted value must start with the same start and ending quote, which is either a single quote or double quote value.

        Parameters:
        input - the input
        separator - the separator char to split the input, for example a comma.
        trim - whether to trim each split value
        Returns:
        the input split, or null if the input is null.
      • splitSafeQuote

        public static String[] splitSafeQuote​(String input,
                                              char separator,
                                              boolean trim,
                                              boolean keepQuotes)
        Splits the input safely honoring if values is enclosed in quotes.

        Though this method does not support double quoting values. A quoted value must start with the same start and ending quote, which is either a single quote or double quote value.

        Parameters:
        input - the input
        separator - the separator char to split the input, for example a comma.
        trim - whether to trim each split value
        keepQuotes - whether to keep quotes
        Returns:
        the input split, or null if the input is null.