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

intquotedIndexOf(String text, int start, int limit, String setOfChars)
Returns the index of the first character in a set, ignoring quoted text.
for (int i = start; i < limit; ++i) {
    char c = text.charAt(i);
    if (c == BACKSLASH) {
        ++i;
    } else if (c == APOSTROPHE) {
        while (++i < limit && text.charAt(i) != APOSTROPHE) {
    } else if (setOfChars.indexOf(c) >= 0) {
...
voidquotedJavaChar(char c, StringBuilder b)
Convert character to Java-compatible source form for use in a string.
switch (c) {
case '\b':
    b.append("\\b");
    break;
case '\t':
    b.append("\\t");
    break;
case '\n':
...
StringquotedName(String name)
quoted Name
if (name.indexOf(' ') >= 0 || name.indexOf('.') >= 0)
    return '"' + name + '"';
else
    return name;
StringquotedName(String name)
DOCUMENTME.
if (name == null)
    return "<null>";
if ((name.indexOf(' ') >= 0) || (name.indexOf('.') >= 0) || (name.indexOf('-') >= 0)) {
    return '"' + name + '"';
} else {
    return name;
StringquotedName(String name)
quoted Name
if (name.matches("\\p{Lower}\\w*"))
    return name;
return "'" + name + "'";
StringquotedOrNULL(String str)
quoted Or NULL
return (str == null) ? "NULL" : '"' + str + '"';
StringquotedString(String in, boolean backslashIsEscape)
quoted String
StringBuilder out = new StringBuilder();
out.append('\'');
if (in == null) {
    out.append("null");
} else {
    for (int i = 0; i < in.length(); i++) {
        char c = in.charAt(i);
        if (c == '\'') {
...
StringquotedString(String str)
Return a double-quoted string with inner single and double quotes escaped.
if (str == null) {
    return null;
StringBuilder sb = new StringBuilder();
sb.append("\"");
for (int i = 0; i < str.length(); i++) {
    char ch = str.charAt(i);
    if ((ch == '\'') || (ch == '"')) {
...
StringquotedString(String string)
Returns a quoted version of the given string, if necessary.
return string.length() == 0 || string.indexOf(' ') >= 0 || string.indexOf('@') >= 0
        || string.indexOf('{') >= 0 || string.indexOf('}') >= 0 || string.indexOf('(') >= 0
        || string.indexOf(')') >= 0 || string.indexOf(':') >= 0 || string.indexOf(';') >= 0
        || string.indexOf(',') >= 0 ? ("'" + string + "'") : (string);
StringquotedString(String text)
quoted String
String s = escapedDoubleQutes + text + escapedDoubleQutes;
return s;