Clover coverage report - MetaClass - 1.1
Coverage timestamp: Tue Apr 27 2004 10:46:24 EST
file stats: LOC: 80   Methods: 4
NCLOC: 40   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
NonNamespaceAttributeRemovingInterceptor.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.tools.qdox;
 9   
 
 10   
 import org.codehaus.metaclass.model.Attribute;
 11   
 import com.thoughtworks.qdox.model.JavaClass;
 12   
 import com.thoughtworks.qdox.model.JavaField;
 13   
 import com.thoughtworks.qdox.model.JavaMethod;
 14   
 
 15   
 /**
 16   
  * Interceptor that only returns attributes if they have a namespace.
 17   
  * Attributes with namespace have names of the form
 18   
  * <namespace>.<name>.
 19   
  *
 20   
  * @author Peter Donald
 21   
  * @version $Revision: 1.2 $ $Date: 2003/11/27 08:08:04 $
 22   
  */
 23   
 public class NonNamespaceAttributeRemovingInterceptor
 24   
     extends DefaultQDoxAttributeInterceptor
 25   
 {
 26   
     /**
 27   
      * Constant containing an instance of interceptor.
 28   
      */
 29   
     public static final NonNamespaceAttributeRemovingInterceptor INTERCEPTOR =
 30   
         new NonNamespaceAttributeRemovingInterceptor();
 31   
 
 32   
     /**
 33   
      * @see DefaultQDoxAttributeInterceptor#processClassAttribute
 34   
      */
 35  6
     public Attribute processClassAttribute( final JavaClass clazz,
 36   
                                             final Attribute attribute )
 37   
     {
 38  6
         return processAttribute( attribute );
 39   
     }
 40   
 
 41   
     /**
 42   
      * @see DefaultQDoxAttributeInterceptor#processFieldAttribute
 43   
      */
 44  2
     public Attribute processFieldAttribute( final JavaField field,
 45   
                                             final Attribute attribute )
 46   
     {
 47  2
         return processAttribute( attribute );
 48   
     }
 49   
 
 50   
     /**
 51   
      * @see DefaultQDoxAttributeInterceptor#processMethodAttribute
 52   
      */
 53  2
     public Attribute processMethodAttribute( final JavaMethod method,
 54   
                                              final Attribute attribute )
 55   
     {
 56  2
         return processAttribute( attribute );
 57   
     }
 58   
 
 59   
     /**
 60   
      * Only return an attribute if it has a namespace.
 61   
      *
 62   
      * @param attribute the attribute
 63   
      * @return the attribute or null
 64   
      */
 65  18
     Attribute processAttribute( final Attribute attribute )
 66   
     {
 67  18
         final String name = attribute.getName();
 68  18
         final int length = name.length();
 69  18
         final int index = name.indexOf( "." );
 70  18
         if( -1 == index || 0 == index || length - 1 == index )
 71   
         {
 72  6
             return null;
 73   
         }
 74   
         else
 75   
         {
 76  12
             return attribute;
 77   
         }
 78   
     }
 79   
 }
 80