View Javadoc

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;
20  
21  import javax.el.ELContext;
22  import javax.faces.context.FacesContext;
23  import javax.faces.el.EvaluationException;
24  import javax.faces.el.PropertyNotFoundException;
25  import javax.faces.el.PropertyResolver;
26  
27  /**
28   * Default PropertyResolver.  See JSF 1.2 spec section 5.8.2
29   *
30   * @author Stan Silvert
31   */
32  public final class NullPropertyResolver extends PropertyResolver
33  {
34  
35      /** Creates a new instance of NullPropertyResolver */
36      public NullPropertyResolver()
37      {
38      }
39  
40      @Override
41      public boolean isReadOnly(Object base, int index) throws EvaluationException, PropertyNotFoundException
42      {
43          elContext().setPropertyResolved(false);
44          return false;
45      }
46  
47      @Override
48      public boolean isReadOnly(Object base, Object property) throws EvaluationException, PropertyNotFoundException
49      {
50          elContext().setPropertyResolved(false);
51          return false;
52      }
53  
54      @Override
55      public Object getValue(Object base, int index) throws EvaluationException, PropertyNotFoundException
56      {
57          elContext().setPropertyResolved(false);
58          return null;
59      }
60  
61      @Override
62      public Object getValue(Object base, Object property) throws EvaluationException, PropertyNotFoundException
63      {
64          elContext().setPropertyResolved(false);
65          return null;
66      }
67  
68      @Override
69      public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException
70      {
71          elContext().setPropertyResolved(false);
72          return null;
73      }
74  
75      @Override
76      public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException
77      {
78          elContext().setPropertyResolved(false);
79          return null;
80      }
81  
82      @Override
83      public void setValue(Object base, Object property, Object value)
84              throws EvaluationException, PropertyNotFoundException
85      {
86          elContext().setPropertyResolved(false);
87      }
88  
89      @Override
90      public void setValue(Object base, int index, Object value) throws EvaluationException, PropertyNotFoundException
91      {
92          elContext().setPropertyResolved(false);
93      }
94  
95      private ELContext elContext()
96      {
97          return FacesContext.getCurrentInstance().getELContext();
98      }
99  
100 }