01: /*
02: * Copyright 1999-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.16 2005/01/23 00:20:47 mcnamara Exp $
18: */
19: package org.apache.xalan.res;
20:
21: import java.util.ListResourceBundle;
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: /** The language specific resource object for Xalan messages. */
33: private static ListResourceBundle XSLTBundle = null;
34:
35: /** The class name of the Xalan error message string table. */
36: private static final String XSLT_ERROR_RESOURCES = "org.apache.xalan.res.XSLTErrorResources";
37:
38: /**
39: * Creates a message from the specified key and replacement
40: * arguments, localized to the given locale.
41: *
42: * @param msgKey The key for the message text.
43: * @param args The arguments to be used as replacement text
44: * in the message created.
45: *
46: * @return The formatted message string.
47: */
48: public static final String createMessage(String msgKey,
49: Object args[]) //throws Exception
50: {
51: if (XSLTBundle == null)
52: XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
53:
54: if (XSLTBundle != null) {
55: return createMsg(XSLTBundle, msgKey, args);
56: } else
57: return "Could not load any resource bundles.";
58: }
59:
60: /**
61: * Creates a message from the specified key and replacement
62: * arguments, localized to the given locale.
63: *
64: * @param msgKey The key for the message text.
65: * @param args The arguments to be used as replacement text
66: * in the message created.
67: *
68: * @return The formatted warning string.
69: */
70: public static final String createWarning(String msgKey,
71: Object args[]) //throws Exception
72: {
73: if (XSLTBundle == null)
74: XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
75:
76: if (XSLTBundle != null) {
77: return createMsg(XSLTBundle, msgKey, args);
78: } else
79: return "Could not load any resource bundles.";
80: }
81: }
|