Coverage Report - org.apache.ojb.broker.metadata.AttributeDescriptorBase
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeDescriptorBase
N/A
N/A
1
 
 1  
 package org.apache.ojb.broker.metadata;
 2  
 
 3  
 /* Copyright 2002-2005 The Apache Software Foundation
 4  
  *
 5  
  * Licensed under the Apache License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
 19  
 import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
 20  
 
 21  
 import java.io.Serializable;
 22  
 
 23  
 /**
 24  
  * Is the base class for all other attribute descriptors.
 25  
  * It holds basic the mapping information for a specific attribute.
 26  
  *
 27  
  * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
 28  
  * @version $Id: AttributeDescriptorBase.java,v 1.1 2007-08-24 22:17:29 ewestfal Exp $
 29  
  */
 30  
 public class AttributeDescriptorBase extends DescriptorBase implements Serializable
 31  
 {
 32  
         private static final long serialVersionUID = -818671542770428043L;
 33  
 
 34  
     protected PersistentField m_PersistentField = null;
 35  
     protected ClassDescriptor m_ClassDescriptor = null;
 36  
 
 37  
     /**
 38  
      * Constructor declaration
 39  
      */
 40  
     public AttributeDescriptorBase(ClassDescriptor descriptor)
 41  
     {
 42  
         this.m_ClassDescriptor = descriptor;
 43  
     }
 44  
 
 45  
     /**
 46  
      * @throws MetadataException if an error occours when setting the PersistenteField
 47  
      */
 48  
     public void setPersistentField(Class c, String fieldname)
 49  
     {
 50  
         m_PersistentField = PersistentFieldFactory.createPersistentField(c, fieldname);
 51  
     }
 52  
 
 53  
         public void setPersistentField(PersistentField pf)
 54  
         {
 55  
                 m_PersistentField = pf;
 56  
         }
 57  
 
 58  
     /**
 59  
      *
 60  
      */
 61  
     public PersistentField getPersistentField()
 62  
     {
 63  
         return m_PersistentField;
 64  
     }
 65  
 
 66  
     /**
 67  
      * @return the name of the Attribute
 68  
      */
 69  
     public String getAttributeName()
 70  
     {
 71  
         return getPersistentField().getName();
 72  
     }
 73  
 
 74  
     /**
 75  
      * Gets the classDescriptor.
 76  
      * @return Returns a ClassDescriptor
 77  
      */
 78  
     public ClassDescriptor getClassDescriptor()
 79  
     {
 80  
         return m_ClassDescriptor;
 81  
     }
 82  
 
 83  
     /**
 84  
      * Sets the classDescriptor.
 85  
      * @param classDescriptor The classDescriptor to set
 86  
      */
 87  
     public void setClassDescriptor(ClassDescriptor classDescriptor)
 88  
     {
 89  
         m_ClassDescriptor = classDescriptor;
 90  
     }
 91  
 
 92  
     public String toString()
 93  
     {
 94  
         StringBuffer buf = new StringBuffer();
 95  
         buf.append(m_PersistentField);
 96  
         buf.append(", field_belongs_to " + m_ClassDescriptor.getClassNameOfObject());
 97  
         buf.append(", "+super.toString());
 98  
         return buf.toString();
 99  
     }
 100  
 }