View Javadoc

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 parsing exception codes for this package.
23   *
24   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
25   * @version $Revision:591 $
26   */
27  public enum ParseExceptionCode implements NumberCode
28  {
29    // ****************************** Enumeration *******************************
30  
31    /**
32     * The generic parsing error.
33     */
34    GENERIC(2000),
35  
36    /**
37     * Parsing an OGNL path expression failed.
38     */
39    OGNL(2000, 1),
40  
41    /**
42     * Parsing the value for a parent attribute failed because the <code>=</code>
43     * -sign is missing. The <code>=</code>-sign separates the attribute name from
44     * the index information.
45     * <p>
46     * The parent attribute is an attribute specified by the super class of an
47     * exception. The parent exception may be of a standard library and therefore
48     * cannot be annotated so the annotation is placed in the subclass.
49     * </p>
50     */
51    MISSING_PARENT_PROPERTY_SEPARATOR(2000, 2),
52  
53    /**
54     * Parsing the value for a parent attribute failed because the attribute in
55     * front of the <code>=</code>-sign is missing.
56     * <p>
57     * The parent attribute is an attribute specified by the super class of an
58     * exception. The parent exception may be of a standard library and therefore
59     * cannot be annotated so the annotation is placed in the subclass.
60     * </p>
61     */
62    MISSING_PARENT_PROPERTY_ATTRIBUTE(2000, 3),
63  
64    /**
65     * Parsing the value for a parent attribute failed because the index after the
66     * <code>=</code>-sign is missing.
67     * <p>
68     * The parent attribute is an attribute specified by the super class of an
69     * exception. The parent exception may be of a standard library and therefore
70     * cannot be annotated so the annotation is placed in the subclass.
71     * </p>
72     */
73    MISSING_PARENT_PROPERTY_INDEX(2000, 4);
74  
75    // ********************************* Fields *********************************
76  
77    // --- constants ------------------------------------------------------------
78  
79    // --- members --------------------------------------------------------------
80  
81    /**
82     * The code information.
83     */
84    private final NumberCodeInfo info;
85  
86    // ****************************** Constructors ******************************
87  
88    /**
89     * Convenience constructor.
90     *
91     * @param majorNumber the major part of the error code.
92     */
93    private ParseExceptionCode(final Integer majorNumber)
94    {
95      this(majorNumber, null);
96    }
97  
98    /**
99     * Convenience constructor.
100    *
101    * @param majorNumber the major part of the error code.
102    * @param minorNumber the minor part of the error code.
103    */
104   private ParseExceptionCode(final Integer majorNumber,
105       final Integer minorNumber)
106   {
107     this(readComponentId(), majorNumber, minorNumber);
108   }
109 
110   /**
111    * Default constructor.
112    *
113    * @param componentId the component identifier.
114    * @param majorNumber the major part of the error code.
115    * @param minorNumber the minor part of the error code.
116    */
117   private ParseExceptionCode(final String componentId,
118       final Integer majorNumber, final Integer minorNumber)
119   {
120     this.info = new NumberCodeInfo(componentId, majorNumber, minorNumber);
121   }
122 
123   // ********************************* Methods ********************************
124 
125   // --- init -----------------------------------------------------------------
126 
127   /**
128    * Used to access the identify for the exceptions raised by this component.
129    *
130    * @return the component identifier of this exception library.
131    */
132   private static String readComponentId()
133   {
134     return Constant.COMPONENT_ID;
135   }
136 
137   // --- get&set --------------------------------------------------------------
138 
139   // --- business -------------------------------------------------------------
140 
141   /**
142    * {@inheritDoc}
143    *
144    * @see de.smartics.exceptions.core.Code#getCode()
145    */
146   public String getCode()
147   {
148     return info.getCode();
149   }
150 
151   /**
152    * {@inheritDoc}
153    *
154    * @see de.smartics.exceptions.core.Code#getComponentId()
155    */
156   public String getComponentId()
157   {
158     return info.getComponentId();
159   }
160 
161   /**
162    * {@inheritDoc}
163    *
164    * @see de.smartics.exceptions.code.NumberCode#getMajorNumber()
165    */
166   public Integer getMajorNumber()
167   {
168     return info.getMajorNumber();
169   }
170 
171   /**
172    * {@inheritDoc}
173    *
174    * @see de.smartics.exceptions.code.NumberCode#getMinorNumber()
175    */
176   public Integer getMinorNumber()
177   {
178     return info.getMinorNumber();
179   }
180 
181   /**
182    * {@inheritDoc}
183    *
184    * @see de.smartics.exceptions.core.Code#getDisplayId()
185    */
186   public String getDisplayId()
187   {
188     return info.getDisplayId();
189   }
190 
191   // --- object basics --------------------------------------------------------
192 
193   /**
194    * Returns the string representation of the object.
195    *
196    * @return the string representation of the object.
197    */
198   @Override
199   public String toString()
200   {
201     return info.toString();
202   }
203 }