List of utility methods to do String Quote
String | quoted(String i, char q) Surround a string in quotes. StringBuffer b = new StringBuffer(); appendQuoted(b, i, q); return b.toString(); |
String | quoted(String path) Useful for example for javac, which doesn't like file paths with spaces if they are not in double quotes. path = path.replaceAll("\\\\", "\\\\\\\\"); path = path.replaceAll("\"", "\\\\\""); return "\"" + path + "\""; |
String | quoteD(String s) Take a string and delimit it with double quotes. return quoteImpl(s, '\"'); |
String | quoted(String s) Returns a String which equals the argument except that occurrences of '"' are expanded into its quoted-printable escaped equivalent sequence, '\"'. if (s == null || s.indexOf('"') < 0) return s; StringBuffer sb = new StringBuffer(s.length() + 5); int i, start = 0; while ((i = s.indexOf('"', start)) > -1) { sb.append(s.substring(start, i)); sb.append("\\\""); start = i + 1; ... |
boolean | quoted(String str) quoted if (str.startsWith("\"") && str.endsWith("\"")) { return true; if (str.startsWith("'") && str.endsWith("'")) { return true; return false; |
String | quoted(String text) quoted return "'" + text.replaceAll("'", "''") + "'"; |
String | quoted(String val, boolean wrap) quoted StringBuilder buf = new StringBuilder(); if (wrap) buf.append('"'); int l = val.length(); for (int n = 0; n < l; n++) { char c = val.charAt(n); if (c == '"') buf.append('\\'); ... |
String | quoted(String value) Returns the given value wrapped in double-quote characters (") if the value is not null, or the string "null" if it is null. return value == null ? "null" : "\"" + value + "\""; |
String | quoted(String value, boolean addQuotes) Returns a string in quotes for use in a database query. if (value == null) { value = "NULL"; } else { value = value.replaceAll("'", "''"); if (addQuotes) { value = "'" + value + "'"; return value; |
String | quotedEscape(final String string) Convenience method which quotes non null strings as well as escaping newlines, carriage returns and double quotes. return null == string ? null : "\"" + escape(string) + "\""; |