/** * Escape the given literal <tt>value</tt> and append it to the string builder <tt>sbuf</tt>. If * <tt>sbuf</tt> is <tt>null</tt>, a new StringBuilder will be returned. The argument * <tt>standardConformingStrings</tt> defines whether the backend expects standard-conforming * string literals or allows backslash escape sequences. * * @param sbuf the string builder to append to; or <tt>null</tt> * @param value the string value * @param standardConformingStrings if standard conforming strings should be used * @return the sbuf argument; or a new string builder for sbuf == null * @throws SQLException if the string contains a <tt>\0</tt> character */ public static StringBuilder escapeLiteral(StringBuilder sbuf, String value, boolean standardConformingStrings) throws SQLException { if (sbuf == null) { sbuf = new StringBuilder((value.length() + 10) / 10 * 11); // Add 10% for escaping. } doAppendEscapedLiteral(sbuf, value, standardConformingStrings); return sbuf; }