Package org.hsqldb.lib

Examples of org.hsqldb.lib.OrderedHashSet


     * After addition or removal of columns and indexes all views that
     * reference the table should be recompiled.
     */
    public void recompileDependentObjects(Table table) {

        OrderedHashSet set = new OrderedHashSet();

        getCascadingReferencingObjectNames(table.getName(), set);

        Session session = database.sessionManager.getSysSession();

        for (int i = 0; i < set.size(); i++) {
            HsqlName name = (HsqlName) set.get(i);

            switch (name.type) {

                case SchemaObject.VIEW :
                case SchemaObject.CONSTRAINT :
View Full Code Here


    }

    // references
    private void addReferences(SchemaObject object) {

        OrderedHashSet set = object.getReferences();

        if (set == null) {
            return;
        }

        for (int i = 0; i < set.size(); i++) {
            HsqlName referenced = (HsqlName) set.get(i);
            HsqlName name       = object.getName();

            if (object instanceof Routine) {
                name = ((Routine) object).getSpecificName();
            }
View Full Code Here

        referenceMap.remove(referenced);
    }

    private void removeReferencingObject(SchemaObject object) {

        OrderedHashSet set = object.getReferences();

        if (set == null) {
            return;
        }

        for (int i = 0; i < set.size(); i++) {
            HsqlName referenced = (HsqlName) set.get(i);
            HsqlName name       = object.getName();

            if (object instanceof Routine) {
                name = ((Routine) object).getSpecificName();
            }
View Full Code Here

        }
    }

    OrderedHashSet getReferencingObjectNames(HsqlName object) {

        OrderedHashSet set = new OrderedHashSet();
        Iterator       it  = referenceMap.get(object);

        while (it.hasNext()) {
            HsqlName name = (HsqlName) it.next();

            set.add(name);
        }

        return set;
    }
View Full Code Here

    }

    public OrderedHashSet getReferencingObjectNames(HsqlName table,
            HsqlName column) {

        OrderedHashSet set = new OrderedHashSet();
        Iterator       it  = referenceMap.get(table);

        while (it.hasNext()) {
            HsqlName       name       = (HsqlName) it.next();
            SchemaObject   object     = getSchemaObject(name);
            OrderedHashSet references = object.getReferences();

            if (references.contains(column)) {
                set.add(name);
            }
        }

        return set;
View Full Code Here

    //
    public void getCascadingReferencingObjectNames(HsqlName object,
            OrderedHashSet set) {

        OrderedHashSet newSet = new OrderedHashSet();
        Iterator       it     = referenceMap.get(object);

        while (it.hasNext()) {
            HsqlName name  = (HsqlName) it.next();
            boolean  added = set.add(name);

            if (added) {
                newSet.add(name);
            }
        }

        for (int i = 0; i < newSet.size(); i++) {
            HsqlName name = (HsqlName) newSet.get(i);

            getCascadingReferencingObjectNames(name, set);
        }
    }
View Full Code Here

        return null;
    }

    public void checkColumnIsReferenced(HsqlName tableName, HsqlName name) {

        OrderedHashSet set = getReferencingObjectNames(tableName, name);

        if (!set.isEmpty()) {
            HsqlName objectName = (HsqlName) set.get(0);

            throw Error.error(ErrorCode.X_42502,
                              objectName.getSchemaQualifiedStatementName());
        }
    }
View Full Code Here

        }
    }

    public void checkObjectIsReferenced(HsqlName name) {

        OrderedHashSet set     = getReferencingObjectNames(name);
        HsqlName       refName = null;

        for (int i = 0; i < set.size(); i++) {
            refName = (HsqlName) set.get(i);

            // except columns of same table
            if (refName.parent != name) {
                break;
            }
View Full Code Here

                addReferences(object);

                return;
            }
            case SchemaObject.TABLE : {
                OrderedHashSet refs = object.getReferences();

                for (int i = 0; i < refs.size(); i++) {
                    HsqlName ref = (HsqlName) refs.get(i);

                    if (ref.type == SchemaObject.COLUMN) {
                        int index = ((Table) object).findColumn(ref.name);
                        ColumnSchema column =
                            ((Table) object).getColumn(index);
View Full Code Here

        addReferences(object);
    }

    public void removeSchemaObject(HsqlName name, boolean cascade) {

        OrderedHashSet objectSet = new OrderedHashSet();

        switch (name.type) {

            case SchemaObject.ROUTINE :
            case SchemaObject.PROCEDURE :
            case SchemaObject.FUNCTION : {
                RoutineSchema routine = (RoutineSchema) getSchemaObject(name);

                if (routine != null) {
                    Routine[] specifics = routine.getSpecificRoutines();

                    for (int i = 0; i < specifics.length; i++) {
                        getCascadingReferencingObjectNames(
                            specifics[i].getSpecificName(), objectSet);
                    }
                }
            }
            break;

            case SchemaObject.SEQUENCE :
            case SchemaObject.TABLE :
            case SchemaObject.VIEW :
            case SchemaObject.TYPE :
            case SchemaObject.CHARSET :
            case SchemaObject.COLLATION :
            case SchemaObject.SPECIFIC_ROUTINE :
                getCascadingReferencingObjectNames(name, objectSet);
                break;

            case SchemaObject.DOMAIN :
                OrderedHashSet set = getReferencingObjectNames(name);
                Iterator       it  = set.iterator();

                while (it.hasNext()) {
                    HsqlName ref = (HsqlName) it.next();

                    if (ref.type == SchemaObject.COLUMN) {
                        it.remove();
                    }
                }

                if (!set.isEmpty()) {
                    HsqlName objectName = (HsqlName) set.get(0);

                    throw Error.error(
                        ErrorCode.X_42502,
                        objectName.getSchemaQualifiedStatementName());
                }
View Full Code Here

TOP

Related Classes of org.hsqldb.lib.OrderedHashSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.