-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPredicate.java
79 lines (71 loc) · 1.8 KB
/
Predicate.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package sjdb;
/**
* This class is used to represent the predicates associated with
* joins and select operators. Note that, while a string value is
* required for predicates of the form attr=value, this values is
* only used by the toString() method; a future version of
* Attribute which uses more expressive synopses may change this.
*
* @author nmg
*/
public class Predicate {
private Attribute leftAttribute;
private Attribute rightAttribute;
private String rightValue;
/**
* Create a predicate of the form attr=attr
* @param left
* @param right
*/
public Predicate(Attribute left, Attribute right) {
this.leftAttribute = left;
this.rightAttribute = right;
}
/**
* Create a predicate of the form attr=value
* @param left
* @param value
*/
public Predicate(Attribute left, String value) {
this.leftAttribute = left;
this.rightValue = value;
}
/**
* Return true if this predicate is of the form attr=value
* @return
*/
public boolean equalsValue() {
return this.rightValue != null;
}
/**
* Return ATTR for predicates of the form ATTR=attr or ATTR=value
* @return left attribute
*/
public Attribute getLeftAttribute() {
return this.leftAttribute;
}
/**
* Return ATTR for predicates of the form attr=ATTR
* @return right attribute
*/
public Attribute getRightAttribute() {
return this.rightAttribute;
}
/**
* Return VALUE for predicates of the form attr=VALUE
* @return right value
*/
public String getRightValue() {
return this.rightValue;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
if (this.rightValue == null) {
return this.leftAttribute.toString() + "=" + this.rightAttribute.toString();
} else {
return this.leftAttribute.toString() + "=\"" + this.rightValue + "\"";
}
}
}