KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mediator > plan > PlanResultSet


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.mediator.plan;
24
25 import org.xml.sax.ContentHandler JavaDoc;
26 import org.xquark.mediator.runtime.MediatorException;
27 import org.xquark.schema.validation.PSVInfoSetProvider;
28 import org.xquark.xml.xdbc.XMLDBCException;
29 import org.xquark.xquery.xdbc.XDBCResultSetInterface;
30
31 public class PlanResultSet implements XDBCResultSetInterface {
32     // **********************************************************************
33
// * VERSIONING
34
// **********************************************************************
35
private static final String JavaDoc RCSRevision = "$Revision: 1.10 $";
36     private static final String JavaDoc RCSName = "$Name: $";
37     // **********************************************************************
38
// * CLASS VARIABLES
39
// **********************************************************************
40
protected ContentHandler JavaDoc handler = null;
41     protected org.xml.sax.ErrorHandler JavaDoc error_handler = null;
42     protected org.xml.sax.ext.LexicalHandler JavaDoc lexical_handler = null;
43
44     protected ResultSet opResultset;
45
46     // ***********************************************************************
47
// * INITIALIZATION
48
// ***********************************************************************
49
/**
50      *
51      */

52     public PlanResultSet(ResultSet opResultset) throws XMLDBCException {
53         this.opResultset = opResultset;
54     }
55
56     // ***********************************************************************
57
// * XDBCResultSetInterface IMPLEMENTATION
58
// ***********************************************************************
59
/**
60      * Return the value of the element specified by the path.
61      * @param path
62      * @param nodeAccessor
63      * @param loopID the ID of the loop concerned if any
64      * @return value of the element
65      * @throws XDBCException if a database access error occurs.
66      */

67     public String JavaDoc fetch(String JavaDoc path, int nodeAccessor) throws XMLDBCException {
68         return fetch(path, nodeAccessor, null);
69     }
70     public String JavaDoc fetch(String JavaDoc path, int nodeAccessor, String JavaDoc loopID) throws XMLDBCException {
71         return fetch(path, nodeAccessor, loopID, null);
72     }
73     public String JavaDoc fetch(String JavaDoc path, int nodeAccessor, String JavaDoc loopID, PSVInfoSetProvider psvisp) throws XMLDBCException {
74         return opResultset.fetch(path, nodeAccessor, loopID, psvisp);
75     }
76
77     /**
78      * Generate the value of the result set specified by the path in the handler.
79      * @param path
80      * @param nodeAccessor the type of node to be generated
81      * @param loopID the ID of the loop concerned if any
82      * @throws XDBCException if a database access error occurs.
83      */

84     public void generate(String JavaDoc path, int nodeAccessor) throws XMLDBCException {
85         generate(path, nodeAccessor, null);
86     }
87     public void generate(String JavaDoc path, int nodeAccessor, String JavaDoc loopID) throws XMLDBCException {
88         generate(path, nodeAccessor, loopID, null);
89     }
90     public void generate(String JavaDoc path, int nodeAccessor, String JavaDoc loopID, PSVInfoSetProvider psvisp) throws XMLDBCException {
91         opResultset.generate(handler, path, nodeAccessor, loopID, psvisp);
92     }
93
94     /**
95      * Recover the identifiers of the current result set and stores them in the table <I>identifiers</I>.
96      * @param identifiers the table of identifiers
97      * @throws XDBCException if a database access error occurs.
98      */

99     public void getIdentifiers(Object JavaDoc[] identifiers) throws XMLDBCException {
100         opResultset.getIdentifiers(identifiers);
101     }
102
103     /**
104      * Recover the identifiers of the next result set and stores them in the table <I>identifiers</I>.
105      * @param identifiers the table of identifiers
106      * @throws XDBCException if a database access error occurs.
107      */

108     public void getNextIdentifiers(Object JavaDoc[] identifiers) throws XMLDBCException {
109         try {
110             opResultset.getNextIdentifiers(identifiers);
111         } catch (MediatorException me) {
112             throw new XMLDBCException(me.getMessage(), me);
113         }
114     }
115
116     /**
117      * Give the new current result set (the next one).
118      * @return true if the new current result set is valid, false otherwise
119      * @throws XDBCException if a database access error occurs.
120      */

121     public boolean next() throws XMLDBCException {
122         try {
123             opResultset.next();
124         } catch (MediatorException me) {
125             throw new XMLDBCException(me.getMessage(), me);
126         }
127         return true;
128     }
129
130     /**
131      * Returns true if the result set has more elements.
132      * @return true if the result set has more elements, false otherwise
133      */

134     public boolean hasNext() throws XMLDBCException {
135         try {
136             return opResultset.hasNext();
137         } catch (MediatorException me) {
138             throw new XMLDBCException(me.getMessage(), me);
139         }
140     }
141
142     /**
143      * To set a content handler (SAX 2) to intercept events produce when retrieves results by SAX 2 way.
144      * @param handler the content handler implementation (see org.xml.sax.ContentHandler)
145      * @throws XDBCException if a database access error occurs.
146      */

147     public void setContentHandler(ContentHandler JavaDoc handler) {
148         this.handler = handler;
149     }
150
151     /**
152      * To set a content handler (SAX 2) to intercept events produce when
153      * retrieves results by SAX 2 way.
154      * @param handler the error handler implementation
155      * (see org.xml.sax.ErrorHan dler)
156      * @throws XDBCException if a database access error occurs.
157      */

158     public void setErrorHandler(org.xml.sax.ErrorHandler JavaDoc handler) {
159         this.error_handler = handler;
160     }
161
162     /**
163      * To set a lexical handler (SAX 2) to intercept events produce when
164      * retrieves results by SAX 2 way.
165      * @param handler the lexical handler implementation
166      * (see org.xml.sax.ext.LexicalHandler)
167      * @throws XDBCException if a database access error occurs.
168      */

169     public void setLexicalHandler(org.xml.sax.ext.LexicalHandler JavaDoc handler) {
170         this.lexical_handler = handler;
171     }
172
173     /**
174      * close the associated algresultset
175      * @throws XMLDBCException if a data source access error occurs.
176      */

177     public void close() throws XMLDBCException {
178         try {
179             opResultset.close();
180         } catch (MediatorException me) {
181             throw new XMLDBCException(me.getMessage(), me);
182         }
183     }
184 }
185
Popular Tags