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 com.sun.org.apache.xalan.internal.res;
  20. import java.util.ListResourceBundle;
  21. import com.sun.org.apache.xpath.internal.res.XPATHMessages;
  22. /**
  23. * Sets things up for issuing error messages. This class is misnamed, and
  24. * should be called XalanMessages, or some such.
  25. * @xsl.usage internal
  26. */
  27. public class XSLMessages extends XPATHMessages
  28. {
  29. /** The language specific resource object for Xalan messages. */
  30. private static ListResourceBundle XSLTBundle = null;
  31. /** The class name of the Xalan error message string table. */
  32. private static final String XSLT_ERROR_RESOURCES =
  33. "com.sun.org.apache.xalan.internal.res.XSLTErrorResources";
  34. /**
  35. * Creates a message from the specified key and replacement
  36. * arguments, localized to the given locale.
  37. *
  38. * @param errorCode The key for the message text.
  39. * @param args The arguments to be used as replacement text
  40. * in the message created.
  41. *
  42. * @return The formatted message string.
  43. */
  44. public static final String createMessage(String msgKey, Object args[]) //throws Exception
  45. {
  46. if (XSLTBundle == null)
  47. XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
  48. if (XSLTBundle != null)
  49. {
  50. return createMsg(XSLTBundle, msgKey, args);
  51. }
  52. else
  53. return "Could not load any resource bundles.";
  54. }
  55. /**
  56. * Creates a message from the specified key and replacement
  57. * arguments, localized to the given locale.
  58. *
  59. * @param msgKey The key for the message text.
  60. * @param args The arguments to be used as replacement text
  61. * in the message created.
  62. *
  63. * @return The formatted warning string.
  64. */
  65. public static final String createWarning(String msgKey, Object args[]) //throws Exception
  66. {
  67. if (XSLTBundle == null)
  68. XSLTBundle = loadResourceBundle(XSLT_ERROR_RESOURCES);
  69. if (XSLTBundle != null)
  70. {
  71. return createMsg(XSLTBundle, msgKey, args);
  72. }
  73. else
  74. return "Could not load any resource bundles.";
  75. }
  76. }