KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectstyle > cayenne > query > DeleteQuery


1 /*
2  * ==================================================================== The ObjectStyle
3  * Group Software License, version 1.1 ObjectStyle Group - http://objectstyle.org/
4  * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors of the
5  * software. All rights reserved. Redistribution and use in source and binary forms, with
6  * or without modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright notice, this list of
8  * conditions and the following disclaimer. 2. Redistributions in binary form must
9  * reproduce the above copyright notice, this list of conditions and the following
10  * disclaimer in the documentation and/or other materials provided with the distribution.
11  * 3. The end-user documentation included with the redistribution, if any, must include
12  * the following acknowlegement: "This product includes software developed by independent
13  * contributors and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
14  * Alternately, this acknowlegement may appear in the software itself, if and wherever
15  * such third-party acknowlegements normally appear. 4. The names "ObjectStyle Group" and
16  * "Cayenne" must not be used to endorse or promote products derived from this software
17  * without prior written permission. For written permission, email "andrus at objectstyle
18  * dot org". 5. Products derived from this software may not be called "ObjectStyle" or
19  * "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their names without prior
20  * written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
21  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OBJECTSTYLE
23  * GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  * ==================================================================== This software
30  * consists of voluntary contributions made by many individuals and hosted on ObjectStyle
31  * Group web site. For more information on the ObjectStyle Group, please see
32  * <http://objectstyle.org/>.
33  */

34 package org.objectstyle.cayenne.query;
35
36 import org.objectstyle.cayenne.exp.Expression;
37 import org.objectstyle.cayenne.map.ObjEntity;
38
39 public class DeleteQuery extends QualifiedQuery {
40
41     /** Creates empty DeleteQuery. */
42     public DeleteQuery() {
43         super();
44     }
45
46     private void init(Object JavaDoc root, Expression qualifier) {
47         this.setRoot(root);
48         this.setQualifier(qualifier);
49     }
50
51     /**
52      * Creates a DeleteQuery with null qualifier, for the specifed ObjEntity
53      *
54      * @param root the ObjEntity this DeleteQuery is for.
55      */

56     public DeleteQuery(ObjEntity root) {
57         this(root, null);
58     }
59
60     /**
61      * Creates a DeleteQuery for the specifed ObjEntity with the given qualifier
62      *
63      * @param root the ObjEntity this DeleteQuery is for.
64      * @param qualifier an Expression indicating which objects should be deleted
65      */

66     public DeleteQuery(ObjEntity root, Expression qualifier) {
67         this();
68         this.init(root, qualifier);
69     }
70
71     /**
72      * Creates a DeleteQuery with null qualifier, for the entity which uses the given
73      * class
74      *
75      * @param rootClass the Class of objects this DeleteQuery is for.
76      */

77     public DeleteQuery(Class JavaDoc rootClass) {
78         this(rootClass, null);
79     }
80
81     /**
82      * Creates a DeleteQuery for the entity which uses the given class, with the given
83      * qualifier
84      *
85      * @param rootClass the Class of objects this DeleteQuery is for.
86      * @param qualifier an Expression indicating which objects should be deleted
87      */

88     public DeleteQuery(Class JavaDoc rootClass, Expression qualifier) {
89         this.init(rootClass, qualifier);
90     }
91
92     /** Creates DeleteQuery with <code>objEntityName</code> parameter. */
93     public DeleteQuery(String JavaDoc objEntityName) {
94         this(objEntityName, null);
95     }
96
97     /**
98      * Creates DeleteQuery with <code>objEntityName</code> and <code>qualifier</code>
99      * parameters.
100      */

101     public DeleteQuery(String JavaDoc objEntityName, Expression qualifier) {
102         this.init(objEntityName, qualifier);
103     }
104     
105     
106     /**
107      * Calls "makeUpdate" on the visitor.
108      *
109      * @since 1.2
110      */

111     public SQLAction createSQLAction(SQLActionVisitor visitor) {
112         return visitor.updateAction(this);
113     }
114 }
Popular Tags