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: /**
034: ** This class represents a parameter in a stored procedure which is a resultset.
035: ** It is named ResultSetColumns to avoid confusing it with the jdbc resultset.
036: **/package org.netbeans.modules.sql.project.dbmodel;
037:
038: import java.util.ArrayList;
039:
040: public class ResultSetColumns {
041: private ArrayList columns = null;
042:
043: /**
044: ** Holds the name of the ResultSet
045: **/
046: private String name = null;
047:
048: /**
049: ** constructor
050: **/
051: public ResultSetColumns() {
052: this .columns = new ArrayList();
053: }
054:
055: /** getter for name;
056: * @return name;
057: */
058: public String getName() {
059: return name;
060: }
061:
062: /** setter for name;
063: ** @param name
064: */
065: public void setName(String rsName) {
066: this .name = rsName;
067: }
068:
069: /** getter for numColumns;
070: ** @return numColumns;
071: **/
072: public int getNumColumns() {
073: return this .columns.size();
074: }
075:
076: /** getter for columns;
077: * @return columns;
078: */
079: public ArrayList getColumns() {
080: return columns;
081: }
082:
083: /** setter for columns;
084: * @param columns list of <code>ResultSetColumn</code>
085: ** objects;
086: */
087: public void setColumns(ArrayList columns) {
088: this .columns = columns;
089: }
090:
091: /** adds a ResultsetColumn object to this list.
092: * @param rsCol <code>ResultSetColumn</code>
093: ** object that needs to be added;
094: */
095: public void add(ResultSetColumn rsCol) {
096: if (rsCol != null) {
097: this .columns.add(rsCol);
098: }
099: }
100:
101: /** gets the ResultsetColumn object at the given index.
102: * @param index index of <code>ResultSetColumn</code>
103: ** object that needs to be retrieved;
104: */
105: public ResultSetColumn get(int index) {
106: return (ResultSetColumn) this .columns.get(index);
107: }
108:
109: /** removes the given ResultSetColumn from the list
110: * @param rsCol <code>ResultSetColumn</code>
111: ** object that needs to be removed;
112: * @returns true if the Object is in the list & is succesfully removed,
113: * false otherwise.
114: */
115: public boolean remove(ResultSetColumn rsCol) {
116: Object removedRSCol = new Object();
117: int remIndex = this .columns.indexOf(rsCol);
118: if (remIndex != -1) {
119: removedRSCol = this .columns.remove(remIndex);
120: }
121: return removedRSCol.equals(rsCol);
122: }
123:
124: /** removes a ResultSetColumn from the list at the given index
125: * @param index index at which the
126: ** object that needs to be removed was set;
127: * @returns true if the Object is in the list & is succesfully removed,
128: * false otherwise.
129: */
130: public boolean remove(int index) {
131: Object removedRSCol = null;
132: removedRSCol = this.columns.remove(index);
133: return (removedRSCol != null);
134: }
135:
136: }
|