org.apache.camel.util
Class StringQuoteHelper

java.lang.Object
  extended by org.apache.camel.util.StringQuoteHelper

public final class StringQuoteHelper
extends Object

Utility class for parsing quoted string which is intended for parameters, separated by comma.


Method Summary
static String doubleQuote(String text)
          Returns the text wrapped double quotes
static String quote(String text, String quote)
          Wraps the text in the given quote text
static String singleQuote(String text)
          Returns the text wrapped single quotes
static String[] splitSafeQuote(String input, char separator)
          Splits the input safely honoring if values is enclosed in quotes.
static String[] splitSafeQuote(String input, char separator, boolean trim)
          Splits the input safely honoring if values is enclosed in quotes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

doubleQuote

public static String doubleQuote(String text)
Returns the text wrapped double quotes


singleQuote

public static String singleQuote(String text)
Returns the text wrapped single quotes


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 splitted value by default.

Parameters:
input - the input
separator - the separator char to split the input, for example a comma.
Returns:
the input splitted, 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 splitted value
Returns:
the input splitted, or null if the input is null.


Apache Camel