com.novoda.imageloader.demo.provider.SqlFile Maven / Gradle / Ivy
package com.novoda.imageloader.demo.provider;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
public class SqlFile {
private BufferedReader reader;
private List statements;
private boolean inComment = false;
public void parse(Reader in) throws IOException {
reader = new BufferedReader(in);
statements = new ArrayList();
String line = null;
while ((line = reader.readLine()) != null) {
line.trim();
if (line.length() == 0) {
continue;
}
if (line.startsWith("--"))
continue;
if (line.startsWith("/*")) {
inComment = true;
continue;
}
if (line.endsWith("*/") && inComment == true) {
inComment = false;
continue;
}
if (inComment == true)
continue;
statements.add(line);
}
reader.close();
}
public List getStatements() {
return statements;
}
public static List statementsFrom(Reader reader) throws IOException {
SqlFile file = new SqlFile();
file.parse(reader);
return file.getStatements();
}
public static List statementsFrom(File sqlfile) throws IOException {
FileReader reader = new FileReader(sqlfile);
SqlFile file = new SqlFile();
file.parse(reader);
return file.getStatements();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy