equal
deleted
inserted
replaced
102 */ |
102 */ |
103 public String toString() { |
103 public String toString() { |
104 return "(" + exp1 + ") and (" + exp2 + ")"; |
104 return "(" + exp1 + ") and (" + exp2 + ")"; |
105 } |
105 } |
106 |
106 |
107 } |
107 @Override |
|
108 String toQueryString() { |
|
109 // Parentheses are only added if needed to disambiguate. |
|
110 return parens(exp1) + " and " + parens(exp2); |
|
111 } |
|
112 |
|
113 // Add parens if needed to disambiguate an expression such as |
|
114 // Query.and(Query.or(a, b), c). We need to return |
|
115 // (a or b) and c |
|
116 // in such a case, because |
|
117 // a or b and c |
|
118 // would mean |
|
119 // a or (b and c) |
|
120 private static String parens(QueryExp exp) { |
|
121 String s = Query.toString(exp); |
|
122 if (exp instanceof OrQueryExp) |
|
123 return "(" + s + ")"; |
|
124 else |
|
125 return s; |
|
126 } |
|
127 |
|
128 } |