Search in sources :

Example 1 with Select_stmtContext

use of com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Select_stmtContext in project kripton by xcesco.

the class SQLiteUpdateTestHelper method readSQLFromFile.

public static List<String> readSQLFromFile(String sqlDefinitionFile) {
    try {
        final List<String> executionList = new ArrayList<>();
        File f = new File(sqlDefinitionFile);
        final String ddl = IOUtils.toString(new FileInputStream(f), Charset.forName("utf-8"));
        MigrationSQLChecker.getInstance().analyze(ddl, new JqlBaseListener() {

            public void enterSelect_stmt(Select_stmtContext ctx) {
            }

            public void enterSql_stmt(Sql_stmtContext ctx) {
                ;
                int start = ctx.getStart().getStartIndex();
                int stop = ctx.getStop().getStopIndex() + 1;
                if (start == stop)
                    return;
                String statement = ddl.substring(start, stop).trim();
                executionList.add(statement);
            }
        });
        return executionList;
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) JqlBaseListener(com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlBaseListener) IOException(java.io.IOException) File(java.io.File) Sql_stmtContext(com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Sql_stmtContext) FileInputStream(java.io.FileInputStream) Select_stmtContext(com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Select_stmtContext)

Aggregations

JqlBaseListener (com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlBaseListener)1 Select_stmtContext (com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Select_stmtContext)1 Sql_stmtContext (com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Sql_stmtContext)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1