KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > SubquerySetExpression


1 /*
2  * Copyright 2002 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: SubquerySetExpression.java,v 1.1 2003/08/11 16:01:51 pierreg0 Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import javax.jdo.JDOFatalInternalException;
14
15
16 /**
17  * A set expression whose contents are expressed as a SQL subquery.
18  *
19  * @author <a HREF="mailto:mmartin5@austin.rr.com">Mike Martin</a>
20  * @version $Revision: 1.1 $
21  */

22
23 class SubquerySetExpression extends SetExpression
24 {
25     private final QueryStatement subquery;
26
27
28     public SubquerySetExpression(QueryStatement qs, QueryStatement subquery)
29     {
30         super(qs);
31
32         this.subquery = subquery;
33
34         if (subquery.columnsSelected() != 1)
35             throw new JDOFatalInternalException("Cannot use as set expression, # of selected columns != 1: " + subquery);
36
37         st.append("(").append(subquery.toStatementText()).append(')');
38     }
39
40
41     public BooleanExpression containsMethod(SQLExpression expr)
42     {
43         return expr.in(this);
44     }
45
46
47     public BooleanExpression isEmptyMethod()
48     {
49         return new ExistsExpression(qs, subquery, false);
50     }
51 }
52
Popular Tags