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.config.domain;
17  
18  import de.smartics.exceptions.i18n.message.MessageParam;
19  import de.smartics.properties.api.config.domain.key.ConfigurationKey;
20  
21  /**
22   * Signals that configuration with the given key cannot be loaded.
23   */
24  public class ConfigurationLoadingException extends ConfigurationException
25  {
26    // ********************************* Fields *********************************
27  
28    // --- constants ------------------------------------------------------------
29  
30    /**
31     * The class version identifier.
32     * <p>
33     * The value of this constant is {@value}.
34     * </p>
35     */
36    private static final long serialVersionUID = 1L;
37  
38    // --- members --------------------------------------------------------------
39  
40    /**
41     * The string representation of the path of the properties resource that
42     * cannot be loaded. This may be an URL, a file name or whatever seems
43     * appropriate.
44     *
45     * @serial
46     */
47    @MessageParam
48    private final String resourceId;
49  
50    // ****************************** Initializer *******************************
51  
52    // ****************************** Constructors ******************************
53  
54    /**
55     * Convenience constructor without root cause.
56     *
57     * @param key the key to the configuration that signaled problems.
58     * @param resourceId the string representation of the path of the properties
59     *          resource that cannot be loaded.
60     */
61    public ConfigurationLoadingException(final ConfigurationKey<?> key,
62        final String resourceId)
63    {
64      this(null, key, resourceId);
65    }
66  
67    /**
68     * Default Constructor.
69     *
70     * @param cause the cause (which is saved for later retrieval by the
71     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
72     *          and indicates that the cause is nonexistent or unknown.)
73     * @param key the key to the configuration that signaled problems.
74     * @param resourceId the string representation of the path of the properties
75     *          resource that cannot be loaded.
76     */
77    public ConfigurationLoadingException(final Throwable cause,
78        final ConfigurationKey<?> key, final String resourceId)
79    {
80      super(ConfigurationCode.CONFIGURATION_LOADING, cause, key);
81      this.resourceId = resourceId;
82    }
83  
84    // ****************************** Inner Classes *****************************
85  
86    // ********************************* Methods ********************************
87  
88    // --- init -----------------------------------------------------------------
89  
90    // --- get&set --------------------------------------------------------------
91  
92    /**
93     * Returns the string representation of the path of the properties resource
94     * that cannot be loaded. This may be an URL, a file name or whatever seems
95     * appropriate.
96     *
97     * @return the string representation of the path of the properties resource
98     *         that cannot be loaded.
99     */
100   public final String getResourceId()
101   {
102     return resourceId;
103   }
104 
105   // --- business -------------------------------------------------------------
106 
107   // --- object basics --------------------------------------------------------
108 
109 }