KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > ReturnTypeMismatchException


1 /*****************************************************************************
2  * Copyright (C) Zephyr Business Solution. 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
9 /*
10  * Created on Apr 15, 2005
11  *
12  * Author Ben Yu
13  * ZBS
14  */

15 package jfun.yan;
16
17 import java.lang.reflect.Method JavaDoc;
18
19 import jfun.util.Misc;
20
21 /**
22  * Represents an error when a component's type does not
23  * match the return type of the factory method that it implements.
24  * <p>
25  * Zephyr Business Solution
26  *
27  * @author Ben Yu
28  *
29  */

30 public class ReturnTypeMismatchException extends TypeMismatchException {
31   private final Method JavaDoc mtd;
32   
33   
34   /**
35    * Create a ReturnTypeMismatchException object.
36    * @param expected_type the expected type.
37    * @param actual_type the actual type.
38    * @param mtd the method.
39    */

40   public ReturnTypeMismatchException(Class JavaDoc expected_type, Class JavaDoc actual_type,
41       final Method JavaDoc mtd) {
42     super(expected_type, actual_type,
43         "" + Misc.getTypeName(actual_type)
44         + " cannot match return type of <"
45         + mtd + ">");
46     this.mtd = mtd;
47   }
48   /**
49    * Create a ReturnTypeMismatchException object.
50    * @param expected_type the expected type.
51    * @param actual_type the actual type.
52    * @param mtd the method.
53    * @param msg the error message.
54    */

55   public ReturnTypeMismatchException(
56       final Class JavaDoc expected_type, final Class JavaDoc actual_type,
57       final Method JavaDoc mtd, final String JavaDoc msg){
58     super(expected_type, actual_type, msg);
59     this.mtd = mtd;
60   }
61   /**
62    * Get the problematic method.
63    * @return the method.
64    */

65   public Method JavaDoc getMethod() {
66     return mtd;
67   }
68 }
69
Popular Tags