1 /* 2 * Copyright 2007-2011 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.exceptions.i18n.app; 17 18 import de.smartics.exceptions.code.NumberCode; 19 import de.smartics.exceptions.code.NumberCodeInfo; 20 21 /** 22 * Defines the exception codes for problems with the configuration of the 23 * library. 24 * 25 * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a> 26 * @version $Revision:591 $ 27 */ 28 public enum ConfigurationExceptionCode implements NumberCode 29 { 30 // ****************************** Enumeration ******************************* 31 32 /** 33 * The generic configuration error. 34 */ 35 GENERIC(1000), 36 37 /** 38 * A configuration error signaling missing getter. 39 */ 40 CONFIGURATION_MISSING_GETTER(1000, 1), 41 42 /** 43 * A configuration error signaling an inaccessible getter. 44 */ 45 CONFIGURATION_INACCESSIBLE_GETTER(1000, 2), 46 47 /** 48 * A configuration error signaling a runtime problem while running the getter 49 * method's code. 50 */ 51 CONFIGURATION_RUNTIME_ACCESS(1000, 3), 52 53 /** 54 * A configuration error signaling that the getter method does not exist. 55 */ 56 CONFIGURATION_NOARG(1000, 4), 57 58 /** 59 * A configuration error signaling that accessing the getter raised a security 60 * exception. 61 */ 62 CONFIGURATION_SECURITY(1000, 5), 63 64 /** 65 * A configuration error signaling a runtime problem while accessing the 66 * property. 67 */ 68 CONFIGURATION_PROPERTY_RUNTIME_ACCESS(1000, 6), 69 70 /** 71 * A configuration error signaling that a property is not accessible. 72 */ 73 CONFIGURATION_INACCESSIBLE_PROPERTY(1000, 7), 74 75 /** 76 * A configuration error signaling that there is no getter to access a 77 * property. 78 */ 79 CONFIGURATION_NO_GETTER_FOR_PROPERTY(1000, 8), 80 81 /** 82 * A configuration error signaling that there is an error in the OGNL 83 * expression of a value. 84 */ 85 CONFIGURATION_OGNL_SYNTAX_ERROR(1000, 9), 86 87 /** 88 * A configuration error signaling that values for a compound message a 89 * missing. 90 */ 91 COMPOUND_MESSAGE_MISSING(1000, 10); 92 93 // ********************************* Fields ********************************* 94 95 // --- constants ------------------------------------------------------------ 96 97 // --- members -------------------------------------------------------------- 98 99 /** 100 * The code information. 101 */ 102 private final NumberCodeInfo info; 103 104 // ****************************** Constructors ****************************** 105 106 /** 107 * Convenience constructor. 108 * 109 * @param majorNumber the major part of the error code. 110 */ 111 private ConfigurationExceptionCode(final Integer majorNumber) 112 { 113 this(majorNumber, null); 114 } 115 116 /** 117 * Convenience constructor. 118 * 119 * @param majorNumber the major part of the error code. 120 * @param minorNumber the minor part of the error code. 121 */ 122 private ConfigurationExceptionCode(final Integer majorNumber, 123 final Integer minorNumber) 124 { 125 this(readComponentId(), majorNumber, minorNumber); 126 } 127 128 /** 129 * Default constructor. 130 * 131 * @param componentId the component identifier. 132 * @param majorNumber the major part of the error code. 133 * @param minorNumber the minor part of the error code. 134 */ 135 private ConfigurationExceptionCode(final String componentId, 136 final Integer majorNumber, final Integer minorNumber) 137 { 138 this.info = new NumberCodeInfo(componentId, majorNumber, minorNumber); 139 } 140 141 // ********************************* Methods ******************************** 142 143 // --- init ----------------------------------------------------------------- 144 145 /** 146 * Used to access the identify for the exceptions raised by this component. 147 * 148 * @return the component identifier of this exception library. 149 */ 150 private static String readComponentId() 151 { 152 return Constant.COMPONENT_ID; 153 } 154 155 // --- get&set -------------------------------------------------------------- 156 157 // --- business ------------------------------------------------------------- 158 159 /** 160 * {@inheritDoc} 161 */ 162 // @Override Java 6 feature 163 public String getCode() 164 { 165 return info.getCode(); 166 } 167 168 /** 169 * {@inheritDoc} 170 */ 171 // @Override Java 6 feature 172 public String getComponentId() 173 { 174 return info.getComponentId(); 175 } 176 177 /** 178 * {@inheritDoc} 179 * 180 * @see de.smartics.exceptions.code.NumberCode#getMajorNumber() 181 */ 182 // @Override Java 6 feature 183 public Integer getMajorNumber() 184 { 185 return info.getMajorNumber(); 186 } 187 188 /** 189 * {@inheritDoc} 190 * 191 * @see de.smartics.exceptions.code.NumberCode#getMinorNumber() 192 */ 193 // @Override Java 6 feature 194 public Integer getMinorNumber() 195 { 196 return info.getMinorNumber(); 197 } 198 199 /** 200 * {@inheritDoc} 201 * 202 * @see de.smartics.exceptions.core.Code#getDisplayId() 203 */ 204 public String getDisplayId() 205 { 206 return info.getDisplayId(); 207 } 208 209 // --- object basics -------------------------------------------------------- 210 211 /** 212 * Returns the string representation of the object. 213 * 214 * @return the string representation of the object. 215 */ 216 @Override 217 public String toString() 218 { 219 return info.toString(); 220 } 221 }