1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. * Copyright (c) 1999 The Apache Software Foundation. All rights
  5. * reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. *
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if
  20. * any, must include the following acknowlegement:
  21. * "This product includes software developed by the
  22. * Apache Software Foundation (http://www.apache.org/)."
  23. * Alternately, this acknowlegement may appear in the software itself,
  24. * if and wherever such third-party acknowlegements normally appear.
  25. *
  26. * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  27. * Foundation" must not be used to endorse or promote products derived
  28. * from this software without prior written permission. For written
  29. * permission, please contact apache@apache.org.
  30. *
  31. * 5. Products derived from this software may not be called "Apache"
  32. * nor may "Apache" appear in their names without prior written
  33. * permission of the Apache Group.
  34. *
  35. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46. * SUCH DAMAGE.
  47. * ====================================================================
  48. *
  49. * This software consists of voluntary contributions made by many
  50. * individuals on behalf of the Apache Software Foundation. For more
  51. * information on the Apache Software Foundation, please see
  52. * <http://www.apache.org/>.
  53. *
  54. */
  55. package org.apache.commons.el;
  56. import java.util.ResourceBundle;
  57. import java.util.MissingResourceException;
  58. /**
  59. *
  60. * <p>This contains all of the non-public constants, including
  61. * messsage strings read from the resource file.
  62. *
  63. * @author Nathan Abramson - Art Technology Group
  64. * @author Shawn Bayern
  65. *
  66. * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: luehe $
  67. **/
  68. public class Constants
  69. {
  70. //-------------------------------------
  71. // Resources
  72. static ResourceBundle sResources =
  73. ResourceBundle.getBundle ("org.apache.commons.el.Resources");
  74. //-------------------------------------
  75. // Messages from the resource bundle
  76. //-------------------------------------
  77. public static final String EXCEPTION_GETTING_BEANINFO =
  78. getStringResource ("EXCEPTION_GETTING_BEANINFO");
  79. public static final String NULL_EXPRESSION_STRING =
  80. getStringResource ("NULL_EXPRESSION_STRING");
  81. public static final String PARSE_EXCEPTION =
  82. getStringResource ("PARSE_EXCEPTION");
  83. public static final String CANT_GET_PROPERTY_OF_NULL =
  84. getStringResource ("CANT_GET_PROPERTY_OF_NULL");
  85. public static final String NO_SUCH_PROPERTY =
  86. getStringResource ("NO_SUCH_PROPERTY");
  87. public static final String NO_GETTER_METHOD =
  88. getStringResource ("NO_GETTER_METHOD");
  89. public static final String ERROR_GETTING_PROPERTY =
  90. getStringResource ("ERROR_GETTING_PROPERTY");
  91. public static final String CANT_GET_INDEXED_VALUE_OF_NULL =
  92. getStringResource ("CANT_GET_INDEXED_VALUE_OF_NULL");
  93. public static final String CANT_GET_NULL_INDEX =
  94. getStringResource ("CANT_GET_NULL_INDEX");
  95. public static final String NULL_INDEX =
  96. getStringResource ("NULL_INDEX");
  97. public static final String BAD_INDEX_VALUE =
  98. getStringResource ("BAD_INDEX_VALUE");
  99. public static final String EXCEPTION_ACCESSING_LIST =
  100. getStringResource ("EXCEPTION_ACCESSING_LIST");
  101. public static final String EXCEPTION_ACCESSING_ARRAY =
  102. getStringResource ("EXCEPTION_ACCESSING_ARRAY");
  103. public static final String CANT_FIND_INDEX =
  104. getStringResource ("CANT_FIND_INDEX");
  105. public static final String TOSTRING_EXCEPTION =
  106. getStringResource ("TOSTRING_EXCEPTION");
  107. public static final String BOOLEAN_TO_NUMBER =
  108. getStringResource ("BOOLEAN_TO_NUMBER");
  109. public static final String STRING_TO_NUMBER_EXCEPTION =
  110. getStringResource ("STRING_TO_NUMBER_EXCEPTION");
  111. public static final String COERCE_TO_NUMBER =
  112. getStringResource ("COERCE_TO_NUMBER");
  113. public static final String BOOLEAN_TO_CHARACTER =
  114. getStringResource ("BOOLEAN_TO_CHARACTER");
  115. public static final String EMPTY_STRING_TO_CHARACTER =
  116. getStringResource ("EMPTY_STRING_TO_CHARACTER");
  117. public static final String COERCE_TO_CHARACTER =
  118. getStringResource ("COERCE_TO_CHARACTER");
  119. public static final String NULL_TO_BOOLEAN =
  120. getStringResource ("NULL_TO_BOOLEAN");
  121. public static final String STRING_TO_BOOLEAN =
  122. getStringResource ("STRING_TO_BOOLEAN");
  123. public static final String COERCE_TO_BOOLEAN =
  124. getStringResource ("COERCE_TO_BOOLEAN");
  125. public static final String COERCE_TO_OBJECT =
  126. getStringResource ("COERCE_TO_OBJECT");
  127. public static final String NO_PROPERTY_EDITOR =
  128. getStringResource ("NO_PROPERTY_EDITOR");
  129. public static final String PROPERTY_EDITOR_ERROR =
  130. getStringResource ("PROPERTY_EDITOR_ERROR");
  131. public static final String ARITH_OP_NULL =
  132. getStringResource ("ARITH_OP_NULL");
  133. public static final String ARITH_OP_BAD_TYPE =
  134. getStringResource ("ARITH_OP_BAD_TYPE");
  135. public static final String ARITH_ERROR =
  136. getStringResource ("ARITH_ERROR");
  137. public static final String ERROR_IN_EQUALS =
  138. getStringResource ("ERROR_IN_EQUALS");
  139. public static final String UNARY_OP_BAD_TYPE =
  140. getStringResource ("UNARY_OP_BAD_TYPE");
  141. public static final String NAMED_VALUE_NOT_FOUND =
  142. getStringResource ("NAMED_VALUE_NOT_FOUND");
  143. public static final String CANT_GET_INDEXED_PROPERTY =
  144. getStringResource ("CANT_GET_INDEXED_PROPERTY");
  145. public static final String COMPARABLE_ERROR =
  146. getStringResource ("COMPARABLE_ERROR");
  147. public static final String BAD_IMPLICIT_OBJECT =
  148. getStringResource ("BAD_IMPLICIT_OBJECT");
  149. public static final String ATTRIBUTE_EVALUATION_EXCEPTION =
  150. getStringResource ("ATTRIBUTE_EVALUATION_EXCEPTION");
  151. public static final String ATTRIBUTE_PARSE_EXCEPTION =
  152. getStringResource ("ATTRIBUTE_PARSE_EXCEPTION");
  153. public static final String UNKNOWN_FUNCTION =
  154. getStringResource ("UNKNOWN_FUNCTION");
  155. public static final String INAPPROPRIATE_FUNCTION_ARG_COUNT =
  156. getStringResource ("INAPPROPRIATE_FUNCTION_ARG_COUNT");
  157. public static final String FUNCTION_INVOCATION_ERROR =
  158. getStringResource ("FUNCTION_INVOCATION_ERROR");
  159. //-------------------------------------
  160. // Getting resources
  161. //-------------------------------------
  162. /**
  163. *
  164. *
  165. **/
  166. public static String getStringResource (String pResourceName)
  167. throws MissingResourceException
  168. {
  169. try {
  170. String ret = sResources.getString (pResourceName);
  171. if (ret == null) {
  172. String str = "ERROR: Unable to load resource " + pResourceName;
  173. System.err.println (str);
  174. throw new MissingResourceException
  175. (str,
  176. "org.apache.commons.el.Constants",
  177. pResourceName);
  178. }
  179. else {
  180. return ret;
  181. }
  182. }
  183. catch (MissingResourceException exc) {
  184. System.err.println ("ERROR: Unable to load resource " +
  185. pResourceName +
  186. ": " +
  187. exc);
  188. throw exc;
  189. }
  190. }
  191. //-------------------------------------
  192. }