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.impl.config.jndi;
17  
18  import static de.smartics.properties.api.config.codes.LibraryCodeNumbers.PROPERTY_STORE_CODE_START;
19  import de.smartics.exceptions.code.NumberCodeInfo;
20  import de.smartics.exceptions.i18n.message.MessageParamsDescriptor;
21  import de.smartics.properties.api.config.codes.ConfigurationsCode;
22  
23  /**
24   * Codes dealing with property store problems.
25   */
26  public enum JndiPropertyStoreCode implements ConfigurationsCode
27  {
28    // ***************************** Enumeration ******************************
29  
30    /**
31     * Failed to get property from store.
32     */
33    @MessageParamsDescriptor(JndiPropertyStoreMessageBean.class)
34    CANNOT_GET_PROPERTY(10),
35  
36    /**
37     * Failed to get property collection from store.
38     */
39    @MessageParamsDescriptor(JndiPropertyStoreMessageBean.class)
40    CANNOT_GET_PROPERTY_COLLECTION(11),
41  
42    /**
43     * Failed to store property in store.
44     */
45    @MessageParamsDescriptor(JndiPropertyStoreMessageBean.class)
46    CANNOT_SET_PROPERTY(12),
47  
48    /**
49     * Failed to delete property from store.
50     */
51    @MessageParamsDescriptor(JndiPropertyStoreMessageBean.class)
52    CANNOT_DELETE_PROPERTY(13),
53  
54    /**
55     * Encountered an invalid configuration key.
56     */
57    @MessageParamsDescriptor(JndiContextMessageBean.class)
58    INVALID_CONFIGURATION_KEY(20);
59  
60    // ******************************** Fields ********************************
61  
62    // --- constants ----------------------------------------------------------
63  
64    // --- members ------------------------------------------------------------
65  
66    /**
67     * The code information.
68     */
69    private final NumberCodeInfo info;
70  
71    // ***************************** Constructors *****************************
72  
73    /**
74     * Default constructor.
75     *
76     * @param minorNumber the minor part of the error code.
77     */
78    private JndiPropertyStoreCode(final Integer minorNumber)
79    {
80      this.info =
81          new NumberCodeInfo("Store", PROPERTY_STORE_CODE_START, minorNumber);
82    }
83  
84    // ******************************** Methods *******************************
85  
86    // --- init ---------------------------------------------------------------
87  
88    // --- get&set ------------------------------------------------------------
89  
90    @Override
91    public String getCode()
92    {
93      return info.getCode();
94    }
95  
96    @Override
97    public String getComponentId()
98    {
99      return info.getComponentId();
100   }
101 
102   @Override
103   public String getDisplayId()
104   {
105     return info.toString();
106   }
107 
108   @Override
109   public Integer getMajorNumber()
110   {
111     return info.getMajorNumber();
112   }
113 
114   @Override
115   public Integer getMinorNumber()
116   {
117     return info.getMinorNumber();
118   }
119 
120   // --- business -----------------------------------------------------------
121 
122   // --- object basics ------------------------------------------------------
123 
124   /**
125    * Returns the string representation of the object.
126    *
127    * @return the string representation of the object.
128    */
129   @Override
130   public String toString()
131   {
132     return getDisplayId();
133   }
134 }