List of utility methods to do String Quote
StringBuilder | quote(StringBuilder sb, String str) quote return sb.append('"').append(str).append('"'); |
String | quote4CMDLine(String str) quote CMD Line if (str == null) { return "\"\""; int len = str.length(); int startPos = 0; String trans = null; StringBuffer res = new StringBuffer("\""); for (int i = 0; i < len; i++) { ... |
String | quoteAndClean(String str) quote And Clean if (str == null || str.isEmpty()) { return "\"\""; StringBuffer buffer = new StringBuffer(str.length()); buffer.append('"'); for (int i = 0; i < str.length(); ++i) { char ch = str.charAt(i); switch (ch) { ... |
String | quoteAndEscape(String str) quote And Escape return quoteAndEscape(new StringBuilder(), str).toString(); |
String | quoteAndEscapeFilename(String filename) quote And Escape Filename if (filename.indexOf(" ") < 0) return filename; return "\"" + filename.replaceAll("\\\\", "\\\\\\\\") + "\""; |
String | quoteAndEscapeValue(String serviceQName) quote And Escape Value return "\"" + serviceQName.replace("?", REPLACED_QUOTATION_MARK) + "\""; |
String | quoteArg(final String arg) quote Arg if (arg.indexOf(' ') > -1 || arg.indexOf('\t') > -1 || arg.indexOf('"') > -1) { if (arg.charAt(0) != '"' && (arg.charAt(arg.length() - 1) != '"')) { StringBuilder sb = new StringBuilder(); sb.append("\""); sb.append(arg.replace("\"", "\"\"")); sb.append("\""); return sb.toString(); return arg; |
String | quoteArg(String arg) Returns the argument string surrounded with quotes if it contains a space, otherwise returns the string as is. if (arg != null && arg.indexOf(' ') > -1) { return "\"" + arg + "\""; return arg; |
String | quoteArgForCommand(String input) Quote a string suitable for the "quote aware" parser of ToHCommandExecutor . input = input.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\""); if (input.matches(".*\\s.*")) return "\"" + input + "\""; else return input; |
String | quoteArgument(final String argument) Puts quotes around the given String if necessary. String cleanedArgument = argument.trim(); while (cleanedArgument.startsWith(SINGLE_QUOTE) && cleanedArgument.endsWith(SINGLE_QUOTE) || cleanedArgument.startsWith(DOUBLE_QUOTE) && cleanedArgument.endsWith(DOUBLE_QUOTE)) { cleanedArgument = cleanedArgument.substring(1, cleanedArgument.length() - 1); final StringBuilder buf = new StringBuilder(); if (cleanedArgument.contains(DOUBLE_QUOTE)) { if (cleanedArgument.contains(SINGLE_QUOTE)) { ... |