KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Iterator JavaDoc;
20
21 import org.apache.ws.jaxme.sqls.Column;
22 import org.apache.ws.jaxme.sqls.Index;
23 import org.apache.ws.jaxme.sqls.Table;
24
25
26 /** <p>Implementation of a column.</p>
27  *
28  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
29  */

30 public class ColumnImpl extends AbstractColumn {
31   public static class NameImpl extends SQLFactoryImpl.IdentImpl implements Column.Name {
32     public NameImpl(String JavaDoc pName) {
33       super(pName);
34     }
35     public boolean equals(Object JavaDoc o) {
36       return o != null && (o instanceof Column.Name) && super.equals(o);
37     }
38   }
39   public static class TypeImpl extends SQLFactoryImpl.IdentImpl implements Column.Type {
40     private int jdbcType;
41     public TypeImpl(String JavaDoc pName, int pJDBCType) {
42       super(pName);
43       jdbcType = pJDBCType;
44     }
45     public int getJDBCType() {
46       return jdbcType;
47     }
48   }
49
50
51   private Table table;
52
53   protected ColumnImpl(Table pTable, Column.Name pName, Column.Type pType) {
54     super(pName, pType);
55     table = pTable;
56   }
57
58   public Table getTable() { return table; }
59   public String JavaDoc getQName() { return getTable().getQName() + "." + getName(); }
60   public boolean isVirtual() { return false; }
61
62   public boolean isPrimaryKeyPart() {
63     Index index = getTable().getPrimaryKey();
64     if (index == null) {
65       return false;
66     }
67     for (Iterator JavaDoc iter = index.getColumns(); iter.hasNext(); ) {
68       Column column = (Column) iter.next();
69       if (column.equals(this)) {
70         return true;
71       }
72     }
73     return false;
74   }
75 }
76
Popular Tags