View Javadoc

1   /*
2    * Copyright 2007-2013 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  import de.smartics.exceptions.i18n.message.ParentMessageParam;
21  
22  /**
23   * This exception is thrown if the configuration is not valid so that the system
24   * cannot evaluate the exception property.
25   */
26  @ParentMessageParam("cause=2:message")
27  public class MethodAccessConfigurationException extends
28      PropertyAccessConfigurationException
29  {
30    // ********************************* Fields *********************************
31  
32    // --- constants ------------------------------------------------------------
33  
34    /**
35     * The class version identifier.
36     * <p>
37     * The value of this constant is {@value}.
38     */
39    private static final long serialVersionUID = 1L;
40  
41    // --- members --------------------------------------------------------------
42  
43    /**
44     * The name of the getter method that has been tried to accessed.
45     *
46     * @serial
47     */
48    @MessageParam("3")
49    protected final String methodName;
50  
51    // ****************************** Initializer *******************************
52  
53    // ****************************** Constructors ******************************
54  
55    /**
56     * Constructor.
57     *
58     * @param code the error or exception code of the exception.
59     * @param propertyName the name of the property that cannot be accessed.
60     * @param clazz the class that should contain the property but the information
61     *          cannot be accessed.
62     * @param methodName the name of the getter method that has been tried to
63     *          accessed.
64     * @see #MethodAccessConfigurationException(Throwable,ConfigurationExceptionCode,java.lang.String,java.lang.Class,java.lang.String)
65     */
66    public MethodAccessConfigurationException(
67        final ConfigurationExceptionCode code, final String propertyName,
68        final Class<?> clazz, final String methodName)
69    {
70      this(null, code, propertyName, clazz, methodName);
71    }
72  
73    /**
74     * Constructor.
75     *
76     * @param cause the cause (which is saved for later retrieval by the
77     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
78     *          and indicates that the cause is nonexistent or unknown.)
79     * @param code the error or exception code of the exception.
80     * @param propertyName the name of the property that cannot be accessed.
81     * @param clazz the class that should contain the property but the information
82     *          cannot be accessed.
83     * @param methodName the name of the getter method that has been tried to
84     *          accessed.
85     * @see PropertyAccessConfigurationException#PropertyAccessConfigurationException(java.lang.Throwable,ConfigurationExceptionCode,String,Class)
86     */
87    public MethodAccessConfigurationException(final Throwable cause,
88        final ConfigurationExceptionCode code, final String propertyName,
89        final Class<?> clazz, final String methodName)
90    {
91      super(cause, code, propertyName, clazz);
92      this.methodName = methodName;
93    }
94  
95    // ****************************** Inner Classes *****************************
96  
97    // ********************************* Methods ********************************
98  
99    // --- init -----------------------------------------------------------------
100 
101   // --- get&set --------------------------------------------------------------
102 
103   /**
104    * Returns the name of the getter method that has been tried to accessed.
105    *
106    * @return the name of the getter method that has been tried to accessed.
107    */
108   public String getMethodName()
109   {
110     return methodName;
111   }
112 
113   // --- business -------------------------------------------------------------
114 
115   // --- object basics --------------------------------------------------------
116 }