public String parse(final String sql) throws SQLException {
  if (!checkForEscapes(sql))   return sql;
  ParserState state=ParserState.INITIAL_STATE;
  final Deque<StringBuilder> bufferStack=new ArrayDeque<>(8);
  StringBuilder buffer=new StringBuilder(sql.length());
  for (int i=0, n=sql.length(); i < n; i++) {
    char currentChar=sql.charAt(i);
    state=state.nextState(currentChar);
switch (state) {
case INITIAL_STATE:
      continue;
case NORMAL_STATE:
case LITERAL_STATE:
case START_LINE_COMMENT:
case LINE_COMMENT:
case START_BLOCK_COMMENT:
case BLOCK_COMMENT:
case END_BLOCK_COMMENT:
    buffer.append(currentChar);
  break;
case ESCAPE_ENTER_STATE:
bufferStack.push(buffer);
buffer=new StringBuilder();
break;
case ESCAPE_EXIT_STATE:
if (bufferStack.isEmpty()) {
throw new FBSQLParseException("Unbalanced JDBC escape, too many '}'");
}
String escapeText=buffer.toString();
buffer=bufferStack.pop();
escapeToNative(buffer,escapeText);
break;
default :
throw new FBSQLParseException("Unexpected parser state " + state);
}
}
if (bufferStack.isEmpty()) {
return buffer.toString();
}
 else {
throw new FBSQLParseException("Unbalanced JDBC escape, too many '{'");
}
}

public String parse ( final String sql ) throws SQLException { if ( ! checkForEscapes ( sql ) ) return sql ; ParserState state = ParserState . INITIAL_STATE ; final Deque < StringBuilder > bufferStack = new ArrayDeque < > ( 8 ) ; StringBuilder buffer = new StringBuilder ( sql . length ( ) ) ; for ( int i = 0 , n = sql . length ( ) ; i < n ; i ++ ) { char currentChar = sql . charAt ( i ) ; state = state . nextState ( currentChar ) ; switch ( state ) { case INITIAL_STATE : continue ; case NORMAL_STATE : case LITERAL_STATE : case START_LINE_COMMENT : case LINE_COMMENT : case START_BLOCK_COMMENT : case BLOCK_COMMENT : case END_BLOCK_COMMENT : buffer . append ( currentChar ) ; break ; case ESCAPE_ENTER_STATE : bufferStack . push ( buffer ) ; buffer = new StringBuilder ( ) ; break ; case ESCAPE_EXIT_STATE : if ( bufferStack . isEmpty ( ) ) { throw new FBSQLParseException ( "Unbalanced JDBC escape, too many '}'" ) ; } String escapeText = buffer . toString ( ) ; buffer = bufferStack . pop ( ) ; escapeToNative ( buffer , escapeText ) ; break ; default : throw new FBSQLParseException ( "Unexpected parser state " + state ) ; } } if ( bufferStack . isEmpty ( ) ) { return buffer . toString ( ) ; } else { throw new FBSQLParseException ( "Unbalanced JDBC escape, too many '{'" ) ; } }
converts escaped parts in the passed sql to native representation .
