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

StringquoteArgument(String arg)
Quotes specified string using '\"' if needed to.
int length = arg.length();
boolean needQuotes;
if (length == 0) {
    needQuotes = true;
} else {
    switch (arg.charAt(0)) {
    case '\"':
    case '\'':
...
StringquoteAtom(String term)
Wraps an atom with single quotes and escapes all single quotes contained in the atom.
return "'" + term.replace("'", "\\'") + "'";
StringquoteAtom(String term)
quote Atom
return "'" + term.replace("'", "\\'") + "'";
StringquoteAttrValue(String s)
Perform entity-quoting of quotes within attribute values.
return "\"" + s.replaceAll("&", "&").replaceAll("\"", """).replaceAll("\'", "'") + "\"";
StringquoteCanonical(String s)
Minimal escape form.
if (s == null || s.length() == 0) {
    return "\"\"";
int len = s.length();
StringBuilder sb = new StringBuilder(len + 4);
sb.append('"');
for (int i = 0; i < len; i += 1) {
    char c = s.charAt(i);
...
StringquoteCeylonKeywords(String qualifiedName)
Returns a copy of the given qualified name, but with any keyword components in the name #quoteIfCeylonKeyword(String) quoted if necessary
if (needsCeylonKeywordsQuoting(qualifiedName))
    return join(".", quoteCeylonKeywords(qualifiedName.split("\\.")));
else
    return qualifiedName;
StringquoteCharacterData(char[] ch, int start, int length)
Replace critical characters by XML entities.
StringBuilder sb = new StringBuilder();
for (int i = start; i < start + length; i++) {
    char c;
    switch (c = ch[i]) {
    case '<':
        sb.append("&lt;");
        break;
    case '>':
...
StringquoteCharacterData(String s)
Quotes character data.
final char space = '\u0020';
if (s == null)
    return null;
s = replaceAll("&", "&amp;", s);
s = replaceAll("<", "&lt;", s);
s = replaceAll("\\", "\\\\", s);
s = replaceAll("\r", "\\r", s);
s = replaceAll("\n", "\\n", s);
...
StringquoteCharacters(String s)
quote Characters
StringBuilder result = null;
for (int i = 0, max = s.length(), delta = 0; i < max; i++) {
    char c = s.charAt(i);
    String replacement = null;
    if (c == '&') {
        replacement = "&amp;";
    } else if (c == '<') {
        replacement = "&lt;";
...
StringquoteCharCode(int code)
quote Char Code
switch (code) {
case '&':
    return "&amp;";
case '<':
    return "&lt;";
case '>':
    return "&gt;";
default:
...