KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.query;
21
22 import org.apache.cayenne.exp.Expression;
23 import org.apache.cayenne.map.ObjEntity;
24
25 public class DeleteQuery extends QualifiedQuery {
26
27     /** Creates empty DeleteQuery. */
28     public DeleteQuery() {
29         super();
30     }
31
32     private void init(Object JavaDoc root, Expression qualifier) {
33         this.setRoot(root);
34         this.setQualifier(qualifier);
35     }
36
37     /**
38      * Creates a DeleteQuery with null qualifier, for the specifed ObjEntity
39      *
40      * @param root the ObjEntity this DeleteQuery is for.
41      */

42     public DeleteQuery(ObjEntity root) {
43         this(root, null);
44     }
45
46     /**
47      * Creates a DeleteQuery for the specifed ObjEntity with the given qualifier
48      *
49      * @param root the ObjEntity this DeleteQuery is for.
50      * @param qualifier an Expression indicating which objects should be deleted
51      */

52     public DeleteQuery(ObjEntity root, Expression qualifier) {
53         this();
54         this.init(root, qualifier);
55     }
56
57     /**
58      * Creates a DeleteQuery with null qualifier, for the entity which uses the given
59      * class
60      *
61      * @param rootClass the Class of objects this DeleteQuery is for.
62      */

63     public DeleteQuery(Class JavaDoc rootClass) {
64         this(rootClass, null);
65     }
66
67     /**
68      * Creates a DeleteQuery for the entity which uses the given class, with the given
69      * qualifier
70      *
71      * @param rootClass the Class of objects this DeleteQuery is for.
72      * @param qualifier an Expression indicating which objects should be deleted
73      */

74     public DeleteQuery(Class JavaDoc rootClass, Expression qualifier) {
75         this.init(rootClass, qualifier);
76     }
77
78     /** Creates DeleteQuery with <code>objEntityName</code> parameter. */
79     public DeleteQuery(String JavaDoc objEntityName) {
80         this(objEntityName, null);
81     }
82
83     /**
84      * Creates DeleteQuery with <code>objEntityName</code> and <code>qualifier</code>
85      * parameters.
86      */

87     public DeleteQuery(String JavaDoc objEntityName, Expression qualifier) {
88         this.init(objEntityName, qualifier);
89     }
90
91     /**
92      * Calls "makeUpdate" on the visitor.
93      *
94      * @since 1.2
95      */

96     public SQLAction createSQLAction(SQLActionVisitor visitor) {
97         return visitor.updateAction(this);
98     }
99 }
100
Popular Tags