KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > servlets > reports > JRDataSourceRSV


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/servlets/reports/JRDataSourceRSV.java,v 1.19 2004/10/24 13:47:30 hkollmann Exp $
3  * $Revision: 1.19 $
4  * $Date: 2004/10/24 13:47:30 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */

23
24 package org.dbforms.servlets.reports;
25
26 import net.sf.jasperreports.engine.JRException;
27
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30
31 import org.dbforms.config.ResultSetVector;
32 import java.util.Map JavaDoc;
33
34 /**
35  * use a ResultSetVector as data source.
36  */

37 public final class JRDataSourceRSV extends JRDataSourceAbstract {
38     private static Log logCat = LogFactory.getLog(JRDataSourceRSV.class
39             .getName());
40
41     private ResultSetVector rsv;
42     /**
43      * Constructor for JRDataSourceRSV.
44      *
45      * @param rsv
46      * DOCUMENT ME!
47      * @param pageContext
48      * DOCUMENT ME!
49      */

50     public JRDataSourceRSV(Map JavaDoc attributes, ResultSetVector rsv) {
51         super(attributes);
52         this.rsv = rsv;
53         this.rsv.moveFirst();
54         // Set the pointer to one place before the first record
55
// Retriving data for JRDataSource will start with a moveNext!
56
this.rsv.movePrevious();
57     }
58
59     /**
60      * @see net.sf.jasperreports.engine.JRDataSource#next()
61      */

62     public boolean next() throws JRException {
63         if (ResultSetVector.isNull(rsv)) {
64             return false;
65         }
66         if (rsv.isLast()) {
67             return false;
68         }
69         rsv.moveNext();
70         return true;
71     }
72
73     public Object JavaDoc getFieldValue(String JavaDoc fieldName) {
74         Object JavaDoc o = null;
75         try {
76             o = rsv.getFieldAsObject(fieldName);
77         } catch (Exception JavaDoc e) {
78             logCat.error("getFieldValue", e);
79         }
80         return o;
81     }
82
83 }
84
Popular Tags