/
DeleteParser.java
56 lines (45 loc) · 1.3 KB
/
DeleteParser.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
49
50
51
52
53
54
55
56
/*
Name: Martin Smith, Eric Anderson
CSCI 330 - Spring 2019
File Name : DeleteParser.java
*/
import java.util.*;
public class DeleteParser { // modified from SURLY1
private Parser parser;
private LinkedList<String> commands;
private AllConditions conditions;
private LinkedList<String> relations;
DeleteParser(String input) {
Parser p = new Parser(input);
commands = p.parseCommandSet();
}
DeleteParser(Parser command){ // constructor, automatically executes case creation if a WHERE exists.
parser = command;
conditions = new AllConditions();
commands = parser.parseCommandSet();
relations = new LinkedList<String>();
getDeleteRelations();
createCases();
}
private void getDeleteRelations(){ // for multiple deletes on one text file line (not for WHERE)
for(int i = 1; i < commands.size(); i = i+2){
relations.add(commands.get(i));
}
}
private void createCases(){ // automatic execution, but only if WHERE is inputted
if(parser.hasWhere()){
conditions.createAllConds(commands);
}
}
public AllConditions getConditions(){ return conditions; } // getter
public String parseRelationName(){
return commands.get(1);
}
public LinkedList<String> parseRelationNames() {
return relations;
}
public LinkedList<String> parseCommands() {
return commands;
}
}
// ### END ###