-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdRelation.java
More file actions
41 lines (36 loc) · 1.11 KB
/
cmdRelation.java
File metadata and controls
41 lines (36 loc) · 1.11 KB
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
import java.util.*;
public class cmdRelation extends base{
public cmdRelation(Scanner line, Database db, LinkedList<String> errorsList){
run(line, db, errorsList);
}
public void run(Scanner line, Database db, LinkedList<String> errorsList){
Relation a = new Relation();
String check = nextSymbol(line);
int[] rIndex = findRelation(check, db, false);
if (rIndex[0] != -1) {
errorsList.add("RELATION \"" + check + "\" ALREADY EXISTS");
}
else{
a.setTitle(check);
while (line.hasNext()) {
String cat = nextSymbol(line);
if (cat.equals("CHAR")) {
String ctype = "";
a.getdataTypes().add(ctype);
String charsize = nextSymbol(line);
a.getmaxSize().add(charsize);
}
else if (cat.equals("NUM")){
String ntype = "1";
a.getdataTypes().add(ntype);
String numsize = nextSymbol(line);
a.getmaxSize().add(numsize);
}
else{
a.getCategories().add(cat);
}
}
db.getRelations().add(a);
}
}
}