⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basedatabase.java

📁 开源的axion的数据库代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * $Id: BaseDatabase.java,v 1.34 2003/07/07 23:36:12 rwald Exp $ * ======================================================================= * Copyright (c) 2002-2003 Axion Development Team.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above *    copyright notice, this list of conditions and the following *    disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The names "Tigris", "Axion", nor the names of its contributors may *    not be used to endorse or promote products derived from this *    software without specific prior written permission. * * 4. Products derived from this software may not be called "Axion", nor *    may "Tigris" or "Axion" appear in their names without specific prior *    written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ======================================================================= */package org.axiondb.engine;import java.io.File;import java.io.InputStream;import java.util.ArrayList;import java.util.Enumeration;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Properties;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.axiondb.AxionException;import org.axiondb.BinaryBranchWhereNode;import org.axiondb.BindVariable;import org.axiondb.Column;import org.axiondb.ColumnIdentifier;import org.axiondb.DataType;import org.axiondb.DataTypeFactory;import org.axiondb.Database;import org.axiondb.FromNode;import org.axiondb.FunctionFactory;import org.axiondb.InWhereNode;import org.axiondb.IndexFactory;import org.axiondb.LeafWhereNode;import org.axiondb.Literal;import org.axiondb.NotWhereNode;import org.axiondb.Row;import org.axiondb.Selectable;import org.axiondb.Sequence;import org.axiondb.Table;import org.axiondb.TableFactory;import org.axiondb.TableIdentifier;import org.axiondb.TransactionManager;import org.axiondb.WhereNode;import org.axiondb.event.DatabaseModificationListener;import org.axiondb.event.DatabaseModifiedEvent;import org.axiondb.event.DatabaseSequenceEvent;import org.axiondb.event.DatabaseTypeEvent;import org.axiondb.event.SequenceModificationListener;import org.axiondb.event.TableModificationListener;import org.axiondb.functions.AggregateFunction;import org.axiondb.functions.ConcreteFunction;import org.axiondb.functions.FunctionIdentifier;import org.axiondb.types.BooleanType;import org.axiondb.types.IntegerType;import org.axiondb.types.ShortType;import org.axiondb.types.StringType;import org.axiondb.expression.Expression;import org.axiondb.expression.ExpressionIdentifier;/** * Abstract base {@link Database} implementation. *  * @version $Revision: 1.34 $ $Date: 2003/07/07 23:36:12 $ * @author Chuck Burdick * @author Rodney Waldhoff * @author Morgan Delagrange * @author James Strachan * @author Amrish Lal * @author Rahul Dwivedi */public abstract class BaseDatabase implements Database {        //------------------------------------------------------------ Constructors        public BaseDatabase(String name) {        _name = name;    }    //------------------------------------------------------------------ Public        public String getName() {        return _name;    }    public boolean isReadOnly() {        return _readOnly;    }    public IndexFactory getIndexFactory(String name) {        return (IndexFactory)(_indexTypes.get(name.toUpperCase()));    }    public TableFactory getTableFactory(String name) {        return (TableFactory)(_tableTypes.get(name.toUpperCase()));    }    public DataType getDataType(String name) {        return (DataType)(_dataTypes.get(name.toUpperCase()));    }    public Table getTable(String name) throws AxionException {        String upName = name.toUpperCase();        return (Table)(_tables.get(upName));    }    public Table getTable(TableIdentifier table) throws AxionException {        return (Table)(_tables.get(table.getTableName()));    }    public void dropTable(String name) throws AxionException {        String upName = name.toUpperCase();        if(_tables.containsKey(upName)) {            Table table = (Table)(_tables.remove(upName));            Iterator i = getDatabaseModificationListeners().iterator();            while (i.hasNext()) {                DatabaseModificationListener cur = (DatabaseModificationListener)i.next();                cur.tableDropped(new DatabaseModifiedEvent(table));            }                        table.drop();        } else {            throw new AxionException("No table " + upName + " found");        }    }    public void tableAltered(Table t) throws AxionException {        Iterator i = getDatabaseModificationListeners().iterator();        while (i.hasNext()) {            DatabaseModificationListener cur = (DatabaseModificationListener)i.next();            DatabaseModifiedEvent e = new DatabaseModifiedEvent(t);            cur.tableDropped(e);            cur.tableAdded(e);        }                }        public void addTable(Table t) throws AxionException {        if(t != null) {            String upName = t.getName().toUpperCase();            if(_tables.containsKey(upName)) {                throw new AxionException("A table named " + t.getName() + " already exists.");            } else {                _tables.put(upName, t);                t.addTableModificationListener((TableModificationListener)_colUpd);                Iterator i = getDatabaseModificationListeners().iterator();                while (i.hasNext()) {                    DatabaseModificationListener cur = (DatabaseModificationListener)i.next();                    cur.tableAdded(new DatabaseModifiedEvent(t));                }            }        }    }    public void shutdown() throws AxionException {                for(Iterator tables = _tables.values().iterator();tables.hasNext();) {            Table table = (Table)(tables.next());            table.shutdown();        }        Databases.forgetDatabase(getName());    }    public void remount(File newdir) throws AxionException {        for(Iterator tables = _tables.values().iterator();tables.hasNext();) {            Table table = (Table)(tables.next());            table.remount(new File(newdir,table.getName()),false);        }    }    public void resolveFromNode(FromNode node, TableIdentifier[] tables) throws AxionException {        if (node == null) {            return;        }        Object left = node.getLeft();        Object right = node.getRight();                WhereNode whereNode = node.getCondition();        resolveWhereNode(whereNode, node.toTableArray());        if (left instanceof FromNode) {            FromNode childNode = (FromNode) left;            resolveFromNode(childNode, childNode.toTableArray());        }        if (right instanceof FromNode) {            FromNode childNode = (FromNode) right;            resolveFromNode(childNode, childNode.toTableArray());        }            }    /**     * Resolves all {@link Selectable}s within the given {@link     * WhereNode} tree, relative to the given {@link Database} and     * {@link TableIdentifier tables}.     */    public void resolveWhereNode(WhereNode node, TableIdentifier[] tables) throws AxionException {        if(null == node) {            return;        } else if(node instanceof BinaryBranchWhereNode) {            BinaryBranchWhereNode branch = (BinaryBranchWhereNode)node;            resolveWhereNode(branch.getLeft(),tables);            resolveWhereNode(branch.getRight(),tables);        } else if(node instanceof NotWhereNode) {            NotWhereNode nnode = (NotWhereNode)node;            resolveWhereNode(nnode.getChild(),tables);        } else if(node instanceof LeafWhereNode) {            LeafWhereNode leaf = (LeafWhereNode)node;            if(null != leaf.getLeft()) {                Selectable lsel = resolveSelectable(leaf.getLeft(), tables);                if (lsel instanceof AggregateFunction) {                    throw new AxionException("Use of aggregate functions in expression is not allowed.");                }                leaf.setLeft(lsel);            }            if(null != leaf.getRight()) {                Selectable rsel = resolveSelectable(leaf.getRight(), tables);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -