001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.el;
018
019import java.util.MissingResourceException;
020import java.util.ResourceBundle;
021
022/**
023 *
024 * <p>This contains all of the non-public constants, including
025 * messsage strings read from the resource file.
026 *
027 * @author Nathan Abramson - Art Technology Group
028 * @author Shawn Bayern
029 *
030 * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: bayard $
031 **/
032
033public class Constants
034{
035  //-------------------------------------
036  // Resources
037
038  static ResourceBundle sResources =
039  ResourceBundle.getBundle ("org.apache.commons.el.Resources");
040
041  //-------------------------------------
042  // Messages from the resource bundle
043  //-------------------------------------
044
045  public static final String EXCEPTION_GETTING_BEANINFO =
046    getStringResource ("EXCEPTION_GETTING_BEANINFO");
047
048  public static final String NULL_EXPRESSION_STRING =
049    getStringResource ("NULL_EXPRESSION_STRING");
050
051  public static final String PARSE_EXCEPTION =
052    getStringResource ("PARSE_EXCEPTION");
053
054  public static final String CANT_GET_PROPERTY_OF_NULL =
055    getStringResource ("CANT_GET_PROPERTY_OF_NULL");
056
057  public static final String NO_SUCH_PROPERTY =
058    getStringResource ("NO_SUCH_PROPERTY");
059
060  public static final String NO_GETTER_METHOD =
061    getStringResource ("NO_GETTER_METHOD");
062
063  public static final String ERROR_GETTING_PROPERTY =
064    getStringResource ("ERROR_GETTING_PROPERTY");
065
066  public static final String CANT_GET_INDEXED_VALUE_OF_NULL =
067    getStringResource ("CANT_GET_INDEXED_VALUE_OF_NULL");
068
069  public static final String CANT_GET_NULL_INDEX =
070    getStringResource ("CANT_GET_NULL_INDEX");
071
072  public static final String NULL_INDEX =
073    getStringResource ("NULL_INDEX");
074
075  public static final String BAD_INDEX_VALUE =
076    getStringResource ("BAD_INDEX_VALUE");
077
078  public static final String EXCEPTION_ACCESSING_LIST =
079    getStringResource ("EXCEPTION_ACCESSING_LIST");
080
081  public static final String EXCEPTION_ACCESSING_ARRAY =
082    getStringResource ("EXCEPTION_ACCESSING_ARRAY");
083
084  public static final String CANT_FIND_INDEX =
085    getStringResource ("CANT_FIND_INDEX");
086
087  public static final String TOSTRING_EXCEPTION =
088    getStringResource ("TOSTRING_EXCEPTION");
089
090  public static final String BOOLEAN_TO_NUMBER =
091    getStringResource ("BOOLEAN_TO_NUMBER");
092
093  public static final String STRING_TO_NUMBER_EXCEPTION =
094    getStringResource ("STRING_TO_NUMBER_EXCEPTION");
095
096  public static final String COERCE_TO_NUMBER =
097    getStringResource ("COERCE_TO_NUMBER");
098
099  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}