View Javadoc

1   /*
2    * Copyright 2012-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.properties.api.core.domain;
17  
18  import de.smartics.exceptions.i18n.message.MessageParam;
19  import de.smartics.properties.api.core.app.PropertiesCode;
20  
21  /**
22   * Provides context information for errors concerning a property value.
23   */
24  public class PropertyExpressionMessageBean extends
25      PropertyDescriptorMessageBean
26  {
27    // ********************************* Fields *********************************
28  
29    // --- constants ------------------------------------------------------------
30  
31    /**
32     * The class version identifier.
33     */
34    private static final long serialVersionUID = 1L;
35  
36    // --- members --------------------------------------------------------------
37  
38    /**
39     * The expression that failed to be resolved.
40     *
41     * @serial
42     */
43    @MessageParam
44    private final String expression;
45  
46    // ****************************** Initializer *******************************
47  
48    // ****************************** Constructors ******************************
49  
50    /**
51     * Convenience constructor with no message and no root cause.
52     *
53     * @param propertyDescriptor the descriptor of the property raising the
54     *          exception.
55     * @param expression the expression that failed to be resolved.
56     */
57    public PropertyExpressionMessageBean(
58        final PropertyDescriptor propertyDescriptor, final String expression)
59    {
60      this(null, propertyDescriptor, expression);
61    }
62  
63    /**
64     * Convenience constructor with cause.
65     *
66     * @param cause the cause (which is saved for later retrieval by the
67     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
68     *          and indicates that the cause is nonexistent or unknown.)
69     * @param propertyDescriptor the descriptor of the property raising the
70     *          exception.
71     * @param expression the expression that failed to be resolved.
72     */
73    public PropertyExpressionMessageBean(final Throwable cause,
74        final PropertyDescriptor propertyDescriptor, final String expression)
75    {
76      this(PropertyCode.RESOLVE_PROBLEM, cause, propertyDescriptor, expression);
77    }
78  
79    /**
80     * Default constructor.
81     *
82     * @param code the error or exception code of the exception.
83     * @param cause the cause (which is saved for later retrieval by the
84     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
85     *          and indicates that the cause is nonexistent or unknown.)
86     * @param propertyDescriptor the descriptor of the property raising the
87     *          exception.
88     * @param expression the expression that failed to be resolved.
89     */
90    public PropertyExpressionMessageBean(final PropertiesCode code,
91        final Throwable cause, final PropertyDescriptor propertyDescriptor,
92        final String expression)
93    {
94      super(code, cause, propertyDescriptor);
95  
96      this.expression = expression;
97    }
98  
99    // ****************************** Inner Classes *****************************
100 
101   // ********************************* Methods ********************************
102 
103   // --- init -----------------------------------------------------------------
104 
105   // --- get&set --------------------------------------------------------------
106 
107   /**
108    * Returns the expression that failed to be resolved.
109    *
110    * @return the expression that failed to be resolved.
111    */
112   public final String getExpression()
113   {
114     return expression;
115   }
116 
117   // --- business -------------------------------------------------------------
118 
119   // --- object basics --------------------------------------------------------
120 
121 }