summaryrefslogtreecommitdiff
path: root/src/de/lmu/ifi/dbs/elki/datasource/FileBasedDatabaseConnection.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/datasource/FileBasedDatabaseConnection.java')
-rw-r--r--src/de/lmu/ifi/dbs/elki/datasource/FileBasedDatabaseConnection.java47
1 files changed, 38 insertions, 9 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/datasource/FileBasedDatabaseConnection.java b/src/de/lmu/ifi/dbs/elki/datasource/FileBasedDatabaseConnection.java
index f2ced700..300b34d2 100644
--- a/src/de/lmu/ifi/dbs/elki/datasource/FileBasedDatabaseConnection.java
+++ b/src/de/lmu/ifi/dbs/elki/datasource/FileBasedDatabaseConnection.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.datasource;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2013
+ Copyright (C) 2014
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -39,7 +39,7 @@ import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameteriz
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.FileParameter;
/**
- * Provides a file based database connection based on the parser to be set.
+ * File based database connection based on the parser to be set.
*
* @author Arthur Zimek
*
@@ -51,7 +51,41 @@ public class FileBasedDatabaseConnection extends InputStreamDatabaseConnection {
*
* @param filters Filters, can be null
* @param parser the parser to provide a database
- * @param in the input stream to parse from.
+ * @param infile File to load the data from
+ */
+ public FileBasedDatabaseConnection(List<ObjectFilter> filters, Parser parser, File infile) {
+ super(filters, parser);
+ try {
+ this.in = new BufferedInputStream(FileUtil.tryGzipInput(new FileInputStream(infile)));
+ }
+ catch(IOException e) {
+ throw new AbortException("Could not load input file: " + infile, e);
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param filters Filters, can be null
+ * @param parser the parser to provide a database
+ * @param infile File to load the data from
+ */
+ public FileBasedDatabaseConnection(List<ObjectFilter> filters, Parser parser, String infile) {
+ super(filters, parser);
+ try {
+ this.in = new BufferedInputStream(FileUtil.tryGzipInput(new FileInputStream(infile)));
+ }
+ catch(IOException e) {
+ throw new AbortException("Could not load input file: " + infile, e);
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param filters Filters, can be null
+ * @param parser the parser to provide a database
+ * @param in Input stream
*/
public FileBasedDatabaseConnection(List<ObjectFilter> filters, Parser parser, InputStream in) {
super(filters, parser);
@@ -91,12 +125,7 @@ public class FileBasedDatabaseConnection extends InputStreamDatabaseConnection {
@Override
protected FileBasedDatabaseConnection makeInstance() {
- try {
- return new FileBasedDatabaseConnection(filters, parser, new BufferedInputStream(FileUtil.tryGzipInput(new FileInputStream(infile))));
- }
- catch(IOException e) {
- throw new AbortException("Input file could not be opened.", e);
- }
+ return new FileBasedDatabaseConnection(filters, parser, infile);
}
}
} \ No newline at end of file