@Test public void testReadSql_sqlBlock_createTrigger() throws Exception { SqlFileReader reader = new SqlFileReader(new File("dummy"), "UTF-8", tokenizer, dialect) { @Override protected BufferedReader createBufferedReader() throws IOException { StringBuilder buf = new StringBuilder(); buf.append("create trigger hoge begin aaa; end\n"); buf.append("go\n"); StringReader reader = new StringReader(buf.toString()); return new BufferedReader(reader); } }; assertEquals("create trigger hoge begin aaa; end", reader.readSql()); assertNull(reader.readSql()); }
public String readSql() { if (endOfFile) { return null; } try { if (reader == null) { reader = createBufferedReader(); } SqlBuilder builder = new SqlBuilder(); readLineLoop: for (;;) { if (endOfLine) { lineCount++; tokenizer.addLine(reader.readLine()); builder.notifyLineChanged(); } for (;;) { builder.build(tokenizer.nextToken(), tokenizer.getToken()); if (builder.isTokenRequired()) { continue; } else if (builder.isLineRequired()) { continue readLineLoop; } else if (builder.isCompleted()) { return builder.getSql(); } throw new IllegalStateException("builder"); } } } catch (IOException e) { throw new IORuntimeException(e); } }
SqlFileReader { public String readSql() { if (endOfFile) { return null; } try { if (reader == null) { reader = createBufferedReader(); } SqlBuilder builder = new SqlBuilder(); readLineLoop: for (;;) { if (endOfLine) { lineCount++; tokenizer.addLine(reader.readLine()); builder.notifyLineChanged(); } for (;;) { builder.build(tokenizer.nextToken(), tokenizer.getToken()); if (builder.isTokenRequired()) { continue; } else if (builder.isLineRequired()) { continue readLineLoop; } else if (builder.isCompleted()) { return builder.getSql(); } throw new IllegalStateException("builder"); } } } catch (IOException e) { throw new IORuntimeException(e); } } }
SqlFileReader { public String readSql() { if (endOfFile) { return null; } try { if (reader == null) { reader = createBufferedReader(); } SqlBuilder builder = new SqlBuilder(); readLineLoop: for (;;) { if (endOfLine) { lineCount++; tokenizer.addLine(reader.readLine()); builder.notifyLineChanged(); } for (;;) { builder.build(tokenizer.nextToken(), tokenizer.getToken()); if (builder.isTokenRequired()) { continue; } else if (builder.isLineRequired()) { continue readLineLoop; } else if (builder.isCompleted()) { return builder.getSql(); } throw new IllegalStateException("builder"); } } } catch (IOException e) { throw new IORuntimeException(e); } } SqlFileReader(File sqlFile, String sqlFileEncoding,
            SqlFileTokenizer tokenizer, GenDialect dialect); }
SqlFileReader { public String readSql() { if (endOfFile) { return null; } try { if (reader == null) { reader = createBufferedReader(); } SqlBuilder builder = new SqlBuilder(); readLineLoop: for (;;) { if (endOfLine) { lineCount++; tokenizer.addLine(reader.readLine()); builder.notifyLineChanged(); } for (;;) { builder.build(tokenizer.nextToken(), tokenizer.getToken()); if (builder.isTokenRequired()) { continue; } else if (builder.isLineRequired()) { continue readLineLoop; } else if (builder.isCompleted()) { return builder.getSql(); } throw new IllegalStateException("builder"); } } } catch (IOException e) { throw new IORuntimeException(e); } } SqlFileReader(File sqlFile, String sqlFileEncoding,
            SqlFileTokenizer tokenizer, GenDialect dialect); String readSql(); int getLineNumber(); void close(); }
SqlFileReader { public String readSql() { if (endOfFile) { return null; } try { if (reader == null) { reader = createBufferedReader(); } SqlBuilder builder = new SqlBuilder(); readLineLoop: for (;;) { if (endOfLine) { lineCount++; tokenizer.addLine(reader.readLine()); builder.notifyLineChanged(); } for (;;) { builder.build(tokenizer.nextToken(), tokenizer.getToken()); if (builder.isTokenRequired()) { continue; } else if (builder.isLineRequired()) { continue readLineLoop; } else if (builder.isCompleted()) { return builder.getSql(); } throw new IllegalStateException("builder"); } } } catch (IOException e) { throw new IORuntimeException(e); } } SqlFileReader(File sqlFile, String sqlFileEncoding,
            SqlFileTokenizer tokenizer, GenDialect dialect); String readSql(); int getLineNumber(); void close();  }