KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mapper > storage > DocumentExplorer


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 /*
24  * DocumentExplorer.java
25  *
26  * Created on 18 avril 2002, 17:15
27  */

28
29 package org.xquark.mapper.storage;
30
31 import java.sql.SQLException JavaDoc;
32
33 import org.xquark.mapper.RepositoryException;
34 import org.xquark.mapper.dbms.AbstractConnection;
35 import org.xquark.mapper.mapping.MappingSetIterator;
36 import org.xquark.mapper.metadata.CollectionMappingInfo;
37 import org.xquark.xml.xdbc.XMLDBCException;
38
39 /**
40  *
41  */

42 class DocumentExplorer extends TableExplorer
43 {
44     private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
45     private static final String JavaDoc RCSName = "$Name: $";
46     
47     private DocumentTuple[] docTuples;
48     private DocumentStructExplorer docNode;
49     private DocumentExtraDataExplorer docExtraNode;
50     
51     /** Creates a new instance of QueryExplorer */
52     public DocumentExplorer(_RepositoryCollection collection) throws SQLException JavaDoc, XMLDBCException
53     {
54         super(collection);
55         
56         wNode = docNode = new DocumentStructExplorer(collection.getMetadata());
57         extraNode = docExtraNode = new DocumentExtraDataExplorer(collection.getMetadata());
58         
59         // tuples creation
60
tuples = docTuples = new DocumentTuple[collection.getMetadata().getMappingStatementsCount()];
61         MappingSetIterator it = collection.getMetadata().getMappingSetIterator();
62         CollectionMappingInfo table;
63         
64         while (it.hasNext())
65         {
66             table = (CollectionMappingInfo)it.next();
67             docTuples[table.getTableMapping().getTableIndex()] =
68                 new DocumentTuple(table);
69         }
70     }
71     
72     public void initDocReading(AbstractConnection connection) throws SQLException JavaDoc, RepositoryException
73     {
74         // Table subset browsing for statement execution
75
for (int i = 0; i < tuples.length; i++)
76         {
77             docTuples[i].init(connection, collection.getMetadata());
78         }
79         
80         docNode.initDocReading(connection);
81         docExtraNode.initDocReading(connection);
82     }
83     
84     public void initDocumentExploration(String JavaDoc ID) throws SQLException JavaDoc, RepositoryException
85     {
86         // Table subset browsing for statement execution
87
for (int i = 0; i < tuples.length; i++)
88         {
89             docTuples[i].execQuery(ID);
90         }
91         
92         // initialize structure retrieval
93
docNode.getDocument(ID);
94         docExtraNode.getDocument(ID);
95     }
96     
97 }
98
Popular Tags