@ Override public < RET extends OCommandExecutor > RET parse ( OCommandRequest iRequest ) { final OCommandRequestText textRequest = ( OCommandRequestText ) iRequest ; if ( iRequest instanceof OSQLSynchQuery ) { request = ( OSQLSynchQuery < ODocument > ) iRequest ; } else if ( iRequest instanceof OSQLAsynchQuery ) { request = ( OSQLAsynchQuery < ODocument > ) iRequest ; } else { // BUILD A QUERY OBJECT FROM THE COMMAND REQUEST request = new OSQLSynchQuery < ODocument > ( textRequest . getText ( ) ) ; if ( textRequest . getResultListener ( ) != null ) { request . setResultListener ( textRequest . getResultListener ( ) ) ; } } String queryText = textRequest . getText ( ) ; // please, do not look at this... refactor this ASAP with new executor structure final InputStream is = new ByteArrayInputStream ( queryText . getBytes ( ) ) ; OrientSql osql = null ; try { ODatabaseDocumentInternal db = getDatabase ( ) ; if ( db == null ) { osql = new OrientSql ( is ) ; } else { osql = new OrientSql ( is , db . getStorage ( ) . getConfiguration ( ) . getCharset ( ) ) ; } } catch ( UnsupportedEncodingException e ) { OLogManager . instance ( ) . warn ( this , "Invalid charset for database " + getDatabase ( ) + " " + getDatabase ( ) . getStorage ( ) . getConfiguration ( ) . getCharset ( ) ) ; osql = new OrientSql ( is ) ; } try { OMatchStatement result = ( OMatchStatement ) osql . parse ( ) ; this . matchExpressions = result . matchExpressions ; this . notMatchExpressions = result . notMatchExpressions ; this . returnItems = result . returnItems ; this . returnAliases = result . returnAliases ; this . limit = result . limit ; } catch ( ParseException e ) { OCommandSQLParsingException ex = new OCommandSQLParsingException ( e , queryText ) ; OErrorCode . QUERY_PARSE_ERROR . throwException ( ex . getMessage ( ) , ex ) ; } buildPatterns ( ) ; pattern . validate ( ) ; return ( RET ) this ; }
this method parses the statement