KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > xml > xdbc > DefaultReadOnlyXMLConnection


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.xml.xdbc;
24
25 /**
26  * A default implementation of XMLConnection for read-only connections
27  */

28 public abstract class DefaultReadOnlyXMLConnection implements XMLConnection {
29  
30
31
32   /** Creates a new instance of DefaultReadOnlyXMLConnection */
33     public DefaultReadOnlyXMLConnection() {
34     }
35
36     /**
37      * Makes all changes made since the previous commit/rollback
38      * permanent and releases any data source locks currently
39      * held by the connection. This method has no effect when
40      * auto-commit mode has been enabled.
41      * @throws XMLDBCException if a data source access error occurs.
42      * @throws XMLDBCNotSupportedException if the data source does not support transactions
43      */

44     public void commit() throws XMLDBCException, XMLDBCNotSupportedException {
45       throw new XMLDBCNotSupportedException("Read-only connection does not support transactions");
46     }
47     
48     /**
49      * To create a new XML collection. Each XML collections can be configured.
50      * @param name the unique name of the new XML collection.
51      * @param description the description of the new XML collection (optional).
52      * @param config a XML collection configuration. If null, the XML collection will be created with default configuration.
53      * @return an instance of XML collection.
54      * @throws XMLDBCException if a data source access error occurs or if the XML collection name already exists.
55      * @throws XMLDBCNotSupportedException if the data source does not support this operation (typically, when the data source is read-only)
56      */

57     public XMLCollection createCollection(String JavaDoc name, String JavaDoc description, Configurable config) throws XMLDBCException, XMLDBCNotSupportedException {
58       throw new XMLDBCNotSupportedException("Read-only connection does not support collection management");
59     }
60     
61     /**
62      * To create a new XML Collection configuration for set features and properties before create a XML Collection.
63      * @return a XML Collection config.
64      * @throws XMLDBCException if a data source access error occurs.
65      * @throws XMLDBCNotSupportedException if the data source does not support this operation (typically, when the data source is read-only)
66      */

67     public Configurable createCollectionConfig() throws XMLDBCException, XMLDBCNotSupportedException {
68       throw new XMLDBCNotSupportedException("Read-only connection does not support collection management");
69     }
70     
71     /**
72      * To delete all XML collections of this connection.
73      * @return the number of XML collections deleted.
74      * @throws XMLDBCException if a data source access error occurs.
75      * @throws XMLDBCNotSupportedException if the data source does not support this operation (typically, when the data source is read-only)
76      */

77     public int deleteAllCollections() throws XMLDBCException, XMLDBCNotSupportedException {
78       throw new XMLDBCNotSupportedException("Read-only connection does not support collection management");
79     }
80     
81     /**
82      * To delete a XML collection by its name.
83      * @param name the unique name of an existing XML collection.
84      * @throws XMLDBCException if a data source access error occurs or if the XML collection does not exist.
85      * @throws XMLDBCNotSupportedException if the data source does not support this operation (typically, when the data source is read-only)
86      */

87     public void deleteCollection(String JavaDoc name) throws XMLDBCException, XMLDBCNotSupportedException {
88       throw new XMLDBCNotSupportedException("Read-only connection does not support collection management");
89     }
90     
91     /**
92      * To know the current auto-commit state.
93      * @return true if the current connection is in auto-commit mode, else false.
94      * @throws XMLDBCException if a data source access error occurs.
95      * @throws XMLDBCNotSupportedException if the data source does not support transactions
96      */

97     public boolean getAutoCommit() throws XMLDBCException, XMLDBCNotSupportedException {
98       throw new XMLDBCNotSupportedException("Read-only connection does not support transactions");
99     }
100     
101     /**
102      * Gets this connection's current transaction isolation level.
103      * @return the current TRANSACTION_* mode value (see fields summary).
104      * @throws XMLDBCException if a data source access error occurs.
105      * @throws XMLDBCNotSupportedException if the data source does not support transactions
106      */

107     public short getTransactionIsolation() throws XMLDBCException, XMLDBCNotSupportedException {
108       throw new XMLDBCNotSupportedException("Read-only connection does not support transactions");
109     }
110     
111     /**
112      * To retrieve a XMLcollection by its name.
113      * @param name a name of XML collection.
114      * @return the XML collection that has the specified name or 'null' if there is no XML collection with this name.
115      * @throws XMLDBCException if a data source access error occurs.
116      * @throws XMLDBCNotSupportedException if the data source does not support this operation (typically, when the data source is read-only)
117      */

118     public XMLCollection getCollection(String JavaDoc name) throws XMLDBCException, XMLDBCNotSupportedException {
119       throw new XMLDBCNotSupportedException("Read-only connection does not support collection management");
120     }
121     
122     /**
123      * To know the read/write mode of the current connection.
124      * @return true if connection is read-only, else false.
125      * @throws XMLDBCException if a data source access error occurs.
126      */

127     public boolean isReadOnly() throws XMLDBCException {
128       return true;
129     }
130     
131     /**
132      * To rename an XML collection by its name.
133      * @param oldname the unique name of an existing XML collection.
134      * @param newname the new unique name of an existing XML collection.
135      * @throws XMLDBCException if a data source access error errors, if the collection does not exist, or if the new name is not unique.
136      * @throws XMLDBCNotSupportedException if the data source does not support this operation (typically, when the data source is read-only)
137      */

138     public void renameCollection(String JavaDoc oldname, String JavaDoc newname) throws XMLDBCException, XMLDBCNotSupportedException {
139       throw new XMLDBCNotSupportedException("Read-only connection does not support collection management");
140     }
141     
142     /**
143      * Drops all changes made since the previous commit/rollback and releases any data source locks currently held by
144      * this connection. This method should be used only when auto-commit has been disabled.
145      * @throws XMLDBCException if a data source access error occurs.
146      * @throws XMLDBCNotSupportedException if the data source does not support transactions
147      */

148     public void rollback() throws XMLDBCException, XMLDBCNotSupportedException {
149       throw new XMLDBCNotSupportedException("Read-only connection does not support transactions");
150     }
151     
152     /**
153      * Sets this connection's auto-commit mode. If the parameter is true, a commit will be done after each statement execution, else
154      * otherwise a commit will have to be made explicitly by calling the commit method.
155      * @param autoCommitMode if true, the connection will pass in auto-commit mode, else in manual commit mode.
156      * @throws XMLDBCException if a data source access error occurs.
157      * @throws XMLDBCNotSupportedException if the data source does not support transactions
158      */

159     public void setAutoCommit(boolean autoCommitMode) throws XMLDBCException, XMLDBCNotSupportedException {
160       throw new XMLDBCNotSupportedException("Read-only connection does not support transactions");
161     }
162     
163     /**
164      * To change the read/write mode of the connection. Some data source could make optimisations if the connection
165      * is in read-only mode.
166      * @param readOnlyMode if true, the connection will pass in read-only mode, else in read/write mode.
167      * @throws XMLDBCException if a data source access error occurs.
168      * @throws XMLDBCNotSupportedException if the data source is read-only and the parameter is false.
169      */

170     public void setReadOnly(boolean readOnlyMode) throws XMLDBCException, XMLDBCNotSupportedException {
171       if (!readOnlyMode)
172         throw new XMLDBCNotSupportedException("Read-only mode cannot be changed for this connection");
173     }
174     
175     /**
176      * Attempts to change the transaction isolation level to the one given. The constants defined in the interface
177      * Connection are the possible transaction isolation levels.
178      * This method cannot be called while in the middle of a transaction.
179      * @param level one of the TRANSACTION_* (see field summary) isolation values with the exception of
180      * TRANSACTION_NONE; some data sources may not support other values.
181      * @throws XMLDBCException if a data source access error occurs.
182      * @throws XMLDBCNotSupportedException if the data source does not support transactions
183      */

184     public void setTransactionIsolation(short level) throws XMLDBCException, XMLDBCNotSupportedException {
185       throw new XMLDBCNotSupportedException("Read-only connection does not support transactions");
186     }
187     
188 }
189
Popular Tags