Clover coverage report - MetaClass - 1.1
Coverage timestamp: Tue Apr 27 2004 10:46:24 EST
file stats: LOC: 112   Methods: 3
NCLOC: 64   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
FeatureDescriptor.java 100% 100% 100% 100%
coverage
 1   
 /*
 2   
  * Copyright (C) The MetaClass Group. All rights reserved.
 3   
  *
 4   
  * This software is published under the terms of the Spice
 5   
  * Software License version 1.1, a copy of which has been included
 6   
  * with this distribution in the LICENSE.txt file.
 7   
  */
 8   
 package org.codehaus.metaclass.model;
 9   
 
 10   
 import java.io.Serializable;
 11   
 
 12   
 /**
 13   
  * This is the Abstract class for all feature descriptors.
 14   
  * Every descriptor has the capability of adding Attributes
 15   
  * of some kind. These Attributes can then be interpreted by
 16   
  * the container. The meaning of the specific Attributes will
 17   
  * be defined by future specification documents.
 18   
  *
 19   
  * @author Peter Donald
 20   
  * @author <a href="mailto:doug at stocksoftware.com.au">Doug Hagan</a>
 21   
  * @version $Revision: 1.12 $ $Date: 2003/11/27 08:09:53 $
 22   
  */
 23   
 public abstract class FeatureDescriptor
 24   
     implements Serializable
 25   
 {
 26   
     /**
 27   
      * The arbitrary set of declared Attributes.
 28   
      */
 29   
     private final Attribute[] m_declaredAttributes;
 30   
 
 31   
     /**
 32   
      * The arbitrary set of Attributes.
 33   
      */
 34   
     private final Attribute[] m_attributes;
 35   
 
 36   
     /**
 37   
      * Create a FeatureDescriptor with specific set of attributes.
 38   
      *
 39   
      * @param attributes the attributes
 40   
      * @param declaredAttributes the declared attributes
 41   
      */
 42  316
     protected FeatureDescriptor( final Attribute[] declaredAttributes,
 43   
                                  final Attribute[] attributes )
 44   
     {
 45  316
         if( null == declaredAttributes )
 46   
         {
 47  2
             throw new NullPointerException( "declaredAttributes" );
 48   
         }
 49  314
         if( null == attributes )
 50   
         {
 51  2
             throw new NullPointerException( "attributes" );
 52   
         }
 53  312
         for( int i = 0; i < declaredAttributes.length; i++ )
 54   
         {
 55  162
             if( null == declaredAttributes[ i ] )
 56   
             {
 57  2
                 throw new NullPointerException( "declaredAttributes[" + i + "]" );
 58   
             }
 59   
         }
 60  310
         for( int i = 0; i < attributes.length; i++ )
 61   
         {
 62  176
             if( null == attributes[ i ] )
 63   
             {
 64  2
                 throw new NullPointerException( "attributes[" + i + "]" );
 65   
             }
 66   
         }
 67  308
         for( int i = 0; i < declaredAttributes.length; i++ )
 68   
         {
 69  160
             final Attribute attribute = declaredAttributes[ i ];
 70  160
             boolean match = false;
 71  160
             for( int j = 0; j < attributes.length; j++ )
 72   
             {
 73  198
                 final Attribute other = attributes[ j ];
 74  198
                 if( attribute.equals( other ) )
 75   
                 {
 76  158
                     match = true;
 77  158
                     break;
 78   
                 }
 79   
             }
 80  160
             if( !match )
 81   
             {
 82  2
                 final String message =
 83   
                     "declaredAttribute[" + i + "] not an attribute";
 84  2
                 throw new IllegalArgumentException( message );
 85   
             }
 86   
         }
 87   
 
 88  306
         m_declaredAttributes = declaredAttributes;
 89  306
         m_attributes = attributes;
 90   
     }
 91   
 
 92   
     /**
 93   
      * Return the declared attributes associated with descriptor.
 94   
      *
 95   
      * @return the declared attributes associated with descriptor.
 96   
      */
 97  40
     public Attribute[] getDeclaredAttributes()
 98   
     {
 99  40
         return m_declaredAttributes;
 100   
     }
 101   
 
 102   
     /**
 103   
      * Return the attributes associated with descriptor.
 104   
      *
 105   
      * @return the attributes associated with descriptor.
 106   
      */
 107  252
     public Attribute[] getAttributes()
 108   
     {
 109  252
         return m_attributes;
 110   
     }
 111   
 }
 112