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: * Sun Public License Notice
022: *
023: * The contents of this file are subject to the Sun Public License
024: * Version 1.0 (the "License"). You may not use this file except in
025: * compliance with the License. A copy of the License is available at
026: * http://www.sun.com/
027: *
028: * The Original Code is NetBeans. The Initial Developer of the Original
029: * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
030: * Microsystems, Inc. All Rights Reserved.
031: */
032:
033: package org.netbeans.modules.sql.project.dbmodel;
034:
035: /**
036: * Class to hold resultset column metadata.
037: *
038: * @author Susan Chen
039: * @version
040: */
041: public class ResultSetColumn {
042: private String name = ""; // name of parameter
043: private String javaType; // Java type - ex. java.lang.String
044: private String sqlType; // SQL type - ex. BIGINT, NUMERIC
045: private int ordinalPosition; // ordinal position
046: private int numericPrecision; // numeric precision
047: private int numericScale; // numeric scale
048: private boolean isNullable; //specifies if the parameter is nullable
049: private String label = ""; // title of column in resultset
050:
051: /**
052: * Creates a new instance of ResultSetColumn.
053: */
054: public ResultSetColumn() {
055: name = "";
056: javaType = "";
057: sqlType = "";
058: ordinalPosition = 0;
059: numericPrecision = 0;
060: numericScale = 0;
061: isNullable = false;
062: }
063:
064: public ResultSetColumn(ResultSetColumn rs) {
065: name = rs.getName();
066: javaType = rs.getJavaType();
067: sqlType = rs.getSqlType();
068: ordinalPosition = rs.getOrdinalPosition();
069: numericPrecision = rs.getNumericPrecision();
070: numericScale = rs.getNumericScale();
071: isNullable = rs.getIsNullable();
072: label = rs.getLabel();
073: }
074:
075: /**
076: * Creates a new instance of ResultSetColumn with the given name.
077: *
078: * @param newName ResultSetColumn name
079: */
080: public ResultSetColumn(String newName) {
081: name = newName;
082: }
083:
084: /**
085: * Creates a new instance of ResultSetColum with the given attributes.
086: *
087: * @param newName ResultSetColumn name
088: * @param newJavaType Java type
089: */
090: public ResultSetColumn(String newName, String newJavaType) {
091: name = newName;
092: javaType = newJavaType;
093: }
094:
095: /**
096: * Creates a new instance of ResultSetColum with the given attributes.
097: *
098: * @param newName ResultSetColumn name
099: * @param newJavaType Java type
100: * @param newOrdinalPosition Ordinal position
101: * @param newNumericPrecision Numeric precision
102: * @param newNumericScale Numeric scale
103: * @param newIsNullable Nullable flag
104: */
105: public ResultSetColumn(String newName, String newJavaType,
106: int newOrdinalPosition, int newNumericPrecision,
107: int newNumericScale, boolean newIsNullable) {
108: name = newName;
109: javaType = newJavaType;
110: ordinalPosition = newOrdinalPosition;
111: numericPrecision = newNumericPrecision;
112: numericScale = newNumericScale;
113: isNullable = newIsNullable;
114: }
115:
116: /**
117: * Get the ResultSet column name.
118: *
119: * @return ResultSet column name.
120: */
121: public String getName() {
122: return name;
123: }
124:
125: /**
126: * Get the Java type.
127: *
128: * @return Java type
129: */
130: public String getJavaType() {
131: return javaType;
132: }
133:
134: /**
135: * Get the SQL type.
136: *
137: * @return SQL type
138: */
139: public String getSqlType() {
140: return sqlType;
141: }
142:
143: /**
144: * Get the ResultSet column ordinal position.
145: *
146: * @return ResultSet column ordinal position
147: */
148: public int getOrdinalPosition() {
149: return ordinalPosition;
150: }
151:
152: /**
153: * Get the ResultSet column numeric precision.
154: *
155: * @return ResultSet column numeric precision
156: */
157: public int getNumericPrecision() {
158: return numericPrecision;
159: }
160:
161: /**
162: * Get the ResultSet column numeric scale.
163: *
164: * @return ResultSet column numeric scale
165: */
166: public int getNumericScale() {
167: return numericScale;
168: }
169:
170: /**
171: * Get the ResultSet column nullable flag.
172: *
173: * @return ResultSet column nullable flag.
174: */
175: public boolean getIsNullable() {
176: return isNullable;
177: }
178:
179: /**
180: * Set the ResultSet column name.
181: *
182: * @param newName ResultSet column name
183: */
184: public void setName(String newName) {
185: name = newName;
186: }
187:
188: /**
189: * Set the ResultSet column Java type.
190: *
191: * @param newJavaType ResultSet column Java type.
192: */
193: public void setJavaType(String newJavaType) {
194: javaType = newJavaType;
195: }
196:
197: /**
198: * Set the ResultSet column SQL type.
199: *
200: * @param newSqlType ResultSet column SQL type.
201: */
202: public void setSqlType(String newSqlType) {
203: sqlType = newSqlType;
204: }
205:
206: /**
207: * Set the ResultSet column ordinal position.
208: *
209: * @param newOrdinalPosition ResultSet column ordinal position.
210: */
211: public void setOrdinalPosition(int newOrdinalPosition) {
212: ordinalPosition = newOrdinalPosition;
213: }
214:
215: /**
216: * Set the ResultSet column numeric precision.
217: *
218: * @param newNumericPrecision ResultSet column numeric precision.
219: */
220: public void setNumericPrecision(int newNumericPrecision) {
221: numericPrecision = newNumericPrecision;
222: }
223:
224: /**
225: * Set the ResultSet column numeric scale.
226: *
227: * @param newNumericScale ResultSet column numeric scale.
228: */
229: public void setNumericScale(int newNumericScale) {
230: numericScale = newNumericScale;
231: }
232:
233: /**
234: * Set the ResultSet column nullable flag.
235: *
236: * @param newIsNullable ResultSet column nullable flag
237: */
238: public void setIsNullable(boolean newIsNullable) {
239: isNullable = newIsNullable;
240: }
241:
242: /**
243: * Get the ResultSet column label.
244: *
245: * @return ResultSet column label.
246: */
247: public String getLabel() {
248: return label;
249: }
250:
251: /**
252: * Set the ResultSet column label.
253: *
254: * @param newName ResultSet column label
255: */
256: public void setLabel(String newName) {
257: label = newName;
258: }
259: }
|