Java Utililty Methods String Quote

List of utility methods to do String Quote

Description

The list of methods to do String Quote are organized into topic(s).

Method

Stringquote(String name)
Return a representation of the given name ensuring quoting (wrapped with '`' characters).
if (isEmpty(name) || isQuoted(name)) {
    return name;
else if (name.startsWith("\"") && name.endsWith("\"")) {
    name = name.substring(1, name.length() - 1);
return "`" + name + '`';
Stringquote(String p_sql)
quote
String singleQuote = "'";
String sql = singleQuote;
int index = p_sql.indexOf(singleQuote);
while (index != -1) {
    sql += p_sql.substring(0, index + 1);
    sql += singleQuote;
    if (p_sql.length() > index + 1) {
        p_sql = p_sql.substring(index + 1);
...
Stringquote(String p_string)

Escapes single quotes (') in strings by two single quotes ('').

char quote = '\'';
if (p_string.length() == 0 || p_string.indexOf(quote) == -1) {
    return p_string;
StringBuffer sb = new StringBuffer(p_string.length() + 2);
for (int i = 0, max = p_string.length(); i < max; i++) {
    char ch = p_string.charAt(i);
    sb.append(ch);
...
Stringquote(String path)
quote
String result = path;
if (path.isEmpty() || path.indexOf(' ') == -1) {
    final StringBuilder builder = new StringBuilder();
    builder.append('\'');
    for (int i = 0; i < path.length(); i++) {
        char chr = path.charAt(i);
        if (chr == '\'') {
            builder.append("\'");
...
Stringquote(String s)
quote
return isEmpty(s) ? "" : '"' + s + '"';
Stringquote(String s)
Note: The policy for quoting MUST match the unquoting policy used by Eclipse's DebugPlugin.ArgumentProcessor.
s = s.replaceAll("\"", "\\\\\"");
return '"' + s + '"';
Stringquote(String s)
Quote the given string by replacing unprintable characters by escape sequences.
char[] in = s.toCharArray();
int n = in.length;
StringBuffer out = new StringBuffer(n);
for (int i = 0; i < n; i++) {
    switch (in[i]) {
    case '\n':
        out.append("\\n");
        break;
...
Stringquote(String s)
quote
return quote(s, Empty);
Stringquote(String s)
Takes a string and returns the regex that will match that string exactly.
int i = s.indexOf(REGEX_QUOTE_END);
if (i == -1) {
    return REGEX_QUOTE_START + s + REGEX_QUOTE_END;
StringBuffer sb = new StringBuffer(s.length() + 32);
sb.append(REGEX_QUOTE_START);
int pos = 0;
do {
...
Stringquote(String s)
Returns a literal replacement String for the specified String.
if ((s.indexOf('\\') == -1) && (s.indexOf('$') == -1))
    return s;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    if (c == '\\') {
        sb.append('\\');
        sb.append('\\');
...