KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > support > sqlstore > sql > generator > ColumnRef


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * ColumnRef.java
26  *
27  * Create on March 3, 2000
28  *
29  */

30
31 package com.sun.jdo.spi.persistence.support.sqlstore.sql.generator;
32
33 import org.netbeans.modules.dbschema.ColumnElement;
34 import com.sun.jdo.api.persistence.support.FieldMapping;
35
36 /**
37  */

38 public class ColumnRef extends Object JavaDoc implements FieldMapping {
39     //
40
// actual ColumnElement from the dbmodel
41
//
42
private ColumnElement columnElement;
43
44     //
45
// the table this column belongs to
46
//
47
private QueryTable table;
48
49     //
50
// input value for this column for update statements.
51
// This field contains LocalFieldDesc for the corresponding field when
52
// an UpdateStatement using batching uses this field.
53
//
54
private Object JavaDoc value;
55
56     //
57
// the position of this column in the SQL statement
58
//
59
private int index;
60
61     //
62
// the name of this column
63
//
64
private String JavaDoc name;
65
66     public ColumnRef(ColumnElement columnElement,
67                      QueryTable table) {
68         this.columnElement = columnElement;
69         name = columnElement.getName().getName();
70         this.table = table;
71     }
72
73     public ColumnRef(ColumnElement columnElement,
74                      Object JavaDoc value) {
75         this.columnElement = columnElement;
76         name = columnElement.getName().getName();
77         this.value = value;
78     }
79
80     /** Return the actual ColumnElement associated with this column.
81      * @return the ColumnElement associated with this
82      */

83     public ColumnElement getColumnElement() {
84         return columnElement;
85     }
86
87     /** Return the position of this column in the SQL statement.
88      * @return the position of this column in the SQL statement
89      */

90     public int getIndex() {
91         return index;
92     }
93
94     /** Set the position of this column in the SQL statement.
95      * @param value - the new position
96      */

97     public void setIndex(int value) {
98         this.index = value;
99     }
100
101     /** Return the input value for this column.
102      * @return the input value for this column
103      */

104     public Object JavaDoc getValue() {
105         return value;
106     }
107
108     /** Return the QueryTable associated with this column.
109      * @return the QueryTable associated with this column.
110      */

111     public QueryTable getQueryTable() {
112         return table;
113     }
114
115     /** Return the name of this column.
116      * @return the name of this column.
117      */

118     public String JavaDoc getName() {
119         return name;
120     }
121
122      //---- implementing FieldMapping ------------------------------//
123
/**
124       * This method return int corresponding to java.sql.Types.
125       */

126      public int getColumnType() {
127          return columnElement.getType();
128      }
129
130      /**
131       * This method return the name of the column.
132       */

133      public String JavaDoc getColumnName() {
134          return name;
135      }
136
137      /**
138       * This method return the length of the column and -1 if unknown.
139       */

140      public int getColumnLength() {
141          Integer JavaDoc len = columnElement.getLength();
142          return (len != null) ? len.intValue(): -1;
143      }
144
145      //---- end of implementing FieldMapping -----------------------//
146
}
147
Popular Tags