KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > dods > builder > generator > query > RDBRow


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: RDBRow.java,v 1.1 2004/09/03 13:42:41 sinisa Exp $
22  */

23 package com.lutris.dods.builder.generator.query;
24
25 /**
26  * An instance of RDBRow is returned by the QueryBuilder.getNextRow() method.
27  * An RDBRow contains RDBColumnValue objects corresponding to the
28  * RDBColumn objects used to construct the instance of QueryBuilder.
29  * in a particular table in the database.
30  * @see QueryBuilder
31  * @author Jay Gunter
32  */

33 public class RDBRow {
34     private RDBColumnValue[] values;
35
36     /**
37      * Constructor used only by QueryBuilder, never the application developer.
38      *
39      * @param vals the column values in the current row
40      * @see QueryBuilder
41      * author Jay Gunter
42      */

43     public RDBRow(RDBColumnValue[] vals) {
44         if (null == vals) {
45             values = new RDBColumnValue[0];
46         } else {
47             values = vals;
48         }
49     }
50
51     /**
52      * Returns an RDBColumnValue object for a column in the current row.
53      * Application developers are encouraged to use the
54      * RDBRow.get(RDBColumn) method instead because specifying the
55      * desired column value using RDBColumn is less error-prone
56      * than using an int offset into the columns.
57      *
58      * @return the value of the ith column
59      * @param i the index into the row of the column value desired.
60      * @exception InvalidRowColumnException If i is not a valid column number.
61      * @see QueryBuilder
62      * author Jay Gunter
63      */

64     public RDBColumnValue get(int i)
65         throws InvalidRowColumnException {
66         if (!(0 <= i && i < values.length)) {
67             throw new InvalidRowColumnException("" + i);
68         }
69         return values[i];
70     }
71
72     /**
73      * Returns an RDBColumnValue object for a column in the current row.
74      * This is the preferred method for use by application developers.
75      *
76      * @return the value of the specified column
77      * @param col the column value desired.
78      * @exception InvalidRowColumnException
79      * If col is not a valid column in the row.
80      * @see QueryBuilder
81      * author Jay Gunter
82      */

83     public RDBColumnValue get(RDBColumn col)
84         throws InvalidRowColumnException {
85         if (null == col) {
86             throw new InvalidRowColumnException("Null RDBColumn");
87         }
88         for (int i = 0; i < values.length; i++) {
89             if (values[i].equals(col)) {
90                 return values[i];
91             }
92         }
93         throw new InvalidRowColumnException(col.getFullColumnName());
94     }
95 }
96
Popular Tags