Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ErrorCode |
|
| 1.6;1.6 |
1 | /** | |
2 | The contents of this file are subject to the Mozilla Public License Version 1.1 | |
3 | (the "License"); you may not use this file except in compliance with the License. | |
4 | You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
5 | Software distributed under the License is distributed on an "AS IS" basis, | |
6 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | |
7 | specific language governing rights and limitations under the License. | |
8 | ||
9 | The Original Code is "ErrorCode.java". Description: | |
10 | "Error code enumeration." | |
11 | ||
12 | The Initial Developer of the Original Code is University Health Network. Copyright (C) | |
13 | 2012. All Rights Reserved. | |
14 | ||
15 | Contributor(s): ______________________________________. | |
16 | ||
17 | Alternatively, the contents of this file may be used under the terms of the | |
18 | GNU General Public License (the "GPL"), in which case the provisions of the GPL are | |
19 | applicable instead of those above. If you wish to allow use of your version of this | |
20 | file only under the terms of the GPL and not to allow others to use your version | |
21 | of this file under the MPL, indicate your decision by deleting the provisions above | |
22 | and replace them with the notice and other provisions required by the GPL License. | |
23 | If you do not delete the provisions above, a recipient may use your version of | |
24 | this file under either the MPL or the GPL. | |
25 | */ | |
26 | package ca.uhn.hl7v2; | |
27 | ||
28 | /** | |
29 | * Error code table | |
30 | */ | |
31 | 245 | public enum ErrorCode { |
32 | 5 | MESSAGE_ACCEPTED(0, "Message accepted"), |
33 | 5 | SEGMENT_SEQUENCE_ERROR(100, "Segment sequence error"), |
34 | 5 | REQUIRED_FIELD_MISSING(101, "Required field missing"), |
35 | 5 | DATA_TYPE_ERROR(102, "Data type error"), |
36 | 5 | TABLE_VALUE_NOT_FOUND(103, "Table value not found"), |
37 | 5 | UNSUPPORTED_MESSAGE_TYPE(200, "Unsupported message type"), |
38 | 5 | UNSUPPORTED_EVENT_CODE(201, "Unsupported event code"), |
39 | 5 | UNSUPPORTED_PROCESSING_ID(202, "Unsupported processing id"), |
40 | 5 | UNSUPPORTED_VERSION_ID(203, "Unsupported version id"), |
41 | 5 | UNKNOWN_KEY_IDENTIFIER(204, "Unknown key identifier"), |
42 | 5 | DUPLICATE_KEY_IDENTIFIER(205, "Duplicate key identifier"), |
43 | 5 | APPLICATION_RECORD_LOCKED(206, "Application record locked"), |
44 | 5 | APPLICATION_INTERNAL_ERROR(207, "Application internal error"); |
45 | ||
46 | private static final String HL70357 = "HL70357"; | |
47 | private final int code; | |
48 | private final String message; | |
49 | ||
50 | 65 | ErrorCode(int errCode, String message) { |
51 | 65 | this.code = errCode; |
52 | 65 | this.message = message; |
53 | 65 | } |
54 | ||
55 | /** | |
56 | * @return the integer error code | |
57 | */ | |
58 | public int getCode() { | |
59 | 605 | return code; |
60 | } | |
61 | ||
62 | /** | |
63 | * @return the error code message | |
64 | */ | |
65 | public String getMessage() { | |
66 | 695 | return message; |
67 | } | |
68 | ||
69 | /** | |
70 | * Returns the ErrorCode for the given integer | |
71 | * @param errCode integer error code | |
72 | * @return ErrorCode | |
73 | */ | |
74 | public static ErrorCode errorCodeFor(int errCode) { | |
75 | 3060 | for (ErrorCode err : ErrorCode.values()) { |
76 | 3060 | if (err.code == errCode) { |
77 | 240 | return err; |
78 | } | |
79 | } | |
80 | 0 | return null; |
81 | } | |
82 | ||
83 | /** | |
84 | * @return the HL7 table number | |
85 | */ | |
86 | public static String codeTable() { | |
87 | 370 | return HL70357; |
88 | } | |
89 | } |