/*
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.ejb.plugins.jaws.metadata;

import java.lang.reflect.Field;

/**
 * This is a wrapper class that holds all the
 * information JawsPersistenceManager commands
 * need about a primary key field.
 * 
 * This class was org.jboss.ejb.plugins.PkFieldInfo
 *   
 * @see <related>
 * @author <a href="mailto:justin@j-m-f.demon.co.uk">Justin Forder</a>
 * @author <a href="mailto:sebastien.alborini@m4x.org">Sebastien Alborini</a>
 * @version $Revision: 1.4.4.1 $
 */

public class PkFieldMetaData
{
   // Attributes ----------------------------------------------------
    
   private Field pkField = null;

   private CMPFieldMetaData cmpField;
   
   private JawsEntityMetaData jawsEntity;
   
   
   
   // Constructors --------------------------------------------------
   
   // This constructor is used when the primary key is composite.
   // The pkField is a field on the primary key class.
   public PkFieldMetaData(Field pkField, CMPFieldMetaData cmpField, JawsEntityMetaData jawsEntity)
   {
      this(cmpField, jawsEntity);
      this.pkField = pkField;
   }
   
   // This constructor is used when the primary key is simple.
   // There is no primary key class, and there is no pkField.
   public PkFieldMetaData(CMPFieldMetaData cmpField, JawsEntityMetaData jawsEntity)
   {
      this.cmpField = cmpField;
	  this.jawsEntity = jawsEntity;
   }
   
   
   // Public --------------------------------------------------------
   
   public final String getName()
   {
      return cmpField.getName();
   }
   
   // N.B. This returns null if the primary key is not composite.
   public final Field getPkField()
   {
      return pkField;
   }
   
   public final Field getCMPField()
   {
      return cmpField.getField();
   }
   
   public final int getJDBCType()
   {
      return cmpField.getJDBCType();
   }
   
   public final String getSQLType()
   {
      return cmpField.getSQLType();
   }
   
   public final String getColumnName()
   {
      return cmpField.getColumnName();
   }
   
   public JawsEntityMetaData getJawsEntity() {
      return jawsEntity;
   }
}
