// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/utils/FileUtils.java
// public class FileUtils {
// 	public static String[] files2AbsolutePath(File... files) {
// 		String[] paths = new String[files.length];
// 		for(int i = 0; i < files.length; i++) {
// 			paths[i]  = files[i].getAbsolutePath();
// 		}
// 		return paths;
// 	}
// }
// 
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/ServerAddress.java
// public class ServerAddress {
// 	
// 	private String url = null;
// 	
// 	public ServerAddress(String url) {
// 		this.url = url;
// 	}
// 	
// 	public String getURL() {
// 		return url;
// 	}
// 	
// 	public String getQueryURL() {
// 		return url;
// 	}
// }


import java.io.File;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.naming.OperationNotSupportedException;
import org.aksw.kbox.kibe.utils.FileUtils;
import org.aksw.kbox.kns.ServerAddress;
import org.apache.jena.graph.Triple;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory;
import org.apache.jena.tdb.TDBLoader;
import org.apache.jena.tdb.transaction.DatasetGraphTransaction;
	 * @param dir directory containing the database file. 
	 * @param lang the RDF streams syntax.
	 * @param inputStreams URLs of the files containing the RDF content to be loaded into the database file.
	 */
	public static void bulkload(String dir, Lang lang, InputStream... inputStreams) {
		List<InputStream> streams = Arrays.asList(inputStreams);
		SequenceInputStream sInputStream = new SequenceInputStream(Collections.enumeration(streams));
		bulkload(dir, lang, sInputStream);
	}
	
	/**
	 * Load a list of files into a database located in a given directory.
	 * 
	 * @param dir directory containing the database file.	 * 
	 * @param lang the RDF streams syntax.
	 * @param inputStream URLs of the files containing the RDF content to be loaded into the database file.
	 */
	public static void bulkload(String dir, Lang lang, InputStream inputStream) {
		DatasetGraph dataset = TDBFactory.createDatasetGraph(dir);
		RDFDataMgr.read(dataset, inputStream, lang);
		dataset.close();
	}

	/**
	 * Query a given KBox endpoint.
	 * 
	 * @param sparql a valid SPARQL query.
	 * @param address the ServerAddress of the service that will be queried.
	 * @return an ResultSet containing the elements retrieved by the given SPARQL query.
	 */
// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/utils/FileUtils.java
// public class FileUtils {
// 	public static String[] files2AbsolutePath(File... files) {
// 		String[] paths = new String[files.length];
// 		for(int i = 0; i < files.length; i++) {
// 			paths[i]  = files[i].getAbsolutePath();
// 		}
// 		return paths;
// 	}
// }
// 
// Path: kbox.kns/src/main/java/org/aksw/kbox/kns/ServerAddress.java
// public class ServerAddress {
// 	
// 	private String url = null;
// 	
// 	public ServerAddress(String url) {
// 		this.url = url;
// 	}
// 	
// 	public String getURL() {
// 		return url;
// 	}
// 	
// 	public String getQueryURL() {
// 		return url;
// 	}
// }


// Path: kbox.kibe/src/main/java/org/aksw/kbox/kibe/tdb/TDB.java
import java.io.File;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.naming.OperationNotSupportedException;
import org.aksw.kbox.kibe.utils.FileUtils;
import org.aksw.kbox.kns.ServerAddress;
import org.apache.jena.graph.Triple;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.riot.Lang;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory;
import org.apache.jena.tdb.TDBLoader;
import org.apache.jena.tdb.transaction.DatasetGraphTransaction;

	 * @param dir directory containing the database file. 
	 * @param lang the RDF streams syntax.
	 * @param inputStreams URLs of the files containing the RDF content to be loaded into the database file.
	 */
	public static void bulkload(String dir, Lang lang, InputStream... inputStreams) {
		List<InputStream> streams = Arrays.asList(inputStreams);
		SequenceInputStream sInputStream = new SequenceInputStream(Collections.enumeration(streams));
		bulkload(dir, lang, sInputStream);
	}
	
	/**
	 * Load a list of files into a database located in a given directory.
	 * 
	 * @param dir directory containing the database file.	 * 
	 * @param lang the RDF streams syntax.
	 * @param inputStream URLs of the files containing the RDF content to be loaded into the database file.
	 */
	public static void bulkload(String dir, Lang lang, InputStream inputStream) {
		DatasetGraph dataset = TDBFactory.createDatasetGraph(dir);
		RDFDataMgr.read(dataset, inputStream, lang);
		dataset.close();
	}

	/**
	 * Query a given KBox endpoint.
	 * 
	 * @param sparql a valid SPARQL query.
	 * @param address the ServerAddress of the service that will be queried.
	 * @return an ResultSet containing the elements retrieved by the given SPARQL query.
	 */
	public static ResultSet queryService(String sparql, ServerAddress address) {