KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > res > XSLMessages


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
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 /*
17  * $Id: XSLMessages.java,v 1.15 2004/02/16 19:14:07 minchau Exp $
18  */

19 package org.apache.xalan.res;
20
21 import java.util.ListResourceBundle JavaDoc;
22
23 import org.apache.xpath.res.XPATHMessages;
24
25 /**
26  * Sets things up for issuing error messages. This class is misnamed, and
27  * should be called XalanMessages, or some such.
28  * @xsl.usage internal
29  */

30 public class XSLMessages extends XPATHMessages
31 {
32
33   /** The language specific resource object for Xalan messages. */
34   private static ListResourceBundle JavaDoc XSLTBundle = null;
35
36   /** The class name of the Xalan error message string table. */
37   private static final String JavaDoc XSLT_ERROR_RESOURCES =
38     "org.apache.xalan.res.XSLTErrorResources";
39
40   /**
41    * Creates a message from the specified key and replacement
42    * arguments, localized to the given locale.
43    *
44    * @param errorCode The key for the message text.
45    * @param args The arguments to be used as replacement text
46    * in the message created.
47    *
48    * @return The formatted message string.
49    */

50   public static final String JavaDoc createMessage(String JavaDoc msgKey, Object JavaDoc args[]) //throws Exception
51
{
52     if (XSLTBundle == null)
53       XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
54     
55     if (XSLTBundle != null)
56     {
57       return createMsg(XSLTBundle, msgKey, args);
58     }
59     else
60       return "Could not load any resource bundles.";
61   }
62   
63   /**
64    * Creates a message from the specified key and replacement
65    * arguments, localized to the given locale.
66    *
67    * @param msgKey The key for the message text.
68    * @param args The arguments to be used as replacement text
69    * in the message created.
70    *
71    * @return The formatted warning string.
72    */

73   public static final String JavaDoc createWarning(String JavaDoc msgKey, Object JavaDoc args[]) //throws Exception
74
{
75     if (XSLTBundle == null)
76       XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
77
78     if (XSLTBundle != null)
79     {
80       return createMsg(XSLTBundle, msgKey, args);
81     }
82     else
83       return "Could not load any resource bundles.";
84   }
85 }
86
Popular Tags