Package org.jpox.store.mapped.query

Source Code of org.jpox.store.mapped.query.AbstractIteratorStatement

/**********************************************************************
Copyright (c) 2005 Andy Jefferson and others. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributors:
...
**********************************************************************/
package org.jpox.store.mapped.query;

import org.jpox.ClassLoaderResolver;
import org.jpox.ObjectManagerFactoryImpl;
import org.jpox.metadata.AbstractClassMetaData;
import org.jpox.store.StoreManager;
import org.jpox.store.mapped.DatastoreAdapter;
import org.jpox.store.mapped.DatastoreClass;
import org.jpox.store.mapped.DatastoreIdentifier;
import org.jpox.store.mapped.MappedStoreManager;
import org.jpox.store.mapped.expression.QueryExpression;
import org.jpox.util.Localiser;

/**
* Abstract representation of a statement that is used for iterating through a list of
* objects of a class, possibly including subclasses.
*
* @version $Revision: 1.13 $
*/
public abstract class AbstractIteratorStatement
{
    /** Localisation or messages. */
    protected static final Localiser LOCALISER = Localiser.getInstance("org.jpox.store.Localisation",
        ObjectManagerFactoryImpl.class.getClassLoader());

    /** Whether to include iteration through subclasses of the candidate. */
    protected final boolean includeSubclasses;

    /** Manager for the Store. */
    protected final MappedStoreManager storeMgr;

    /** Datastore adapter */
    protected final DatastoreAdapter dba;
   
    /** full class name for the candidate class **/
    protected String candidateFullClassName;

    /** Table where the candidate objects are stored. */
    protected DatastoreClass candidateTable;

    /** ClassLoader resolver. */
    protected final ClassLoaderResolver clr;

    /**
     * Constructor.
     * @param type Class that we are querying for as our base.
     * @param clr ClassLoaderResolver
     * @param subclasses Whether to include subclasses in the iteration.
     * @param storeMgr Manager for the store
     */
    public AbstractIteratorStatement(Class type, ClassLoaderResolver clr, boolean subclasses, StoreManager storeMgr)
    {
        this.includeSubclasses = subclasses;
        this.storeMgr = (MappedStoreManager)storeMgr;
        this.dba = ((MappedStoreManager)storeMgr).getDatastoreAdapter();
        this.clr = clr;
        AbstractClassMetaData cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(type, clr);
        if (cmd == null)
        {
            candidateFullClassName = type.getName();
        }
        else
        {
            candidateFullClassName = cmd.getFullClassName();
        }

        if (!storeMgr.getOMFContext().getTypeManager().isSupportedType(candidateFullClassName))
        {
            candidateTable = this.storeMgr.getDatastoreClass(candidateFullClassName, clr);
        }
    }

    /**
     * Accessor for the QueryStatement that will return the objects of the candidate
     * type and its subclasses (if required).
     * @param candidateAlias Alias for the candidate
     * @return The QueryExpression
     */
    public abstract QueryExpression getQueryStatement(DatastoreIdentifier candidateAlias);
}
TOP

Related Classes of org.jpox.store.mapped.query.AbstractIteratorStatement

TOP
Copyright © 2018 www.massapi.com. 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.