1
2
3
4 package net.sf.bddbddb.ir.highlevel;
5
6 import java.util.Collections;
7 import java.util.List;
8 import net.sf.bddbddb.Attribute;
9 import net.sf.bddbddb.Relation;
10 import net.sf.bddbddb.ir.Operation;
11
12 /***
13 * JoinConstant
14 *
15 * @author jwhaley
16 * @version $Id: JoinConstant.java 328 2004-10-16 02:45:30Z joewhaley $
17 */
18 public class JoinConstant extends HighLevelOperation {
19 Relation r0, r1;
20 Attribute a;
21 long value;
22
23 /***
24 * @param r0
25 * @param r1
26 * @param a
27 * @param value
28 */
29 public JoinConstant(Relation r0, Relation r1, Attribute a, long value) {
30 super();
31 this.r0 = r0;
32 this.r1 = r1;
33 this.a = a;
34 this.value = value;
35 }
36
37
38
39
40
41
42 public String toString() {
43 return r0.toString() + " = " + getExpressionString();
44 }
45
46
47
48
49
50
51 public String getExpressionString() {
52 return "restrict(" + r1.toString() + "," + a.toString() + "=" + value + ")";
53 }
54
55
56
57
58
59
60 public Object visit(HighLevelOperationVisitor i) {
61 return i.visit(this);
62 }
63
64
65
66
67
68
69 public Relation getRelationDest() {
70 return r0;
71 }
72
73
74
75
76
77
78 public List getSrcs() {
79 return Collections.singletonList(r1);
80 }
81
82 /***
83 * @return Returns the source relation.
84 */
85 public Relation getSrc() {
86 return r1;
87 }
88
89 /***
90 * @return the value being joined
91 */
92 public long getValue() {
93 return value;
94 }
95
96 /***
97 * @return the attribute of the value being joined
98 */
99 public Attribute getAttribute() {
100 return a;
101 }
102
103 public Operation copy() {
104 return new JoinConstant(r0, r1, a, value);
105 }
106
107
108
109
110
111
112
113 public void replaceSrc(Relation r_old, Relation r_new) {
114 if (r1 == r_old) r1 = r_new;
115 }
116
117
118
119
120
121
122 public void setRelationDest(Relation r0) {
123 this.r0 = r0;
124 }
125 }