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.spi.config.ds;
17  
18  import static de.smartics.properties.api.config.codes.LibraryCodeNumbers.DATA_SOURCE_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 problems.
25   */
26  public enum DataSourceCode implements ConfigurationsCode
27  {
28    // ***************************** Enumeration ******************************
29  
30    /**
31     * The table containing the properties cannot be created.
32     */
33    @MessageParamsDescriptor(DataSourceMessageBean.class)
34    CANNOT_CREATE_TABLE(0),
35  
36    /**
37     * The table containing the properties cannot be dropped.
38     */
39    @MessageParamsDescriptor(DataSourceMessageBean.class)
40    CANNOT_DROP_TABLE(1),
41  
42    /**
43     * The table containing the properties cannot be accessed for printing.
44     */
45    @MessageParamsDescriptor(DataSourceMessageBean.class)
46    CANNOT_PRINT_TABLE(2),
47  
48    /**
49     * The table containing the properties cannot be accessed to fetch the
50     * configuration keys found therein.
51     */
52    @MessageParamsDescriptor(DataSourceMessageBean.class)
53    CANNOT_ACCESS_CONFIGURATION_KEYS(3),
54  
55    /**
56     * The table containing the properties contains an invalid configuration key.
57     */
58    @MessageParamsDescriptor(DataSourceMessageBean.class)
59    INVALID_CONFIGURATION_KEY(4),
60  
61    /**
62     * Problems accessing the property in the database.
63     */
64    @MessageParamsDescriptor(DataSourcePropertyKeyMessageBean.class)
65    CANNOT_ACCESS_PROPERTY(10),
66  
67    /**
68     * Problems accessing a set of properties in the database.
69     */
70    @MessageParamsDescriptor(DataSourceConfigurationMessageBean.class)
71    CANNOT_ACCESS_PROPERTIES(11),
72  
73    /**
74     * Problems storing the value of a property to the database.
75     */
76    @MessageParamsDescriptor(DataSourcePropertyMessageBean.class)
77    CANNOT_STORE_PROPERTY(12),
78  
79    /**
80     * Problems deleting the value of a property from the database.
81     */
82    @MessageParamsDescriptor(DataSourcePropertyKeyMessageBean.class)
83    CANNOT_DELETE_PROPERTY(13),
84  
85    /**
86     * Problems deleting all property values from the database.
87     */
88    @MessageParamsDescriptor(DataSourceMessageBean.class)
89    CANNOT_DELETE_PROPERTIES(14),
90  
91    /**
92     * Problems storing a set of properties to the database.
93     */
94    @MessageParamsDescriptor(DataSourceConfigurationMessageBean.class)
95    CANNOT_STORE_PROPERTIES(15);
96  
97    // ******************************** Fields ********************************
98  
99    // --- constants ----------------------------------------------------------
100 
101   // --- members ------------------------------------------------------------
102 
103   /**
104    * The code information.
105    */
106   private final NumberCodeInfo info;
107 
108   // ***************************** Constructors *****************************
109 
110   /**
111    * Default constructor.
112    *
113    * @param minorNumber the minor part of the error code.
114    */
115   private DataSourceCode(final Integer minorNumber)
116   {
117     this.info =
118         new NumberCodeInfo("DataSource", DATA_SOURCE_CODE_START, minorNumber);
119   }
120 
121   // ******************************** Methods *******************************
122 
123   // --- init ---------------------------------------------------------------
124 
125   // --- get&set ------------------------------------------------------------
126 
127   @Override
128   public String getCode()
129   {
130     return info.getCode();
131   }
132 
133   @Override
134   public String getComponentId()
135   {
136     return info.getComponentId();
137   }
138 
139   @Override
140   public String getDisplayId()
141   {
142     return info.toString();
143   }
144 
145   @Override
146   public Integer getMajorNumber()
147   {
148     return info.getMajorNumber();
149   }
150 
151   @Override
152   public Integer getMinorNumber()
153   {
154     return info.getMinorNumber();
155   }
156 
157   // --- business -----------------------------------------------------------
158 
159   // --- object basics ------------------------------------------------------
160 
161   /**
162    * Returns the string representation of the object.
163    *
164    * @return the string representation of the object.
165    */
166   @Override
167   public String toString()
168   {
169     return getDisplayId();
170   }
171 }