Clover coverage report - picocontainer - 1.2-beta-1
Coverage timestamp: Sun May 29 2005 14:29:04 BST
file stats: LOC: 71   Methods: 4
NCLOC: 32   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AmbiguousComponentResolutionException.java 100% 100% 100% 100%
coverage
 1    /*****************************************************************************
 2    * Copyright (c) PicoContainer Organization. All rights reserved. *
 3    * ------------------------------------------------------------------------- *
 4    * The software in this package is published under the terms of the BSD *
 5    * style license a copy of which has been included with this distribution in *
 6    * the LICENSE.txt file. *
 7    * *
 8    * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant *
 9    *****************************************************************************/
 10    package org.picocontainer.defaults;
 11   
 12    import org.picocontainer.PicoIntrospectionException;
 13   
 14    import java.util.Arrays;
 15   
 16    /**
 17    * Exception that is thrown as part of the introspection. Raised if a PicoContainer cannot resolve a
 18    * type dependency because the registered {@link org.picocontainer.ComponentAdapter}s are not
 19    * distinct.
 20    *
 21    * @author Paul Hammant
 22    * @author Aslak Hellesøy
 23    * @author Jon Tirsén
 24    * @since 1.0
 25    */
 26    public class AmbiguousComponentResolutionException extends PicoIntrospectionException {
 27    private Class component;
 28    private Class ambiguousDependency;
 29    private final Object[] ambiguousComponentKeys;
 30   
 31   
 32    /**
 33    * Construct a new exception with the ambigous class type and the ambiguous component keys.
 34    *
 35    * @param ambiguousDependency the unresolved dependency type
 36    * @param componentKeys the ambiguous keys.
 37    */
 38  14 public AmbiguousComponentResolutionException(Class ambiguousDependency, Object[] componentKeys) {
 39  14 super("");
 40  14 this.ambiguousDependency = ambiguousDependency;
 41  14 this.ambiguousComponentKeys = new Class[componentKeys.length];
 42  14 for (int i = 0; i < componentKeys.length; i++) {
 43  28 ambiguousComponentKeys[i] = componentKeys[i];
 44    }
 45    }
 46   
 47    /**
 48    * @return Returns a string containing the unresolved class type and the ambiguous keys.
 49    */
 50  14 public String getMessage() {
 51  14 StringBuffer msg = new StringBuffer();
 52  14 msg.append(component);
 53  14 msg.append(" has ambiguous dependency on ");
 54  14 msg.append(ambiguousDependency);
 55  14 msg.append(", ");
 56  14 msg.append("resolves to multiple classes: ");
 57  14 msg.append(Arrays.asList(getAmbiguousComponentKeys()));
 58  14 return msg.toString();
 59    }
 60   
 61    /**
 62    * @return Returns the ambiguous component keys as array.
 63    */
 64  26 public Object[] getAmbiguousComponentKeys() {
 65  26 return ambiguousComponentKeys;
 66    }
 67   
 68  14 public void setComponent(Class component) {
 69  14 this.component = component;
 70    }
 71    }