ConversionException.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:4k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: ConversionException.java,v 1.2 2005/10/10 17:01:08 rbair Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.binding.metadata;
  22. /**
  23.  * Thrown by Converter instances when errors occur during value conversion.
  24.  * @see Converter
  25.  *
  26.  * @author Amy Fowler
  27.  * @version 1.0
  28.  */
  29. public class ConversionException extends Exception {
  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 which could not be converted
  34.      * @param fromClass class of object value being converted
  35.      */
  36.     public ConversionException(Object value, Class fromClass) {
  37.         this("could not convert value from class " + fromClass.getName() +
  38.              "to a string");
  39.     }
  40.     /**
  41.      * Instantiates conversion exception for error which occurred when
  42.      * attempting to convert the specified object value to a string.
  43.      * @param value object value which could not be converted
  44.      * @param fromClass class of object value being converted
  45.      * @param cause the specific throwable which caused conversion failure
  46.      */
  47.     public ConversionException(Object value, Class fromClass, Throwable cause) {
  48.         this("could not convert value from class " + fromClass.getName() +
  49.              "to a string", cause);
  50.     }
  51.     /**
  52.      * Instantiates conversion exception for error which occurred when
  53.      * attempting to convert the specified string value to an object
  54.      * of the specified class.
  55.      * @param value string value which could not be converted
  56.      * @param toClass class the value was being converted to
  57.      */
  58.     public ConversionException(String value, Class toClass) {
  59.         this("could not convert string value "" + value + "" to " +
  60.              toClass.getName());
  61.     }
  62.     /**
  63.      * Instantiates conversion exception for error which occurred when
  64.      * attempting to convert the specified string value to an object
  65.      * of the specified class.
  66.      * @param value object value which could not be converted
  67.      * @param toClass class of object value being converted
  68.      * @param cause the specific throwable which caused conversion failure
  69.      */
  70.     public ConversionException(String value, Class toClass, Throwable cause) {
  71.         this("could not convert string value "" + value + "" to " +
  72.              toClass.getName(), cause);
  73.     }
  74.     /**
  75.      * Instantiates conversion exception.
  76.      * @param message String containing description of why exception occurred
  77.      */
  78.     public ConversionException(String message) {
  79.         super(message);
  80.     }
  81.     /**
  82.      * Instantiates conversion exception.
  83.      * @param message String containing description of why exception occurred
  84.      * @param cause the specific throwable which caused conversion failure
  85.      */
  86.     public ConversionException(String message, Throwable cause) {
  87.         super(message, cause);
  88.     }
  89. }