All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.datanucleus.metadata.AbstractConstraintMetaData Maven / Gradle / Ivy

/**********************************************************************
 Copyright (c) 2007 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.datanucleus.metadata;

import java.util.ArrayList;
import java.util.List;

import org.datanucleus.ClassLoaderResolver;

/**
 * Abstract representation of an ORM constraint.
 */
public class AbstractConstraintMetaData extends MetaData
{
    /** the constraint name */
    protected String name;

    /** the constraint table name. Name of the table to which this applies (null implies the enclosing class' table). */
    protected String table;

    /** Contains the metadata for fields/properties. */
    protected AbstractMemberMetaData[] memberMetaData;

    /** Contains the metadata for columns */
    protected ColumnMetaData[] columnMetaData;

    // -------------------------------------------------------------------------
    // Fields below here are used in the metadata parse process where the parser
    // dynamically adds fields/columns as it encounters them in the MetaData files.
    // They are typically cleared at the point of initialise() and not used thereafter.

    /** The fields/properties for this constraint. */
    protected List members = new ArrayList();

    /** The columns for this constraint. */
    protected List columns = new ArrayList();

    /**
     * Default constructor. Set fields using setters before populate().
     */
    public AbstractConstraintMetaData()
    {
    }

    /**
     * Copy constructor.
     */
    public AbstractConstraintMetaData(AbstractConstraintMetaData acmd)
    {
        super(null, acmd);
    }

    /**
     * Method to initialise the object, creating internal convenience arrays.
     * Initialise all sub-objects.
     */
    public void initialise(ClassLoaderResolver clr, MetaDataManager mmgr)
    {
        if (isInitialised())
        {
            return;
        }

        // Set up the fieldMetaData
        if (members.size() == 0)
        {
            memberMetaData = null;
        }
        else
        {
            memberMetaData = new AbstractMemberMetaData[members.size()];
            for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy