KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > publishing > XMLFormErrorCodes


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19
20 package org.openharmonise.rm.publishing;
21
22 import java.util.HashMap JavaDoc;
23
24 /**
25  * Utility class holding error codes and messages used in publishing
26  * <code>Publishable</code> objects.
27  *
28  * @author Michael Bell
29  * @version $Revision: 1.1 $
30  *
31  */

32 public class XMLFormErrorCodes {
33     public static final String JavaDoc TAG_ERRORTEXT = "ErrorText" ;
34     public static final String JavaDoc ATTRIB_ERRORCODE = "errorCode" ;
35     public static String JavaDoc OBJECT_NAME_EXISTS = "OBJECT_NAME_EXISTS";
36     public static String JavaDoc NO_VALUE = "NO_VALUE";
37     public static String JavaDoc EXCEEDS_SIZE = "EXCEEDS_SIZE";
38     public static String JavaDoc MANDATORY_FIELD = "MANDATORY_FIELD";
39     private static XMLFormErrorCodes m_instance;
40     private static HashMap JavaDoc code_map;
41
42     private XMLFormErrorCodes() {
43         code_map = new HashMap JavaDoc(10);
44         code_map.put("OBJECT_NAME_EXISTS",
45                      "An object with this name already exists");
46         code_map.put("NO_VALUE", "A value must be entered"); // for fields where mandatory is not optional
47
code_map.put("EXCEEDS_SIZE", "This entry exceeds the maximum size");
48         code_map.put("MANDATORY_FIELD", "This field is mandatory");
49     }
50
51     public static synchronized XMLFormErrorCodes getInstance() {
52         if (m_instance == null) {
53             m_instance = new XMLFormErrorCodes();
54         }
55
56         return m_instance;
57     }
58
59     public String JavaDoc getErrorText(String JavaDoc error_code) {
60         return (String JavaDoc) code_map.get(error_code);
61     }
62 }
Popular Tags