KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cintoo > messages > error > ErrorCode


1 /*
2  * Copyright 2006 cintoo, Berlin, Germany
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 cintoo.messages.error;
17
18 /**
19  * Represents an error code.
20  *
21  * @author Stephan J. Schmidt
22  * @version $id$
23  * @since 1.0
24  */

25 public class ErrorCode {
26
27   private int errorCode;
28
29   /**
30    * Factory method to create an error code object
31    *
32    * @param errorCode number of the error code
33    * @return created error code
34    */

35   public static ErrorCode error(int errorCode) {
36     return new ErrorCode(errorCode);
37   }
38
39   /**
40    * Construct an error code from the error number
41    *
42    * @param errorCode errorCode
43    */

44   public ErrorCode(int errorCode) {
45     this.errorCode = errorCode;
46   }
47
48   /**
49    * Return a representation of the error code
50    * with the error number
51    *
52    * @return representation of the error code
53    */

54   public String JavaDoc getError() {
55     return String.valueOf(errorCode);
56   }
57
58   /**
59    * Return the error code
60    *
61    * @return error code
62    */

63   public int getCode() {
64     return errorCode;
65   }
66
67   public int hashCode() {
68     return errorCode;
69   }
70
71   public boolean equals(Object JavaDoc obj) {
72     if (null == obj || ! (obj instanceof ErrorCode)) return false;
73     return ((ErrorCode) obj).errorCode == errorCode;
74   }
75 }
76
Popular Tags