Clover coverage report - Code Coverage for hivemind release 1.1-alpha-3
Coverage timestamp: Tue Mar 22 2005 09:10:26 EST
file stats: LOC: 112   Methods: 4
NCLOC: 71   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
InterfaceFabImpl.java 100% 93.1% 100% 94.9%
coverage coverage
 1   
 // Copyright 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.hivemind.service.impl;
 16   
 
 17   
 import java.lang.reflect.Modifier;
 18   
 import java.util.ArrayList;
 19   
 import java.util.Iterator;
 20   
 import java.util.List;
 21   
 
 22   
 import javassist.CtClass;
 23   
 import javassist.CtMethod;
 24   
 
 25   
 import org.apache.hivemind.ApplicationRuntimeException;
 26   
 import org.apache.hivemind.service.InterfaceFab;
 27   
 import org.apache.hivemind.service.MethodSignature;
 28   
 
 29   
 /**
 30   
  * @author Howard M. Lewis Ship
 31   
  */
 32   
 public class InterfaceFabImpl extends AbstractFab implements InterfaceFab
 33   
 {
 34   
     private List _methods = new ArrayList();
 35   
 
 36  8
     public InterfaceFabImpl(CtClassSource source, CtClass ctClass)
 37   
     {
 38  8
         super(source, ctClass);
 39   
     }
 40   
 
 41  3
     public String toString()
 42   
     {
 43  3
         StringBuffer buffer = new StringBuffer("InterfaceFabImpl[\npublic interface ");
 44   
 
 45  3
         CtClass ctClass = getCtClass();
 46   
 
 47  3
         buffer.append(ctClass.getName());
 48   
 
 49  3
         try
 50   
         {
 51  3
             CtClass[] interfaces = ctClass.getInterfaces();
 52   
 
 53  3
             for (int i = 0; i < interfaces.length; i++)
 54   
             {
 55  2
                 buffer.append(i == 0 ? " extends " : ", ");
 56  2
                 buffer.append(interfaces[i].getName());
 57   
             }
 58   
 
 59   
         }
 60   
         catch (Exception ex)
 61   
         {
 62  0
             buffer.append("<Exception: " + ex + ">");
 63   
         }
 64   
 
 65  3
         Iterator i = _methods.iterator();
 66   
 
 67  3
         while (i.hasNext())
 68   
         {
 69  1
             MethodSignature sig = (MethodSignature) i.next();
 70   
 
 71  1
             buffer.append("\n\npublic ");
 72  1
             buffer.append(sig);
 73  1
             buffer.append(";");
 74   
         }
 75   
 
 76  3
         buffer.append("\n]");
 77   
 
 78  3
         return buffer.toString();
 79   
     }
 80   
 
 81  5
     public void addMethod(MethodSignature ms)
 82   
     {
 83  5
         CtClass ctReturnType = convertClass(ms.getReturnType());
 84  5
         CtClass[] ctParameters = convertClasses(ms.getParameterTypes());
 85  5
         CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes());
 86   
 
 87  5
         CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass());
 88   
 
 89  5
         try
 90   
         {
 91  5
             method.setModifiers(Modifier.PUBLIC | Modifier.ABSTRACT);
 92  5
             method.setExceptionTypes(ctExceptions);
 93   
 
 94  5
             getCtClass().addMethod(method);
 95   
         }
 96   
         catch (Exception ex)
 97   
         {
 98  0
             throw new ApplicationRuntimeException(ServiceMessages.unableToAddMethod(
 99   
                     ms,
 100   
                     getCtClass(),
 101   
                     ex), ex);
 102   
         }
 103   
 
 104  5
         _methods.add(ms);
 105   
     }
 106   
 
 107  8
     public Class createInterface()
 108   
     {
 109  8
         return createClass();
 110   
     }
 111   
 
 112   
 }