01: /**********************************************************************
02: Copyright (c) 2005 Andy Jefferson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15:
16: Contributors:
17: ...
18: **********************************************************************/package org.jpox.store.expression;
19:
20: /**
21: * Representation of the size of a container in a Query.
22: *
23: * @version $Revision: 1.4 $
24: **/
25: class ContainerSizeExpression extends NumericExpression {
26: /**
27: * Constructs a expression what will return true if the argument expression has elements
28: * @param qs the QueryExpression
29: * @param argumentExpression the QueryExpression returning the size of the container
30: */
31: public ContainerSizeExpression(QueryExpression qs,
32: QueryExpression argumentExpression) {
33: super (qs);
34:
35: // Add parenthese around the subquery for clarity of SQL
36: st.append("(");
37: st.append(argumentExpression);
38: st.append(")");
39: }
40:
41: public BooleanExpression eq(ScalarExpression expr) {
42: BooleanExpression eqExpr = super .eq(expr);
43: eqExpr.encloseWithInParentheses();
44: return eqExpr;
45: }
46:
47: public BooleanExpression noteq(ScalarExpression expr) {
48: BooleanExpression eqExpr = super .noteq(expr);
49: eqExpr.encloseWithInParentheses();
50: return eqExpr;
51: }
52:
53: public BooleanExpression lt(ScalarExpression expr) {
54: BooleanExpression eqExpr = super .lt(expr);
55: eqExpr.encloseWithInParentheses();
56: return eqExpr;
57: }
58:
59: public BooleanExpression lteq(ScalarExpression expr) {
60: BooleanExpression eqExpr = super .lteq(expr);
61: eqExpr.encloseWithInParentheses();
62: return eqExpr;
63: }
64:
65: public BooleanExpression gt(ScalarExpression expr) {
66: BooleanExpression eqExpr = super .gt(expr);
67: eqExpr.encloseWithInParentheses();
68: return eqExpr;
69: }
70:
71: public BooleanExpression gteq(ScalarExpression expr) {
72: BooleanExpression eqExpr = super.gteq(expr);
73: eqExpr.encloseWithInParentheses();
74: return eqExpr;
75: }
76: }
|