KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > sqls > impl > StatementImpl


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

17 package org.apache.ws.jaxme.sqls.impl;
18
19 import org.apache.ws.jaxme.sqls.Case;
20 import org.apache.ws.jaxme.sqls.Column;
21 import org.apache.ws.jaxme.sqls.Function;
22 import org.apache.ws.jaxme.sqls.SQLFactory;
23 import org.apache.ws.jaxme.sqls.Statement;
24 import org.apache.ws.jaxme.sqls.Table;
25 import org.apache.ws.jaxme.sqls.TableReference;
26
27
28 /** <p>A common base class for {@link org.apache.ws.jaxme.sqls.SelectStatement},
29  * {@link org.apache.ws.jaxme.sqls.InsertStatement},
30  * {@link org.apache.ws.jaxme.sqls.UpdateStatement}, and
31  * {@link org.apache.ws.jaxme.sqls.DeleteStatement}.</p>
32  *
33  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
34  */

35 public abstract class StatementImpl implements Statement {
36   private SQLFactory factory;
37   private TableReference tableReference;
38   
39   protected StatementImpl(SQLFactory pFactory) {
40     factory = pFactory;
41   }
42   
43   public SQLFactory getSQLFactory() {
44     return factory;
45   }
46   
47   protected TableReference newTableReference(Table pTable) {
48     return new TableReferenceImpl(this, pTable);
49   }
50   
51   public TableReference setTable(Table pTable) {
52     if (pTable == null) {
53       throw new NullPointerException JavaDoc("The table on which the statement operates must not be null.");
54     }
55     if (tableReference != null) {
56       throw new IllegalStateException JavaDoc("The table on which the statement operates was already set.");
57     }
58     tableReference = newTableReference(pTable);
59     return tableReference;
60   }
61   
62   public TableReference getTableReference() {
63     return tableReference;
64   }
65   
66   public Function createFunction(String JavaDoc pName) {
67     return getSQLFactory().getObjectFactory().newFunction(this, pName);
68   }
69
70     public Case newCase(Column.Type pType) {
71         return getSQLFactory().getObjectFactory().newCase(pType);
72     }
73 }
74
Popular Tags