private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes, boolean escapeForwardSlash) {
        if (str == null) {
            return null;
        }
        try {
            Writer writer = new StringBuilderWriter(str.length() * 2);
            escapeJavaStyleString(writer, str, escapeSingleQuotes, escapeForwardSlash);
            return writer.toString();
        } catch (IOException ioe) {
            // this should never ever happen while writing to a StringBuilderWriter
            throw new RuntimeException(ioe);
        }
    }
private static String escapeJavaStyleString ( String str , boolean escapeSingleQuotes , boolean escapeForwardSlash ) { if ( str == null ) { return null ; } try { Writer writer = new StringBuilderWriter ( str . length ( ) * 2 ) ; escapeJavaStyleString ( writer , str , escapeSingleQuotes , escapeForwardSlash ) ; return writer . toString ( ) ; } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; } }
Worker method for the {@link #escapeJavaScript(String)} method.

@param str String to escape values in, may be null
@param escapeSingleQuotes escapes single quotes if <code>true</code>
@param escapeForwardSlash TODO
@return the escaped string