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