001: /*
002: * $Id: Database.java,v 1.40 2005/12/20 18:32:40 ahimanikya Exp $
003: * =======================================================================
004: * Copyright (c) 2002-2006 Axion Development Team. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above
011: * copyright notice, this list of conditions and the following
012: * disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The names "Tigris", "Axion", nor the names of its contributors may
020: * not be used to endorse or promote products derived from this
021: * software without specific prior written permission.
022: *
023: * 4. Products derived from this software may not be called "Axion", nor
024: * may "Tigris" or "Axion" appear in their names without specific prior
025: * written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
030: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
032: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
033: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
034: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
035: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
036: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
037: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
038: * =======================================================================
039: */
040:
041: package org.axiondb;
042:
043: import java.io.File;
044: import java.util.List;
045:
046: import org.axiondb.event.DatabaseModificationListener;
047: import org.axiondb.functions.ConcreteFunction;
048:
049: /**
050: * An Axion database.
051: *
052: * @version $Revision: 1.40 $ $Date: 2005/12/20 18:32:40 $
053: * @author Rodney Waldhoff
054: * @author Chuck Burdick
055: * @author Amrish Lal
056: * @author Ahimanikya Satapathy
057: */
058: public interface Database {
059:
060: public static String COMMIT_SIZE = "COMMITSIZE";
061:
062: /** Adds a listener to receive events on this database */
063: void addDatabaseModificationListener(DatabaseModificationListener l);
064:
065: /**
066: * Add the given {@link Index}to this database, associated with the given table.
067: */
068: void addIndex(Index index, Table table) throws AxionException;
069:
070: /**
071: * Add the given {@link Index}to this database, associating it with the given table
072: * and (optionally) populating it.
073: *
074: * @param index Index to be added and (optionally) populated
075: * @param table Table to be indexed
076: * @param doPopulate true if <code>index</code> should be populated by the
077: * appropriate column in <code>table</code>; false if <code>index</code>
078: * should be left as-is.
079: * @throws AxionException if error occurs during addition and/or population of
080: * <code>index</code>
081: */
082: void addIndex(Index index, Table table, boolean doPopulate)
083: throws AxionException;
084:
085: /**
086: * Add the given {@link Table}to this database.
087: */
088: void addTable(Table table) throws AxionException;
089:
090: /**
091: * Make sure any modified state or data has been written to disk.
092: */
093: void checkpoint() throws AxionException;
094:
095: void createDatabaseLink(DatabaseLink dblink) throws AxionException;
096:
097: /**
098: * Create a numeric sequence
099: */
100: void createSequence(Sequence seq) throws AxionException;
101:
102: void dropDatabaseLink(String name) throws AxionException;
103:
104: void dropDependentExternalDBTable(List tables)
105: throws AxionException;
106:
107: void dropDependentViews(List views) throws AxionException;
108:
109: /**
110: * Drop the given {@link Index}from this database.
111: */
112: void dropIndex(String name) throws AxionException;
113:
114: /**
115: * Drop the specified {@link Sequence}from this database.
116: * <p>
117: * Sequence name matching is case-insensitive.
118: */
119: void dropSequence(String name) throws AxionException;
120:
121: /**
122: * Drop the specified {@link Table}from this database.
123: * <p>
124: * Table name matching is case-insensitive.
125: */
126: void dropTable(String name) throws AxionException;
127:
128: DatabaseLink getDatabaseLink(String name);
129:
130: /** Returns all listeners set to receive events on this database */
131: List getDatabaseModificationListeners();
132:
133: /**
134: * Get the {@link DataType}currently registered for the given name, or <tt>null</tt>.
135: */
136: DataType getDataType(String name);
137:
138: /**
139: * Get the directory into which table information is stored, or <tt>null</tt>.
140: */
141: File getDBDirectory();
142:
143: List getDependentExternalDBTable(String name);
144:
145: List getDependentViews(String tableName);
146:
147: ConcreteFunction getFunction(String name);
148:
149: Object getGlobalVariable(String key);
150:
151: /**
152: * Get the {@link IndexFactory}currently registered for the given name, or
153: * <tt>null</tt>.
154: */
155: IndexFactory getIndexFactory(String name);
156:
157: /**
158: * Returns the name of this <code>Database</code>.
159: */
160: String getName();
161:
162: /**
163: * Get the specified {@link Sequence}, or <tt>null</tt> if no such sequence can be
164: * found.
165: * <p>
166: * Sequence name matching is case-insensitive.
167: */
168: Sequence getSequence(String name);
169:
170: /**
171: * Get the specified {@link Table}, or <tt>null</tt> if no such table can be found.
172: * <p>
173: * Table name matching is case-insensitive.
174: */
175: Table getTable(String name) throws AxionException;
176:
177: /**
178: * Get the specified {@link Table}, or <tt>null</tt> if no such table can be found.
179: * <p>
180: * Table name matching is case-insensitive.
181: */
182: Table getTable(TableIdentifier table) throws AxionException;
183:
184: /**
185: * Get the {@link TableFactory}currently registered for the given name, or
186: * <tt>null</tt>.
187: */
188: TableFactory getTableFactory(String name);
189:
190: /** Get the {@link TransactionManager}for this database. */
191: TransactionManager getTransactionManager();
192:
193: boolean hasDatabaseLink(String name) throws AxionException;
194:
195: /**
196: * Returns <code>true</code> iff the given {@link Index}exists.
197: */
198: boolean hasIndex(String name) throws AxionException;
199:
200: boolean hasSequence(String name) throws AxionException;
201:
202: boolean hasTable(String name) throws AxionException;
203:
204: boolean hasTable(TableIdentifier table) throws AxionException;
205:
206: /**
207: * Is this database read-only?
208: */
209: boolean isReadOnly();
210:
211: /** Migrate from older version to newer version for this database*/
212: void migrate(int version) throws AxionException;
213:
214: /**
215: * Notify this database that its root directory has been moved to the given location.
216: * (E.g., the CD containing the data for a CD-resident database has changed drives.)
217: */
218: void remount(File newdir) throws AxionException;
219:
220: void renameTable(String oldName, String newName)
221: throws AxionException;
222:
223: /**
224: * Close this database and free any resources associated with it.
225: */
226: void shutdown() throws AxionException;
227:
228: /** Update metadata tables since this table has changed. */
229: void tableAltered(Table t) throws AxionException;
230:
231: }
|