View Javadoc

1   /*
2    * Copyright 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.resource.filesystem.heap;
17  
18  import de.smartics.exceptions.code.NumberCodeInfo;
19  import de.smartics.exceptions.i18n.message.MessageParamsDescriptor;
20  import de.smartics.properties.resource.app.ResourcesCode;
21  import de.smartics.properties.resource.heap.HeapException;
22  
23  /**
24   * Codes dealing with resource problems on the file system.
25   */
26  public enum FileSystemResourceCode implements ResourcesCode
27  {
28    // ***************************** Enumeration ******************************
29  
30    /**
31     * The target folder cannot be cleaned.
32     */
33    @MessageParamsDescriptor(HeapException.class)
34    FAILED_TO_READ_ARCHIVE_FILE(0);
35  
36    // ******************************** Fields ********************************
37  
38    // --- constants ----------------------------------------------------------
39  
40    // --- members ------------------------------------------------------------
41  
42    /**
43     * The code information.
44     */
45    private final NumberCodeInfo info;
46  
47    // ***************************** Constructors *****************************
48  
49    /**
50     * Default constructor.
51     *
52     * @param minorNumber the minor part of the error code.
53     */
54    private FileSystemResourceCode(final Integer minorNumber)
55    {
56      final int start = 6000;
57      this.info = new NumberCodeInfo("ResourceFile", start, minorNumber);
58    }
59  
60    // ******************************** Methods *******************************
61  
62    // --- init ---------------------------------------------------------------
63  
64    // --- get&set ------------------------------------------------------------
65  
66    @Override
67    public String getCode()
68    {
69      return info.getCode();
70    }
71  
72    @Override
73    public String getComponentId()
74    {
75      return info.getComponentId();
76    }
77  
78    @Override
79    public String getDisplayId()
80    {
81      return info.toString();
82    }
83  
84    @Override
85    public Integer getMajorNumber()
86    {
87      return info.getMajorNumber();
88    }
89  
90    @Override
91    public Integer getMinorNumber()
92    {
93      return info.getMinorNumber();
94    }
95  
96    // --- business -----------------------------------------------------------
97  
98    // --- object basics ------------------------------------------------------
99  
100   /**
101    * Returns the string representation of the object.
102    *
103    * @return the string representation of the object.
104    */
105   @Override
106   public String toString()
107   {
108     return getDisplayId();
109   }
110 }