View Javadoc

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   */
32  public enum ErrorCode {
33  	MESSAGE_ACCEPTED(0, "Message accepted"), 
34  	SEGMENT_SEQUENCE_ERROR(100, "Segment sequence error"), 
35  	REQUIRED_FIELD_MISSING(101, "Required field missing"), 
36  	DATA_TYPE_ERROR(102, "Data type error"), 
37  	TABLE_VALUE_NOT_FOUND(103, "Table value not found"),
38  	UNSUPPORTED_MESSAGE_TYPE(200, "Unsupported message type"),
39  	UNSUPPORTED_EVENT_CODE(201, "Unsupported event code"),
40  	UNSUPPORTED_PROCESSING_ID(202, "Unsupported processing id"),
41  	UNSUPPORTED_VERSION_ID(203, "Unsupported version id"),
42  	UNKNOWN_KEY_IDENTIFIER(204, "Unknown key identifier"),
43  	DUPLICATE_KEY_IDENTIFIER(205, "Duplicate key identifier"),
44  	APPLICATION_RECORD_LOCKED(206, "Application record locked"),
45  	APPLICATION_INTERNAL_ERROR(207, "Application internal error");
46  
47  	private static final String HL70357 = "HL70357";
48      private final int code;
49  	private final String message;
50  
51  	ErrorCode(int errCode, String message) {
52  		this.code = errCode;
53  		this.message = message;
54  	}
55  
56      /**
57       * @return the integer error code
58       */
59  	public int getCode() {
60  		return code;
61  	}
62  
63      /**
64       * @return the error code message
65       */
66  	public String getMessage() {
67  		return message;
68  	}
69  
70      /**
71       * Returns the ErrorCode for the given integer
72       * @param errCode integer error code
73       * @return ErrorCode
74       */
75  	public static ErrorCode errorCodeFor(int errCode) {
76  		for (ErrorCode err : ErrorCode.values()) {
77  			if (err.code == errCode) {
78  				return err;
79  			}
80  		}
81  		return null;
82  	}
83  
84      /**
85       * @return the HL7 table number
86       */
87  	public static String codeTable() {
88  		return HL70357;
89  	}
90  }