View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.el;
18  
19  import java.util.MissingResourceException;
20  import java.util.ResourceBundle;
21  
22  /**
23   *
24   * <p>This contains all of the non-public constants, including
25   * messsage strings read from the resource file.
26   *
27   * @author Nathan Abramson - Art Technology Group
28   * @author Shawn Bayern
29   *
30   * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: bayard $
31   **/
32  
33  public class Constants
34  {
35    //-------------------------------------
36    // Resources
37  
38    static ResourceBundle sResources =
39    ResourceBundle.getBundle ("org.apache.commons.el.Resources");
40  
41    //-------------------------------------
42    // Messages from the resource bundle
43    //-------------------------------------
44  
45    public static final String EXCEPTION_GETTING_BEANINFO =
46      getStringResource ("EXCEPTION_GETTING_BEANINFO");
47  
48    public static final String NULL_EXPRESSION_STRING =
49      getStringResource ("NULL_EXPRESSION_STRING");
50  
51    public static final String PARSE_EXCEPTION =
52      getStringResource ("PARSE_EXCEPTION");
53  
54    public static final String CANT_GET_PROPERTY_OF_NULL =
55      getStringResource ("CANT_GET_PROPERTY_OF_NULL");
56  
57    public static final String NO_SUCH_PROPERTY =
58      getStringResource ("NO_SUCH_PROPERTY");
59  
60    public static final String NO_GETTER_METHOD =
61      getStringResource ("NO_GETTER_METHOD");
62  
63    public static final String ERROR_GETTING_PROPERTY =
64      getStringResource ("ERROR_GETTING_PROPERTY");
65  
66    public static final String CANT_GET_INDEXED_VALUE_OF_NULL =
67      getStringResource ("CANT_GET_INDEXED_VALUE_OF_NULL");
68  
69    public static final String CANT_GET_NULL_INDEX =
70      getStringResource ("CANT_GET_NULL_INDEX");
71  
72    public static final String NULL_INDEX =
73      getStringResource ("NULL_INDEX");
74  
75    public static final String BAD_INDEX_VALUE =
76      getStringResource ("BAD_INDEX_VALUE");
77  
78    public static final String EXCEPTION_ACCESSING_LIST =
79      getStringResource ("EXCEPTION_ACCESSING_LIST");
80  
81    public static final String EXCEPTION_ACCESSING_ARRAY =
82      getStringResource ("EXCEPTION_ACCESSING_ARRAY");
83  
84    public static final String CANT_FIND_INDEX =
85      getStringResource ("CANT_FIND_INDEX");
86  
87    public static final String TOSTRING_EXCEPTION =
88      getStringResource ("TOSTRING_EXCEPTION");
89  
90    public static final String BOOLEAN_TO_NUMBER =
91      getStringResource ("BOOLEAN_TO_NUMBER");
92  
93    public static final String STRING_TO_NUMBER_EXCEPTION =
94      getStringResource ("STRING_TO_NUMBER_EXCEPTION");
95  
96    public static final String COERCE_TO_NUMBER =
97      getStringResource ("COERCE_TO_NUMBER");
98  
99    public static final String BOOLEAN_TO_CHARACTER =
100     getStringResource ("BOOLEAN_TO_CHARACTER");
101 
102   public static final String EMPTY_STRING_TO_CHARACTER =
103     getStringResource ("EMPTY_STRING_TO_CHARACTER");
104 
105   public static final String COERCE_TO_CHARACTER =
106     getStringResource ("COERCE_TO_CHARACTER");
107 
108   public static final String NULL_TO_BOOLEAN =
109     getStringResource ("NULL_TO_BOOLEAN");
110 
111   public static final String STRING_TO_BOOLEAN =
112     getStringResource ("STRING_TO_BOOLEAN");
113 
114   public static final String COERCE_TO_BOOLEAN =
115     getStringResource ("COERCE_TO_BOOLEAN");
116 
117   public static final String COERCE_TO_OBJECT =
118     getStringResource ("COERCE_TO_OBJECT");
119 
120   public static final String NO_PROPERTY_EDITOR =
121     getStringResource ("NO_PROPERTY_EDITOR");
122 
123   public static final String PROPERTY_EDITOR_ERROR =
124     getStringResource ("PROPERTY_EDITOR_ERROR");
125 
126   public static final String ARITH_OP_NULL =
127     getStringResource ("ARITH_OP_NULL");
128 
129   public static final String ARITH_OP_BAD_TYPE =
130     getStringResource ("ARITH_OP_BAD_TYPE");
131 
132   public static final String ARITH_ERROR =
133     getStringResource ("ARITH_ERROR");
134 
135   public static final String ERROR_IN_EQUALS =
136     getStringResource ("ERROR_IN_EQUALS");
137 
138   public static final String UNARY_OP_BAD_TYPE =
139     getStringResource ("UNARY_OP_BAD_TYPE");
140 
141   public static final String NAMED_VALUE_NOT_FOUND =
142     getStringResource ("NAMED_VALUE_NOT_FOUND");
143 
144   public static final String CANT_GET_INDEXED_PROPERTY =
145     getStringResource ("CANT_GET_INDEXED_PROPERTY");
146 
147   public static final String COMPARABLE_ERROR =
148     getStringResource ("COMPARABLE_ERROR");
149 
150   public static final String BAD_IMPLICIT_OBJECT =
151     getStringResource ("BAD_IMPLICIT_OBJECT");
152 
153   public static final String ATTRIBUTE_EVALUATION_EXCEPTION =
154     getStringResource ("ATTRIBUTE_EVALUATION_EXCEPTION");
155 
156   public static final String ATTRIBUTE_PARSE_EXCEPTION =
157     getStringResource ("ATTRIBUTE_PARSE_EXCEPTION");
158 
159   public static final String UNKNOWN_FUNCTION =
160     getStringResource ("UNKNOWN_FUNCTION");
161 
162   public static final String INAPPROPRIATE_FUNCTION_ARG_COUNT =
163     getStringResource ("INAPPROPRIATE_FUNCTION_ARG_COUNT");
164 
165   public static final String FUNCTION_INVOCATION_ERROR =
166     getStringResource ("FUNCTION_INVOCATION_ERROR");
167 
168 
169   //-------------------------------------
170   // Getting resources
171   //-------------------------------------
172   /**
173    *
174    * 
175    **/
176   public static String getStringResource (String pResourceName)
177     throws MissingResourceException
178   {
179     try {
180       String ret = sResources.getString (pResourceName);
181       if (ret == null) {
182 	String str = "ERROR: Unable to load resource " + pResourceName;
183 	System.err.println (str);
184 	throw new MissingResourceException 
185 	  (str, 
186 	   "org.apache.commons.el.Constants",
187 	   pResourceName);
188       }
189       else {
190 	return ret;
191       }
192     }
193     catch (MissingResourceException exc) {
194       System.err.println ("ERROR: Unable to load resource " +
195 			  pResourceName +
196 			  ": " +
197 			  exc);
198       throw exc;
199     }
200   }
201 
202   //-------------------------------------
203 }