/** * Convert a string to the Java literal and enclose it with double quotes. * Null will result in "null" (without double quotes). * * @param s the text to convert * @return the Java representation */ public static String quoteJavaString(String s) { if (s == null) { return "null"; } return "\"" + javaEncode(s) + "\""; }
/** * Convert a string to a SQL literal. Null is converted to NULL. The text is * enclosed in single quotes. If there are any special characters, the * method STRINGDECODE is used. * * @param s the text to convert. * @return the SQL literal */ public static String quoteStringSQL(String s) { if (s == null) { return "NULL"; } int length = s.length(); StringBuilder buff = new StringBuilder(length + 2); buff.append('\''); for (int i = 0; i < length; i++) { char c = s.charAt(i); if (c == '\'') { buff.append(c); } else if (c < ' ' || c > 127) { // need to start from the beginning because maybe there was a \ // that was not quoted return "STRINGDECODE(" + quoteStringSQL(javaEncode(s)) + ")"; } buff.append(c); } buff.append('\''); return buff.toString(); }
append(StringUtils.javaEncode(sql)). append(StringUtils.javaEncode(params)). append(';'); sql = buff.toString();
break; case STRINGENCODE: result = ValueString.get(StringUtils.javaEncode(v0.getString()), database.getMode().treatEmptyStringsAsNull); break;
public static String quoteJavaString(String s) { if (s == null) { return "null"; } else { return "\"" + javaEncode(s) + "\""; } }
/** * Convert a string to the Java literal and enclose it with double quotes. * Null will result in "null" (without double quotes). * * @param s the text to convert * @return the Java representation */ public static String quoteJavaString(String s) { if (s == null) { return "null"; } return "\"" + javaEncode(s) + "\""; }
/** * Convert a string to the Java literal and enclose it with double quotes. * Null will result in "null" (without double quotes). * * @param s the text to convert * @return the Java representation */ public static String quoteJavaString(String s) { if (s == null) { return "null"; } return "\"" + javaEncode(s) + "\""; }
public static String quoteStringSQL(String s) { StringBuffer buff = new StringBuffer(s.length() + 2); buff.append('\''); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '\'') { buff.append(c); } else if (c < ' ' || c > 127) { // need to start from the beginning because maybe there was a \ // that was not quoted return "STRINGDECODE(" + quoteStringSQL(javaEncode(s)) + ")"; } buff.append(c); } buff.append('\''); return buff.toString(); }
public void infoSQL(String sql, String params, int count, long time) { StringBuffer buff = new StringBuffer(sql.length() + 20); buff.append(lineSeparator); buff.append("/*SQL "); if (params.length() > 0) { buff.append("l:"); buff.append(sql.length()); } if (count > 0) { buff.append(" #:"); buff.append(count); } if (time > 0) { buff.append(" t:"); buff.append(time); } buff.append("*/"); buff.append(StringUtils.javaEncode(sql)); buff.append(params); buff.append(';'); sql = buff.toString(); traceSystem.write(TraceSystem.INFO, module, sql, null); }
/** * Convert a string to a SQL literal. Null is converted to NULL. The text is * enclosed in single quotes. If there are any special characters, the * method STRINGDECODE is used. * * @param s the text to convert. * @return the SQL literal */ public static String quoteStringSQL(String s) { if (s == null) { return "NULL"; } int length = s.length(); StringBuilder buff = new StringBuilder(length + 2); buff.append('\''); for (int i = 0; i < length; i++) { char c = s.charAt(i); if (c == '\'') { buff.append(c); } else if (c < ' ' || c > 127) { // need to start from the beginning because maybe there was a \ // that was not quoted return "STRINGDECODE(" + quoteStringSQL(javaEncode(s)) + ")"; } buff.append(c); } buff.append('\''); return buff.toString(); }
/** * Convert a string to a SQL literal. Null is converted to NULL. The text is * enclosed in single quotes. If there are any special characters, the * method STRINGDECODE is used. * * @param s the text to convert. * @return the SQL literal */ public static String quoteStringSQL(String s) { if (s == null) { return "NULL"; } int length = s.length(); StringBuilder buff = new StringBuilder(length + 2); buff.append('\''); for (int i = 0; i < length; i++) { char c = s.charAt(i); if (c == '\'') { buff.append(c); } else if (c < ' ' || c > 127) { // need to start from the beginning because maybe there was a \ // that was not quoted return "STRINGDECODE(" + quoteStringSQL(javaEncode(s)) + ")"; } buff.append(c); } buff.append('\''); return buff.toString(); }
append(StringUtils.javaEncode(sql)). append(StringUtils.javaEncode(params)). append(';'); sql = buff.toString();
append(StringUtils.javaEncode(sql)). append(StringUtils.javaEncode(params)). append(';'); sql = buff.toString();
break; case STRINGENCODE: result = ValueString.get(StringUtils.javaEncode(v0.getString())); break; case STRINGDECODE:
break; case STRINGENCODE: result = ValueString.get(StringUtils.javaEncode(v0.getString()), database.getMode().treatEmptyStringsAsNull); break;
break; case STRINGENCODE: result = ValueString.get(StringUtils.javaEncode(v0.getString()), database.getMode().treatEmptyStringsAsNull); break;