-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.java
More file actions
87 lines (81 loc) · 2 KB
/
base.java
File metadata and controls
87 lines (81 loc) · 2 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.util.*;
public abstract class base implements Icommand{
public String nextSymbol(Scanner read){
String fix = read.next();
String better = "";
boolean quote = false;
for(int i =0; i < fix.length(); i++){
char a = fix.charAt(i);
if(a == '\''){
quote = true;
}
else if(a == '('){
}
else if(a == ')'){
}
else if(a == ','){
}
else if(a == ';'){
}
else{
better += a;
}
}
while(quote == true){
better += " ";
fix = read.next();
for(int j = 0; j < fix.length(); j++){
char a = fix.charAt(j);
if(a == '\''){
quote = false;
}
else if(a == '('){
}
else if(a == ')'){
}
else if(a == ','){
}
else if(a == ';'){
}
else{
better += a;
}
}
}
return better;
}
int[] findRelation(String name, Database db, boolean includeTmp) {
int result = -1;
int isTmpIndex = 1;
LinkedList<Relation> rls = db.getRelations();
ListIterator<Relation> litr = rls.listIterator();
int elem = 0;
while (litr.hasNext()) {
String nextTitle = litr.next().getTitle();
if (nextTitle != null && nextTitle.equals(name)) {
result = elem;
}
elem++;
}
if (includeTmp && result < 0) {
result = findTmpRelation(name, db);
isTmpIndex = 0;
}
int[] resultArray = {result, isTmpIndex};
return resultArray;
}
private int findTmpRelation(String name, Database db) {
int result = -1;
LinkedList<Relation> tmprls = db.getTmpRelations();
ListIterator<Relation> tmpitr = tmprls.listIterator();
int elem = 0;
while (tmpitr.hasNext()) {
String nextTitle = tmpitr.next().getTitle();
if (nextTitle != null && nextTitle.equals(name)) {
result = elem;
}
elem++;
}
return result;
}
}