001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: /*
021: *
022: * Copyright 2005 Sun Microsystems, Inc.
023: *
024: * Licensed under the Apache License, Version 2.0 (the "License");
025: * you may not use this file except in compliance with the License.
026: * You may obtain a copy of the License at
027: *
028: * http://www.apache.org/licenses/LICENSE-2.0
029: *
030: * Unless required by applicable law or agreed to in writing, software
031: * distributed under the License is distributed on an "AS IS" BASIS,
032: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
033: * See the License for the specific language governing permissions and
034: * limitations under the License.
035: *
036: */
037: package org.netbeans.modules.jdbcwizard.builder;
038:
039: /**
040: * Class to hold resultset column metadata.
041: *
042: * @author
043: */
044: public class ResultSetColumn {
045: private String name = ""; // name of parameter
046:
047: private String javaType; // Java type - ex. java.lang.String
048:
049: private String sqlType; // SQL type - ex. BIGINT, NUMERIC
050:
051: private int ordinalPosition; // ordinal position
052:
053: private int numericPrecision; // numeric precision
054:
055: private int numericScale; // numeric scale
056:
057: private boolean isNullable; // specifies if the parameter is nullable
058:
059: private String label = ""; // title of column in resultset
060:
061: /**
062: * Creates a new instance of ResultSetColumn.
063: */
064: public ResultSetColumn() {
065: this .name = "";
066: this .javaType = "";
067: this .sqlType = "";
068: this .ordinalPosition = 0;
069: this .numericPrecision = 0;
070: this .numericScale = 0;
071: this .isNullable = false;
072: }
073:
074: public ResultSetColumn(final ResultSetColumn rs) {
075: this .name = rs.getName();
076: this .javaType = rs.getJavaType();
077: this .sqlType = rs.getSqlType();
078: this .ordinalPosition = rs.getOrdinalPosition();
079: this .numericPrecision = rs.getNumericPrecision();
080: this .numericScale = rs.getNumericScale();
081: this .isNullable = rs.getIsNullable();
082: this .label = rs.getLabel();
083: }
084:
085: /**
086: * Creates a new instance of ResultSetColumn with the given name.
087: *
088: * @param newName ResultSetColumn name
089: */
090: public ResultSetColumn(final String newName) {
091: this .name = newName;
092: }
093:
094: /**
095: * Creates a new instance of ResultSetColum with the given attributes.
096: *
097: * @param newName ResultSetColumn name
098: * @param newJavaType Java type
099: */
100: public ResultSetColumn(final String newName,
101: final String newJavaType) {
102: this .name = newName;
103: this .javaType = newJavaType;
104: }
105:
106: /**
107: * Creates a new instance of ResultSetColum with the given attributes.
108: *
109: * @param newName ResultSetColumn name
110: * @param newJavaType Java type
111: * @param newOrdinalPosition Ordinal position
112: * @param newNumericPrecision Numeric precision
113: * @param newNumericScale Numeric scale
114: * @param newIsNullable Nullable flag
115: */
116: public ResultSetColumn(final String newName,
117: final String newJavaType, final int newOrdinalPosition,
118: final int newNumericPrecision, final int newNumericScale,
119: final boolean newIsNullable) {
120: this .name = newName;
121: this .javaType = newJavaType;
122: this .ordinalPosition = newOrdinalPosition;
123: this .numericPrecision = newNumericPrecision;
124: this .numericScale = newNumericScale;
125: this .isNullable = newIsNullable;
126: }
127:
128: /**
129: * Get the ResultSet column name.
130: *
131: * @return ResultSet column name.
132: */
133: public String getName() {
134: return this .name;
135: }
136:
137: /**
138: * Get the Java type.
139: *
140: * @return Java type
141: */
142: public String getJavaType() {
143: return this .javaType;
144: }
145:
146: /**
147: * Get the SQL type.
148: *
149: * @return SQL type
150: */
151: public String getSqlType() {
152: return this .sqlType;
153: }
154:
155: /**
156: * Get the ResultSet column ordinal position.
157: *
158: * @return ResultSet column ordinal position
159: */
160: public int getOrdinalPosition() {
161: return this .ordinalPosition;
162: }
163:
164: /**
165: * Get the ResultSet column numeric precision.
166: *
167: * @return ResultSet column numeric precision
168: */
169: public int getNumericPrecision() {
170: return this .numericPrecision;
171: }
172:
173: /**
174: * Get the ResultSet column numeric scale.
175: *
176: * @return ResultSet column numeric scale
177: */
178: public int getNumericScale() {
179: return this .numericScale;
180: }
181:
182: /**
183: * Get the ResultSet column nullable flag.
184: *
185: * @return ResultSet column nullable flag.
186: */
187: public boolean getIsNullable() {
188: return this .isNullable;
189: }
190:
191: /**
192: * Set the ResultSet column name.
193: *
194: * @param newName ResultSet column name
195: */
196: public void setName(final String newName) {
197: this .name = newName;
198: }
199:
200: /**
201: * Set the ResultSet column Java type.
202: *
203: * @param newJavaType ResultSet column Java type.
204: */
205: public void setJavaType(final String newJavaType) {
206: this .javaType = newJavaType;
207: }
208:
209: /**
210: * Set the ResultSet column SQL type.
211: *
212: * @param newSqlType ResultSet column SQL type.
213: */
214: public void setSqlType(final String newSqlType) {
215: this .sqlType = newSqlType;
216: }
217:
218: /**
219: * Set the ResultSet column ordinal position.
220: *
221: * @param newOrdinalPosition ResultSet column ordinal position.
222: */
223: public void setOrdinalPosition(final int newOrdinalPosition) {
224: this .ordinalPosition = newOrdinalPosition;
225: }
226:
227: /**
228: * Set the ResultSet column numeric precision.
229: *
230: * @param newNumericPrecision ResultSet column numeric precision.
231: */
232: public void setNumericPrecision(final int newNumericPrecision) {
233: this .numericPrecision = newNumericPrecision;
234: }
235:
236: /**
237: * Set the ResultSet column numeric scale.
238: *
239: * @param newNumericScale ResultSet column numeric scale.
240: */
241: public void setNumericScale(final int newNumericScale) {
242: this .numericScale = newNumericScale;
243: }
244:
245: /**
246: * Set the ResultSet column nullable flag.
247: *
248: * @param newIsNullable ResultSet column nullable flag
249: */
250: public void setIsNullable(final boolean newIsNullable) {
251: this .isNullable = newIsNullable;
252: }
253:
254: /**
255: * Get the ResultSet column label.
256: *
257: * @return ResultSet column label.
258: */
259: public String getLabel() {
260: return this .label;
261: }
262:
263: /**
264: * Set the ResultSet column label.
265: *
266: * @param newName ResultSet column label
267: */
268: public void setLabel(final String newName) {
269: this.label = newName;
270: }
271: }
|