Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ImplicitObject |
|
| 1.0;1 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package org.apache.myfaces.el.unified.resolver.implicitobject; | |
20 | ||
21 | import java.beans.FeatureDescriptor; | |
22 | import javax.el.ELContext; | |
23 | import javax.el.ELResolver; | |
24 | import javax.faces.context.ExternalContext; | |
25 | import javax.faces.context.FacesContext; | |
26 | ||
27 | /** | |
28 | * Implementors of this class encapsulate the information needed to resolve | |
29 | * the implicit object. | |
30 | * | |
31 | * @author Stan Silvert | |
32 | */ | |
33 | 0 | public abstract class ImplicitObject { |
34 | ||
35 | public abstract Object getValue(ELContext context); | |
36 | ||
37 | public abstract FeatureDescriptor getDescriptor(); | |
38 | ||
39 | /** | |
40 | * Returns an interned String representing the name of the | |
41 | * implicit object. | |
42 | */ | |
43 | public abstract String getName(); | |
44 | ||
45 | /** | |
46 | * Returns the most general type allowed for a future call to setValue() | |
47 | */ | |
48 | public abstract Class getType(); | |
49 | ||
50 | protected FeatureDescriptor makeDescriptor(String name, | |
51 | String description, | |
52 | Class elResolverType) { | |
53 | 0 | FeatureDescriptor fd = new FeatureDescriptor(); |
54 | 0 | fd.setValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE); |
55 | 0 | fd.setValue(ELResolver.TYPE, elResolverType); |
56 | 0 | fd.setName(name); |
57 | 0 | fd.setDisplayName(name); |
58 | 0 | fd.setShortDescription(description); |
59 | 0 | fd.setExpert(false); |
60 | 0 | fd.setHidden(false); |
61 | 0 | fd.setPreferred(true); |
62 | 0 | return fd; |
63 | } | |
64 | ||
65 | // get the FacesContext from the ELContext | |
66 | protected FacesContext facesContext(ELContext context) { | |
67 | 0 | return (FacesContext)context.getContext(FacesContext.class); |
68 | } | |
69 | ||
70 | protected ExternalContext externalContext(ELContext context) { | |
71 | 0 | return facesContext(context).getExternalContext(); |
72 | } | |
73 | ||
74 | } |