-
Notifications
You must be signed in to change notification settings - Fork 1
/
Parse.java
48 lines (43 loc) · 1.27 KB
/
Parse.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import javafx.util.Pair;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.nio.charset.Charset;
// Abstract Layer for parsing input data
public abstract class Parse {
// Constructor & Initializer
// inputFile: path to inputFile
// dataStore: data store to insert into
public Parse( String _inputFile, DataStore _dataStore, boolean _noHeader ) {
inputFile = _inputFile;
dataStore = _dataStore;
noHeader = _noHeader;
}
private String inputFile = null; // File to parse
protected List<String> lines = null; // list of lines read in from input file
protected DataStore dataStore = null; // data store
protected boolean noHeader = false; // input file has no header (csv,psv,tsv)
// Method to open the input file
public void Open()
throws IOException
{
// open the input file
try
{
lines = Files.readAllLines( Paths.get( inputFile ), Charset.forName( "UTF-8" ) );
}
catch ( IOException e ) {
throw new IOException( "Unable to open input file: " + inputFile );
}
}
// Method to close the input file
public void Close()
throws IOException
{
// nothing
}
// Method to parse input file
public abstract void Parse() throws StorageException;
}