String buffer = ""; String escape = ""; for(int i = 0; i < sql.length(); i++) { char ch = sql.charAt(i); switchState(ch); if (isInState(NORMAL_STATE) && (wasInState(NORMAL_STATE) || wasInState(LITERAL_STATE))) buffer += ch; else if (isInState(NORMAL_STATE) && wasInState(ESCAPE_STATE)) {  buffer += escapeToNative(escape.substring(1, escape.length())); escape = ""; setState(NORMAL_STATE); } else if (isInState(ESCAPE_STATE)) escape += ch; else if (isInState(LITERAL_STATE)) buffer += ch; } return buffer; }
if (!checkForEscapes(sql)) return sql;  char[] sqlbuff = sql.toCharArray(); StringBuffer buffer = new StringBuffer(); StringBuffer escape = new StringBuffer();  for(int i = 0; i < sqlbuff.length; i++) {  switchState(sqlbuff[i]);  if (isInState(NORMAL_STATE) && (wasInState(NORMAL_STATE) || wasInState(LITERAL_STATE))) buffer.append(sqlbuff[i]); else if (isInState(NORMAL_STATE) && wasInState(ESCAPE_STATE)) {  buffer.append(escapeToNative(escape.substring(1, escape.length()))); escape = new StringBuffer(); setState(NORMAL_STATE); } else if (isInState(ESCAPE_STATE)) escape.append(sqlbuff[i]); else if (isInState(LITERAL_STATE)) buffer.append(sqlbuff[i]); } return buffer.toString(); }
    public String parse(String sql) throws FBSQLParseException {        String buffer = "";        String escape = "";        for(int i = 0; i < sql.length(); i++) {            char ch = sql.charAt(i);            switchState(ch);            if (isInState(NORMAL_STATE) &&                    (wasInState(NORMAL_STATE) || wasInState(LITERAL_STATE)))                buffer += ch;            else            if (isInState(NORMAL_STATE) && wasInState(ESCAPE_STATE)) {                // escape now is in form "{...." without trailing '}'...                buffer += escapeToNative(escape.substring(1, escape.length()));                escape = "";                setState(NORMAL_STATE);            } else            if (isInState(ESCAPE_STATE))                escape += ch;            else            if (isInState(LITERAL_STATE))                buffer += ch;        }        return buffer;    }