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 parameter metadata.
037: *
038: * @author Susan Chen
039: * @version
040: */
041: public class Parameter {
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 String paramType; // parameter type description: IN, INOUT, OUT, RETURN, RESULT
046: private int ordinalPosition; // ordinal position
047: private int numericPrecision; // numeric precision
048: private int numericScale; // numeric scale
049: private boolean isNullable; //specifies if the parameter is nullable
050:
051: /**
052: * Creates an instance of Paramter.
053: */
054: public Parameter() {
055: name = "";
056: javaType = "";
057: sqlType = "";
058: paramType = "";
059: ordinalPosition = 0;
060: numericPrecision = 0;
061: numericScale = 0;
062: isNullable = false;
063: }
064:
065: /**
066: * Creates an instance of Parameter with the given name.
067: *
068: * @param newName Parameter name
069: */
070: public Parameter(String newName) {
071: name = newName;
072: }
073:
074: /**
075: * Creates an instance of Parameter with the given name and java type.
076: *
077: * @param newName Parameter name
078: * @param newJavaType Java type
079: */
080: public Parameter(String newName, String newJavaType) {
081: name = newName;
082: javaType = newJavaType;
083: }
084:
085: /**
086: * Creates an instance of Parameter with the given attributes.
087: *
088: * @param newName Parameter name
089: * @param newJavaType Java type
090: * @param newParamType Parameter type
091: * @param newOrdinalPosition Ordinal position
092: * @param newNumericPrecision Numeric precision
093: * @param newNumericScale Numeric scale
094: * @param newIsNullable Nullable flag
095: */
096: public Parameter(String newName, String newJavaType,
097: String newParamType, int newOrdinalPosition,
098: int newNumericPrecision, int newNumericScale,
099: boolean newIsNullable) {
100: name = newName;
101: javaType = newJavaType;
102: paramType = newParamType;
103: ordinalPosition = newOrdinalPosition;
104: numericPrecision = newNumericPrecision;
105: numericScale = newNumericScale;
106: isNullable = newIsNullable;
107: }
108:
109: public Parameter(Parameter p) {
110: name = p.getName();
111: javaType = p.getJavaType();
112: sqlType = p.getSqlType();
113: paramType = p.getParamType();
114: ordinalPosition = p.getOrdinalPosition();
115: numericPrecision = p.getNumericPrecision();
116: numericScale = p.getNumericScale();
117: isNullable = p.getIsNullable();
118: }
119:
120: /**
121: * Get the parameter name.
122: *
123: * @return parameter name
124: */
125: public String getName() {
126: return name;
127: }
128:
129: /**
130: * Get the Java type.
131: *
132: * @return Java type
133: */
134: public String getJavaType() {
135: return javaType;
136: }
137:
138: /**
139: * Get the SQL type.
140: *
141: * @return SQL type
142: */
143: public String getSqlType() {
144: return sqlType;
145: }
146:
147: /**
148: * Get the parameter type.
149: *
150: * @return Parameter type
151: */
152: public String getParamType() {
153: return paramType;
154: }
155:
156: /**
157: * Get the parameter ordinal position.
158: *
159: * @return Parameter ordinal position
160: */
161: public int getOrdinalPosition() {
162: return ordinalPosition;
163: }
164:
165: /**
166: * Get the parameter numeric precision.
167: *
168: * @return Parameter numeric precision.
169: */
170: public int getNumericPrecision() {
171: return numericPrecision;
172: }
173:
174: /**
175: * Get the parameter numeric scale.
176: *
177: * @return Parameter numeric scale.
178: */
179: public int getNumericScale() {
180: return numericScale;
181: }
182:
183: /**
184: * Get the parameter nullable flag.
185: *
186: * @return Parameter nullable flag.
187: */
188: public boolean getIsNullable() {
189: return isNullable;
190: }
191:
192: /**
193: * Set the parameter name.
194: *
195: * @param newName Parameter name
196: */
197: public void setName(String newName) {
198: name = newName;
199: }
200:
201: /**
202: * Set the parameter Java type.
203: *
204: * @param newJavaType Parameter Java type.
205: */
206: public void setJavaType(String newJavaType) {
207: javaType = newJavaType;
208: }
209:
210: /**
211: * Set the parameter SQL type.
212: *
213: * @param newSqlType Parameter SQL type.
214: */
215: public void setSqlType(String newSqlType) {
216: sqlType = newSqlType;
217: }
218:
219: /**
220: * Set the parameter type.
221: *
222: * @param newParamType Parameter type.
223: */
224: public void setParamType(String newParamType) {
225: paramType = newParamType;
226: }
227:
228: /**
229: * Set the parameter ordinal position.
230: *
231: * @param newOrdinalPosition Parameter ordinal Position.
232: */
233: public void setOrdinalPosition(int newOrdinalPosition) {
234: ordinalPosition = newOrdinalPosition;
235: }
236:
237: /**
238: * Set the parameter numeric position.
239: *
240: * @param newNumericPrecision Parameter numeric precision
241: */
242: public void setNumericPrecision(int newNumericPrecision) {
243: numericPrecision = newNumericPrecision;
244: }
245:
246: /**
247: * Set the parameter numeric scale.
248: *
249: * @param newNumericScale Parameter numeric scale
250: */
251: public void setNumericScale(int newNumericScale) {
252: numericScale = newNumericScale;
253: }
254:
255: /**
256: * Set the parameter nullable flag.
257: *
258: * @param newIsNullable Parameter nullable flag
259: */
260: public void setIsNullable(boolean newIsNullable) {
261: isNullable = newIsNullable;
262: }
263:
264: /*public int getAccessType() {
265: if (getParamType().equals("IN")) {
266: return OtdLeaf.Access.WRITE;
267: }
268: if (getParamType().equals("INOUT")) {
269: return OtdLeaf.Access.MODIFY;
270: }
271: return OtdLeaf.Access.READ;
272: }*/
273: }
|