KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > ParameterTypeMismatchException


1 /*****************************************************************************
2  * Copyright (C) Codehaus.org. 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  * Created on Feb 28, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

14 package jfun.yan;
15
16 import jfun.yan.function.Signature;
17
18 /**
19  * Represents an exception when the type of the actual argument
20  * does not match the expected parameter type.
21  * <p>
22  * Codehaus.org.
23  *
24  * @author Ben Yu
25  *
26  */

27 public class ParameterTypeMismatchException extends TypeMismatchException {
28   private final Signature source;
29   private final Object JavaDoc ckey;
30   private final int num;
31   /**
32    * Create a ParameterTypeMismatchException object.
33    * @param ckey the component key.
34    * @param src the signature of the method call that caused this.
35    * @param num the ordinal position of the parameter.
36    * @param param_type the expected parameter type.
37    * @param arg_type the type of the actual argument.
38    */

39   public ParameterTypeMismatchException(final Object JavaDoc ckey,
40       final Signature src, final int num,
41       final Class JavaDoc param_type, final Class JavaDoc arg_type) {
42     super(param_type, arg_type,
43         "type mismatch for The #" + num + " parameter of component <" + ckey+"> for "
44         + src
45         + " - " + param_type.getName()+" expected, "
46         + arg_type + " encountered.");
47     this.ckey = ckey;
48     this.source = src;
49     this.num = num;
50   }
51
52   /**
53    * Get the component key.
54    * @return the component key.
55    */

56   public Object JavaDoc getComponentKey() {
57     return ckey;
58   }
59   /**
60    * Get the ordinal position of the parameter starting from 0.
61    * @return the ordinal position.
62    */

63   public int getOrdinalPosition() {
64     return num;
65   }
66
67   /**
68    * To get the signature of the method call that caused this error.
69    */

70   public Signature getSource() {
71     return source;
72   }
73   
74 }
75
Popular Tags