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 entityName)
quote
StringBuilder sb = new StringBuilder();
sb.append("'");
for (int i = 0; i < entityName.length(); i++) {
    char curChar = entityName.charAt(i);
    if (curChar == SINGLE_QUOTE || curChar == ESCAPE_CHAR) {
        sb.append(ESCAPE_CHAR);
    } else {
        sb.append(curChar);
...
Stringquote(String filepath)
Enclose in quotes, used for paths and filenames that contains spaces
return ("\"" + filepath + "\"");
Stringquote(String inp)
Escapes special characters in a string
StringBuffer sb = new StringBuffer(inp.length());
sb.append('\"');
sb.append(escape(inp));
sb.append('\"');
return sb.toString();
CharSequencequote(String input)
quote
StringBuilder sb = new StringBuilder("");
sb.append('"');
for (char c : input.toCharArray()) {
    if (c == '\n') {
        sb.append("\\n");
        continue;
    if (c == '"' || c == '\'' || c == '\\') {
...
Stringquote(String input)
quote the given String using double quotes, replace all double quotes within the given String by doubleing them.
return '"' + input.replaceAll("\"", "\"\"") + '"';
Stringquote(String literal)
Puts a quote before and after given string.
String result = "";
boolean t_bProcessed = true;
if ((literal != null) && (literal.length() > 0)) {
    if (literal.charAt(0) != '\"') {
        if (literal.charAt(0) != '\'') {
            result = "\"" + literal + "\"";
        } else {
            if (literal.trim().length() > 0) {
...
Stringquote(String message, String quotationMark)
quote a given message with an quotation mark
if (message == null)
    return message;
return String.format("%s%s%s", quotationMark, message, quotationMark);
Stringquote(String name)
Return a representation of the given name ensuring quoting (wrapped with '`' characters).
if (name == null || name.length() == 0 || isQuoted(name)) {
    return name;
} else {
    return new StringBuffer(name.length() + 2).append('`').append(name).append('`').toString();
Stringquote(String name)
Quote the given name by prefixing it with a dollar ($)
return "$" + name;
Stringquote(String name)
quote
if (name.toLowerCase().indexOf("\\e") > 0) {
    throw new RuntimeException("Quote method will fail");
return "\\Q" + name + "\\E";