View Javadoc

1   /*
2    * Copyright 2007-2011 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.exceptions.i18n;
17  
18  import de.smartics.exceptions.i18n.app.ConfigurationExceptionCode;
19  import de.smartics.exceptions.i18n.message.MessageParam;
20  
21  /**
22   * This exception is thrown if the configuration is not valid so that the system
23   * cannot evaluate the exception property.
24   * <p>
25   * This exception and all subclasses of this exception share the resource bundle
26   * with {@link ConfigurationException}. This may change in future and is not
27   * considered to be part of the public API.
28   *
29   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
30   * @version $Revision:591 $
31   */
32  public class PropertyAccessConfigurationException extends
33      ConfigurationException
34  {
35    // ********************************* Fields *********************************
36  
37    // --- constants ------------------------------------------------------------
38  
39    /**
40     * The class version identifier.
41     * <p>
42     * The value of this constant is {@value}.
43     */
44    private static final long serialVersionUID = 1L;
45  
46    // --- members --------------------------------------------------------------
47  
48    /**
49     * The class that should contain the property but the information cannot be
50     * accessed.
51     *
52     * @serial
53     */
54    @MessageParam("0:canonicalName")
55    protected final Class<?> clazz;
56  
57    /**
58     * The name of the property that cannot be accessed.
59     *
60     * @serial
61     */
62    @MessageParam("1")
63    protected final String propertyName;
64  
65    // ****************************** Initializer *******************************
66  
67    // ****************************** Constructors ******************************
68  
69    /**
70     * Constructor.
71     *
72     * @param code the error or exception code of the exception.
73     * @param propertyName the name of the property that cannot be accessed.
74     * @param clazz the class that should contain the property but the information
75     *          cannot be accessed.
76     * @see #PropertyAccessConfigurationException(Throwable,ConfigurationExceptionCode,String,Class)
77     */
78    public PropertyAccessConfigurationException(
79        final ConfigurationExceptionCode code, final String propertyName,
80        final Class<?> clazz)
81    {
82      this(null, code, propertyName, clazz);
83    }
84  
85    /**
86     * Constructor.
87     *
88     * @param cause the cause (which is saved for later retrieval by the
89     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
90     *          and indicates that the cause is nonexistent or unknown.)
91     * @param code the error or exception code of the exception.
92     * @param propertyName the name of the property that cannot be accessed.
93     * @param clazz the class that should contain the property but the information
94     *          cannot be accessed.
95     */
96    public PropertyAccessConfigurationException(final Throwable cause,
97        final ConfigurationExceptionCode code, final String propertyName,
98        final Class<?> clazz)
99    {
100     super(cause, code, null);
101     this.propertyName = propertyName;
102     this.clazz = clazz;
103   }
104 
105   // ****************************** Inner Classes *****************************
106 
107   // ********************************* Methods ********************************
108 
109   // --- init -----------------------------------------------------------------
110 
111   // --- get&set --------------------------------------------------------------
112 
113   /**
114    * Returns the name of the property that cannot be accessed.
115    *
116    * @return the name of the property that cannot be accessed.
117    */
118   public String getPropertyName()
119   {
120     return propertyName;
121   }
122 
123   /**
124    * Returns the class that should contain the property but the information
125    * cannot be accessed.
126    *
127    * @return the class that should contain the property but the information
128    *         cannot be accessed.
129    */
130   public Class<?> getClazz()
131   {
132     return clazz;
133   }
134 
135   // --- business -------------------------------------------------------------
136 
137   // --- object basics --------------------------------------------------------
138 }