KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > PropertyTypeMismatchException


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 Mar 6, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

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

27 public class PropertyTypeMismatchException extends TypeMismatchException {
28   private final Class JavaDoc source;
29   private final Object JavaDoc ckey;
30   private final Object JavaDoc lkey;
31   
32   /**
33    * Create a PropertyTypeMismatchException object.
34    * @param ckey the component key.
35    * @param src the source class that caused this property mismatch problem.
36    * @param lkey the property key.
37    * @param param_type the expected type.
38    * @param arg_type the type of the actual value.
39    */

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

57   public Object JavaDoc getComponentKey() {
58     return ckey;
59   }
60   /**
61    * Get the property key.
62    * @return the property key.
63    */

64   public Object JavaDoc getPropertyKey() {
65     return lkey;
66   }
67
68   /**
69    * To get the source of the exception.
70    */

71   public Class JavaDoc getSource() {
72     return source;
73   }
74   
75 }
76
Popular Tags