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