-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdCopy.java
More file actions
40 lines (34 loc) · 1.02 KB
/
cmdCopy.java
File metadata and controls
40 lines (34 loc) · 1.02 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
/* cmdCopy.java
*
* Created by William Tyas
* 11/21/17
*
* This command creates a copy of its relational argument.
*/
import java.util.*;
public class cmdCopy extends base {
public cmdCopy(Scanner line, Database db, LinkedList<String> errorsList) {
run(line, db, errorsList);
}
public void run(Scanner line, Database db, LinkedList<String> errorsList) {
String relexp = nextSymbol(line);
int[] rIndex = findRelation(relexp, db, true);
if (rIndex[0] != -1) {
Relation r = db.getRelations().get(rIndex[0]);
Relation tmp = createTmpRelation(r, db);
}
}
public Relation createTmpRelation(Relation r, Database db) {
Relation tmp = new Relation();
for (int i = 0; i < r.getCategories().size(); i++) {
tmp.getCategories().add(r.getCategories().get(i));
tmp.getdataTypes().add(r.getdataTypes().get(i));
tmp.getmaxSize().add(r.getmaxSize().get(i));
}
for (int i = 0; i < r.getTuples().size(); i++) {
tmp.getTuples().add(r.getTuples().get(i));
}
db.getTmpRelations().add(tmp);
return tmp;
}
}