KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > xquery > xdbc > PathSetXMLDocument


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.xquery.xdbc;
24
25 import java.io.IOException JavaDoc;
26
27 import org.xml.sax.XMLReader JavaDoc;
28 import org.xquark.xml.xdbc.XMLCollection;
29 import org.xquark.xml.xdbc.XMLDBCException;
30 import org.xquark.xpath.XTree;
31 import org.xquark.xpath.XTreeReader;
32
33 public class PathSetXMLDocument extends AbstractXMLDocument {
34     private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
35     private static final String JavaDoc RCSName = "$Name: $";
36     private XTree pathSet;
37     
38     public PathSetXMLDocument(String JavaDoc collectionName, XTree pathSet)
39     {
40         super(collectionName, true);
41         this.pathSet = pathSet;
42     }
43     
44     public PathSetXMLDocument(String JavaDoc collectionName, XMLCollection collection, XTree pathSet)
45     {
46         super(collectionName, collection, true);
47         this.pathSet = pathSet;
48     }
49     
50     /**
51      * Returns the document content as a SAX2 event flow.
52      * This method uses the various SAX2 handlers set by the setXXXHandler() methods.
53      * <P>*** ONLY FOR SAX2 ***</P>
54      * @throws XMLDBCException if a data source access error occurs
55      * or if the user has not set a content handler.
56      * @throws org.xml.sax.SAXException if a handler exception occurs.
57      */

58     public void getAsSAX() throws XMLDBCException, org.xml.sax.SAXException JavaDoc
59     {
60         XMLReader JavaDoc reader = new XTreeReader(pathSet);
61         plugHandlers(reader);
62         try {
63             reader.parse(getIdentifier());
64         }
65         catch (IOException JavaDoc e) {
66             // TO IMPROVE
67
throw new XMLDBCException("IOException while reading document.", e);
68         }
69     }
70     
71 }
72
Popular Tags