2009/04/15 - Apache HiveMind has been retired.

For more information, please explore the Attic.

Clover coverage report - Code Coverage for hivemind release 1.2.1
Coverage timestamp: Fri Feb 10 2006 16:33:43 PST
file stats: LOC: 112   Methods: 4
NCLOC: 71   Classes: 1
 
 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  15 public InterfaceFabImpl(CtClassSource source, CtClass ctClass)
 37    {
 38  15 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  14 public void addMethod(MethodSignature ms)
 82    {
 83  14 CtClass ctReturnType = convertClass(ms.getReturnType());
 84  14 CtClass[] ctParameters = convertClasses(ms.getParameterTypes());
 85  14 CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes());
 86   
 87  14 CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass());
 88   
 89  14 try
 90    {
 91  14 method.setModifiers(Modifier.PUBLIC | Modifier.ABSTRACT);
 92  14 method.setExceptionTypes(ctExceptions);
 93   
 94  14 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  14 _methods.add(ms);
 105    }
 106   
 107  15 public Class createInterface()
 108    {
 109  15 return createClass();
 110    }
 111   
 112    }