KickJava   Java API By Example, From Geeks To Geeks.

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


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.JoinReference;
20 import org.apache.ws.jaxme.sqls.SelectStatement;
21 import org.apache.ws.jaxme.sqls.SelectTableReference;
22 import org.apache.ws.jaxme.sqls.Table;
23
24 /**
25  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
26  */

27 public class SelectTableReferenceImpl extends TableReferenceImpl implements SelectTableReference {
28    private JoinReference joinReference;
29
30     /** <p>Creates a new instance of SelectTableReferenceImpl referencing
31     * the given {@link SelectStatement}.</p>
32      */

33     public SelectTableReferenceImpl(SelectStatement pStatement, Table pTable) {
34         super(pStatement, pTable);
35     }
36
37     public JoinReference join(Table pTable) {
38       if (joinReference != null) {
39         throw new IllegalStateException JavaDoc("The table is already involved in a left join.");
40       }
41       joinReference = getStatement().getSQLFactory().getObjectFactory().newJoinReference(this, pTable, false);
42       return joinReference;
43     }
44     
45     public JoinReference leftOuterJoin(Table pTable) {
46       if (joinReference != null) {
47         throw new IllegalStateException JavaDoc("The table is already involved in a left join.");
48       }
49       joinReference = getStatement().getSQLFactory().getObjectFactory().newJoinReference(this, pTable, true);
50       return joinReference;
51     }
52     
53     public SelectStatement getSelectStatement() {
54       return (SelectStatement) getStatement();
55     }
56     
57     public JoinReference getRightJoinedTableReference() {
58       return joinReference;
59     }
60 }
61
Popular Tags