001/* 002 * jDTAUS Core API 003 * Copyright (C) 2005 Christian Schulte 004 * <cs@schulte.it> 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License, or any later version. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 019 * 020 */ 021package org.jdtaus.core.container; 022 023import java.util.Locale; 024 025/** 026 * Gets thrown for illegal property values. 027 * 028 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 029 * @version $JDTAUS: PropertyException.java 8743 2012-10-07 03:06:20Z schulte $ 030 */ 031public class PropertyException extends IllegalStateException 032{ 033 //--Constants--------------------------------------------------------------- 034 035 /** Serial version UID for backwards compatibility with 1.0.x classes. */ 036 private static final long serialVersionUID = -8921078803137740601L; 037 038 //---------------------------------------------------------------Constants-- 039 //--Constructors------------------------------------------------------------ 040 041 /** 042 * Creates a new instance of {@code PropertyException} taking a property 043 * name and the invalid value. 044 * 045 * @param name the name of the property with invalid value. 046 * @param value the invalid value of the property with name {@code name}. 047 */ 048 public PropertyException( final String name, final Object value ) 049 { 050 super( PropertyExceptionBundle.getInstance(). 051 getPropertyExceptionMessage( Locale.getDefault(), name, 052 value.toString() ) ); 053 054 this.name = name; 055 this.value = value; 056 } 057 058 /** 059 * Creates a new instance of {@code PropertyException} taking a property 060 * name, the invalid value and a causing throwable. 061 * 062 * @param name the name of the property with invalid value. 063 * @param value the invalid value of the property with name {@code name}. 064 * @param cause the causing throwable. 065 */ 066 public PropertyException( final String name, final Object value, 067 final Throwable cause ) 068 { 069 070 super( PropertyExceptionBundle.getInstance(). 071 getPropertyExceptionMessage( Locale.getDefault(), name, 072 value.toString() ) ); 073 074 this.initCause( cause ); 075 this.name = name; 076 this.value = value; 077 } 078 079 //------------------------------------------------------------Constructors-- 080 //--PropertyException------------------------------------------------------- 081 082 /** 083 * The name of the invalid property. 084 * @serial 085 */ 086 private final String name; 087 088 /** 089 * The value of the invalid property. 090 * @serial 091 */ 092 private final Object value; 093 094 /** 095 * Gets the name of the invalid property. 096 * 097 * @return the name of the invalid property or {@code null}. 098 */ 099 public String getName() 100 { 101 return this.name; 102 } 103 104 /** 105 * Gets the value of the invalid property. 106 * 107 * @return the value of the invalid property or {@code null}. 108 */ 109 public Object getValue() 110 { 111 return this.value; 112 } 113 114 //-------------------------------------------------------PropertyException-- 115}