@SuppressWarnings("unchecked")
public static void _main(final QueryEvaluator evaluator,
final String datafile, final String queryfile) {
try {
final URILiteral rdfURL = LiteralFactory
.createURILiteralWithoutLazyLiteral("<file:" + datafile
+ ">");
final Collection<URILiteral> defaultGraphs = new LinkedList<URILiteral>();
final Collection<URILiteral> namedGraphs = new LinkedList<URILiteral>();
defaultGraphs.add(rdfURL);
Collection<String> queryFiles;
if (evaluator.multiplequeries) {
queryFiles = FileHelper.readFileToCollection(queryfile);
} else {
queryFiles = new LinkedList<String>();
queryFiles.add(queryfile);
}
// dataset is given from command line
if (evaluator.dataset.compareTo("") != 0) {
// copy RDF name in dataset to the static variable dataset
final BufferedReader br = new BufferedReader(new FileReader(
evaluator.dataset));
while (br.ready()) {
String rdf = br.readLine();
// System.out.println(rdf);
while (br.ready() && (rdf.length() > 0)
&& rdf.substring(0, 1).compareTo("*") == 0) {
rdf = br.readLine();
// System.out.println(query);
}
if ((rdf.length() > 0)
&& (rdf.substring(0, 1).compareTo("*") != 0)) {
final String[] s = rdf.split(" ");
if (s.length > 0) {
boolean defaultGraph;
String url;
if (s.length == 1) {
defaultGraph = true;
url = s[0];
} else {
url = s[1];
if (s[0].compareTo("named") == 0
|| s[0].compareTo("named:") == 0)
defaultGraph = false;
else
defaultGraph = true;
}
final URILiteral rdfURL2 = LiteralFactory
.createURILiteralWithoutLazyLiteral("<file:"
+ url + ">");
if (defaultGraph)
defaultGraphs.add(rdfURL2);
else
namedGraphs.add(rdfURL2);
}
}
}
}
if (evaluator.compare != compareEvaluator.NONE) {
String[] argsCompareEngine = evaluator.compareoptions
.split("[\b]|[\t]|[\f]|[\n]|[\r]| ");
for (int i = 0; i < argsCompareEngine.length; i++) {
if (argsCompareEngine[i].compareTo("--compare") == 0
|| argsCompareEngine[i]
.compareTo("--compareoptions") == 0
|| argsCompareEngine[i].compareTo("--times") == 0) {
System.out.println("The option " + argsCompareEngine[i]
+ " must not be nested in a compare option!");
return;
}
}
String compareDataFile = datafile;
Collection<URILiteral> compareDefaultGraphs = defaultGraphs;
Collection<URILiteral> compareNamedGraphs = namedGraphs;
// final Collection<String> compareQueryFiles = queryFiles;
if (!argsCompareEngine[0].startsWith("--")) {
compareDataFile = argsCompareEngine[0];
final URILiteral compareRdfURL = LiteralFactory
.createURILiteralWithoutLazyLiteral("<file:"
+ compareDataFile + ">");
compareDefaultGraphs = new LinkedList<URILiteral>();
compareNamedGraphs = new LinkedList<URILiteral>();
compareDefaultGraphs.add(compareRdfURL);