public void visitQueries(Reader reader, QueryVisitor visitor) { int count = 0; StringBuilder builder = new StringBuilder(); Scanner scanner = new Scanner(reader); while (scanner.hasNextLine()) { String line = trimTrailingWhitespace(scanner.nextLine()); if (builder.length() > 0) { builder.append(getSeparator()); } builder.append(line); if (statementEnds(line)) { visitor.visit(++count, withoutTrailingDelimiter(builder)); builder = new StringBuilder(); } } if (builder.length() > 0) { visitor.visit(++count, builder.toString()); } Closeables.closeQuietly(reader); }
@Override public void accept(final QueryVisitor visitor) { visitor.visit(this); }