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