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