01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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:
18: package javax.el;
19:
20: import java.text.MessageFormat;
21: import java.util.Iterator;
22: import java.util.Locale;
23: import java.util.MissingResourceException;
24: import java.util.ResourceBundle;
25:
26: /**
27: * @author Jacob Hookom [jacob/hookom.net]
28: *
29: */
30: public abstract class ELResolver {
31:
32: static String message(ELContext context, String name, Object[] props) {
33: Locale locale = context.getLocale();
34: if (locale == null) {
35: locale = Locale.getDefault();
36: if (locale == null) {
37: return "";
38: }
39: }
40: ResourceBundle bundle = ResourceBundle.getBundle(
41: "javax.el.LocalStrings", locale);
42: try {
43: String template = bundle.getString(name);
44: if (props != null) {
45: template = MessageFormat.format(template, props);
46: }
47: return template;
48: } catch (MissingResourceException e) {
49: return "Missing Resource: '" + name + "' for Locale "
50: + locale.getDisplayName();
51: }
52: }
53:
54: public final static String RESOLVABLE_AT_DESIGN_TIME = "resolvableAtDesignTime";
55:
56: public final static String TYPE = "type";
57:
58: public abstract Object getValue(ELContext context, Object base,
59: Object property) throws NullPointerException,
60: PropertyNotFoundException, ELException;
61:
62: public abstract Class<?> getType(ELContext context, Object base,
63: Object property) throws NullPointerException,
64: PropertyNotFoundException, ELException;
65:
66: public abstract void setValue(ELContext context, Object base,
67: Object property, Object value) throws NullPointerException,
68: PropertyNotFoundException, PropertyNotWritableException,
69: ELException;
70:
71: public abstract boolean isReadOnly(ELContext context, Object base,
72: Object property) throws NullPointerException,
73: PropertyNotFoundException, ELException;
74:
75: public abstract Iterator<java.beans.FeatureDescriptor> getFeatureDescriptors(
76: ELContext context, Object base);
77:
78: public abstract Class<?> getCommonPropertyType(ELContext context,
79: Object base);
80: }
|