KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > data > ConversionException


1 /*
2  * $Id: ConversionException.java,v 1.1.1.1 2004/06/16 01:43:39 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.swing.data;
9
10 /**
11  * Thrown by Converter instances when errors occur during value conversion.
12  * @see Converter
13  *
14  * @author Amy Fowler
15  * @version 1.0
16  */

17 public class ConversionException extends Exception JavaDoc {
18
19     /**
20      * Instantiates conversion exception for error which occurred when
21      * attempting to convert the specified object value to a string.
22      * @param value object which could not be converted
23      * @param fromClass class of object value being converted
24      */

25     public ConversionException(Object JavaDoc value, Class JavaDoc fromClass) {
26         this("could not convert value from class " + fromClass.getName() +
27              "to a string");
28     }
29
30     /**
31      * Instantiates conversion exception for error which occurred when
32      * attempting to convert the specified object value to a string.
33      * @param value object value which could not be converted
34      * @param fromClass class of object value being converted
35      * @param cause the specific throwable which caused conversion failure
36      */

37     public ConversionException(Object JavaDoc value, Class JavaDoc fromClass, Throwable JavaDoc cause) {
38         this("could not convert value from class " + fromClass.getName() +
39              "to a string", cause);
40     }
41
42     /**
43      * Instantiates conversion exception for error which occurred when
44      * attempting to convert the specified string value to an object
45      * of the specified class.
46      * @param value string value which could not be converted
47      * @param toClass class the value was being converted to
48      */

49     public ConversionException(String JavaDoc value, Class JavaDoc toClass) {
50         this("could not convert string value \"" + value + "\" to " +
51              toClass.getName());
52     }
53
54     /**
55      * Instantiates conversion exception for error which occurred when
56      * attempting to convert the specified string value to an object
57      * of the specified class.
58      * @param value object value which could not be converted
59      * @param toClass class of object value being converted
60      * @param cause the specific throwable which caused conversion failure
61      */

62     public ConversionException(String JavaDoc value, Class JavaDoc toClass, Throwable JavaDoc cause) {
63         this("could not convert string value \"" + value + "\" to " +
64              toClass.getName(), cause);
65     }
66
67     /**
68      * Instantiates conversion exception.
69      * @param message String containing description of why exception occurred
70      */

71     public ConversionException(String JavaDoc message) {
72         super(message);
73     }
74
75     /**
76      * Instantiates conversion exception.
77      * @param message String containing description of why exception occurred
78      * @param cause the specific throwable which caused conversion failure
79      */

80     public ConversionException(String JavaDoc message, Throwable JavaDoc cause) {
81         super(message, cause);
82     }
83
84 }
85
Popular Tags