ohair | 6c32066 | 2012-03-04 11:55:34 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * reserved comment block |
| 3 | * DO NOT REMOVE OR ALTER! |
| 4 | */ |
| 5 | /* |
| 6 | * Copyright 1999-2004 The Apache Software Foundation. |
| 7 | * |
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | * you may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | * |
| 14 | * Unless required by applicable law or agreed to in writing, software |
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | * See the License for the specific language governing permissions and |
| 18 | * limitations under the License. |
| 19 | */ |
| 20 | /* |
| 21 | * $Id: XSLMessages.java,v 1.2.4.1 2005/09/09 07:41:10 pvedula Exp $ |
| 22 | */ |
| 23 | package com.sun.org.apache.xalan.internal.res; |
| 24 | |
| 25 | import java.util.ListResourceBundle; |
| 26 | |
| 27 | import com.sun.org.apache.xpath.internal.res.XPATHMessages; |
| 28 | |
| 29 | /** |
| 30 | * Sets things up for issuing error messages. This class is misnamed, and |
| 31 | * should be called XalanMessages, or some such. |
| 32 | * @xsl.usage internal |
| 33 | */ |
| 34 | public class XSLMessages extends XPATHMessages |
| 35 | { |
| 36 | |
| 37 | /** The language specific resource object for Xalan messages. */ |
| 38 | private static ListResourceBundle XSLTBundle = null; |
| 39 | |
| 40 | /** The class name of the Xalan error message string table. */ |
| 41 | private static final String XSLT_ERROR_RESOURCES = |
| 42 | "com.sun.org.apache.xalan.internal.res.XSLTErrorResources"; |
| 43 | |
| 44 | /** |
| 45 | * Creates a message from the specified key and replacement |
| 46 | * arguments, localized to the given locale. |
| 47 | * |
| 48 | * @param msgKey The key for the message text. |
| 49 | * @param args The arguments to be used as replacement text |
| 50 | * in the message created. |
| 51 | * |
| 52 | * @return The formatted message string. |
| 53 | */ |
| 54 | public static final String createMessage(String msgKey, Object args[]) //throws Exception |
| 55 | { |
| 56 | if (XSLTBundle == null) |
| 57 | XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES); |
| 58 | |
| 59 | if (XSLTBundle != null) |
| 60 | { |
| 61 | return createMsg(XSLTBundle, msgKey, args); |
| 62 | } |
| 63 | else |
| 64 | return "Could not load any resource bundles."; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Creates a message from the specified key and replacement |
| 69 | * arguments, localized to the given locale. |
| 70 | * |
| 71 | * @param msgKey The key for the message text. |
| 72 | * @param args The arguments to be used as replacement text |
| 73 | * in the message created. |
| 74 | * |
| 75 | * @return The formatted warning string. |
| 76 | */ |
| 77 | public static final String createWarning(String msgKey, Object args[]) //throws Exception |
| 78 | { |
| 79 | if (XSLTBundle == null) |
| 80 | XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES); |
| 81 | |
| 82 | if (XSLTBundle != null) |
| 83 | { |
| 84 | return createMsg(XSLTBundle, msgKey, args); |
| 85 | } |
| 86 | else |
| 87 | return "Could not load any resource bundles."; |
| 88 | } |
| 89 | } |