KickJava   Java API By Example, From Geeks To Geeks.

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


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: ExistsExpression.java,v 1.2 2002/10/17 21:00:55 pierreg0 Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13
14 class ExistsExpression extends BooleanExpression
15 {
16     private final QueryStatement subquery;
17     private final boolean truthTest;
18
19     public ExistsExpression(QueryStatement qs, QueryStatement subquery)
20     {
21         this(qs, subquery, true);
22     }
23
24     public ExistsExpression(QueryStatement qs, QueryStatement subquery, boolean truthTest)
25     {
26         super(qs);
27
28         this.subquery = subquery;
29         this.truthTest = truthTest;
30
31         if (!truthTest)
32             st.append("NOT ");
33
34         st.append("EXISTS (").append(subquery.toStatementText()).append(')');
35
36     }
37
38     public BooleanExpression not()
39     {
40         return new ExistsExpression(qs, subquery, !truthTest);
41     }
42 }
43
Popular Tags