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

StringquoteMonetDbValue(String value)
Put escaped quotes around a value.
return "'" + value.replaceAll("\\\\", "\\\\\\\\").replaceAll("'", "\\\\'") + "'";
StringquoteNameIfNecessary(String name)
quote Name If Necessary
return (name != null && name.indexOf(' ') >= 0 ? '"' + name + '"' : name);
StringquoteNcName(String ncName)
Quote name to make it NcName.
String result = null;
return result;
StringquotEncode(String txt)
quot Encode
if ((txt == null) || (txt.length() == 0)) {
    return txt;
txt = replace(txt, "&", "&");
txt = replace(txt, "\"", """);
return txt;
StringquotEncode(String txt)
quot Encode
if ((txt == null) || (txt.length() == 0)) {
    return txt;
txt = replaceEx(txt, "&", "&");
txt = replaceEx(txt, "\"", """);
return txt;
StringquoteOutputName(String name)
Returns a quoted name for StageOutput .
StringBuilder buf = new StringBuilder();
for (char c : name.toCharArray()) {
    if ('1' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z') {
        buf.append(c);
    } else if (c <= 0xff) {
        buf.append('0');
        buf.append(String.format("%02x", (int) c)); 
    } else {
...
StringquoteParameter(String param)
quote Parameter
if (IS_WINDOWS) {
    return "\"" + param + "\"";
return param;
StringquotePath(String path)
quote Path
if (path != null && path.indexOf(' ') != -1) {
    path = path.replaceAll("\\\\", "\\\\\\\\");
    path = '"' + path + '"';
return path;
StringquotePattern(String pattern)
Quotes a string pattern as non-regular expression string.
final String START = "\\Q"; 
final String STOP = "\\E"; 
final int STOP_LENGTH = 2; 
int stopIndex = pattern.indexOf(STOP);
if (stopIndex < 0) {
    return START + pattern + STOP;
String result = START;
...
StringquotePattern(String s)
Quotes a pattern.
s = s.replaceAll("\\\\", "\\\\");
s = s.replaceAll("\\.", "\\\\.");
s = s.replaceAll("\\+", "\\\\+");
s = s.replaceAll("\\{", "\\\\{");
s = s.replaceAll("\\}", "\\\\}");
s = s.replaceAll("\\|", "\\\\||");
s = s.replaceAll("[$]", "\\\\\\$");
s = s.replaceAll("\\?", "\\\\?");
...