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.view.facelets.el;
20  
21  import java.io.Externalizable;
22  import java.io.IOException;
23  import java.io.ObjectInput;
24  import java.io.ObjectOutput;
25  import javax.el.ELContext;
26  import javax.el.ValueExpression;
27  import javax.el.ValueReference;
28  import javax.faces.FacesWrapper;
29  
30  /**
31   *
32   */
33  public class CacheableValueExpressionWrapper extends ValueExpression
34      implements FacesWrapper<ValueExpression>, Externalizable, CacheableValueExpression
35  {
36      private static final long serialVersionUID = -5636849184764526288L;
37      
38      ValueExpression delegate;
39  
40      public CacheableValueExpressionWrapper()
41      {
42      }
43  
44      public CacheableValueExpressionWrapper(ValueExpression delegate)
45      {
46          this.delegate = delegate;
47      }
48      
49      @Override
50      public Class<?> getExpectedType()
51      {
52          return delegate.getExpectedType();
53      }
54  
55      @Override
56      public Class<?> getType(ELContext context)
57      {
58          return delegate.getType(context);
59      }
60  
61      @Override
62      public Object getValue(ELContext context)
63      {
64          return delegate.getValue(context);
65      }
66  
67      @Override
68      public boolean isReadOnly(ELContext context)
69      {
70          return delegate.isReadOnly(context);
71      }
72  
73      @Override
74      public void setValue(ELContext context, Object value)
75      {
76          delegate.setValue(context, value);
77      }
78  
79      @Override
80      public boolean equals(Object obj)
81      {
82          return delegate.equals(obj);
83      }
84  
85      @Override
86      public String getExpressionString()
87      {
88          return delegate.getExpressionString();
89      }
90  
91      @Override
92      public int hashCode()
93      {
94          return delegate.hashCode();
95      }
96  
97      @Override
98      public boolean isLiteralText()
99      {
100         return delegate.isLiteralText();
101     }
102 
103     @Override
104     public ValueExpression getWrapped()
105     {
106         return delegate;
107     }
108     
109     @Override
110     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
111     {
112         this.delegate = (ValueExpression) in.readObject();
113     }
114 
115     @Override
116     public void writeExternal(ObjectOutput out) throws IOException
117     {
118         out.writeObject(this.delegate);
119     }
120     
121     @Override
122     public ValueReference getValueReference(ELContext context)
123     {
124         return getWrapped().getValueReference(context);
125     }
126 }