head	1.2;
access;
symbols;
locks; strict;
comment	@# @;


1.2
date	2001.05.04.01.05.18;	author dlr;	state Exp;
branches;
next	1.1;

1.1
date	2001.05.04.01.01.52;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Renamed this file in the repository (it's currently in only in the trunk).
@
text
@/* ================================================================
 * Copyright (c) 2000-2001 CollabNet.  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 end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.Collab.Net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 COLLABNET OR ITS 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.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */


package org.tigris.helm.om;

import java.util.Hashtable;

/**
 * Resolves database key field names for business objects.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: BOKeyFieldName.java,v 1.1 2001/05/04 01:01:52 dlr Exp $
 */
class BOKeyFieldName
{
    /**
     * The table mapping entity type to key field name.
     */
    private static final String[][] TYPE_TO_KEY_FIELD =
    {
        { BOType.HOST_TYPE, ProjectPeer.PROJECT_ID },
        { BOType.DOMAIN_TYPE, ProjectPeer.PROJECT_ID },
        { BOType.PROJECT_TYPE, ProjectPeer.PROJECT_ID },
        { BOType.ROLE_TYPE, RolePeer.ROLE_ID }
    };

    /**
     * Resolves the database key field name for the specified entity type.
     *
     * @@param entityType The type of the business object to resolve for.
     * @@return           The field name of the requested database key.
     */
    public static String resolve(String entityType)
        throws IllegalArgumentException
    {
        for (int i = 0; i < TYPE_TO_KEY_FIELD.length; i++)
        {
            if (TYPE_TO_KEY_FIELD[i][0].equals(entityType))
            {
                return TYPE_TO_KEY_FIELD[i][1];
            }
        }

        throw new IllegalArgumentException("Couldn't resolve the field name " +
                                           "for unknown entity type: " +
                                           entityType);
    }
}
@


1.1
log
@Resolves database key field names for business objects.  This would
likely be unnecessary if Peers were singletons instead of a collection
of static methods, or Torque were enhanced.  Until that day, all your
entity are belong to us.
@
text
@d56 1
a56 1
 * @@version $Id: BOType.java,v 1.3 2001/05/02 07:08:20 dlr Exp $
d58 1
a58 1
class BOKeyFieldNames
@

