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.trinidad.component;
20  
21  import java.io.Serializable;
22  
23  import javax.el.ELContext;
24  import javax.el.ELException;
25  import javax.el.MethodExpression;
26  import javax.el.MethodInfo;
27  
28  import javax.faces.context.FacesContext;
29  import javax.faces.el.EvaluationException;
30  import javax.faces.el.MethodBinding;
31  
32  
33  @Deprecated
34  class MethodBindingMethodExpression
35    extends MethodExpression implements Serializable
36  {
37    // TODO implement serialization correctly?
38    public MethodBindingMethodExpression(MethodBinding binding)
39    {
40      _binding = binding;
41    }
42    
43    public MethodBinding getMethodBinding()
44    {
45      return _binding;
46    }
47  
48    public MethodInfo getMethodInfo(ELContext context)
49    {
50      Class<?> type = _binding.getType(FacesContext.getCurrentInstance());
51      return new MethodInfo(null, type, null);
52    }
53  
54    public Object invoke(ELContext elContext, Object[] params)
55    {
56      try
57      {
58        return _binding.invoke(FacesContext.getCurrentInstance(), params);
59      }
60      // Convert EvaluationExceptions into ELExceptions
61      catch (EvaluationException ee)
62      {
63        throw new ELException(ee.getMessage(), ee.getCause());
64      }
65    }
66  
67    public String getExpressionString()
68    {
69      return _binding.getExpressionString();
70    }
71  
72    public boolean isLiteralText()
73    {
74      return false;
75    }
76  
77    public boolean equals(Object o)
78    {
79      if (o == this)
80        return true;
81      if (!(o instanceof MethodBindingMethodExpression))
82        return false;
83        
84      MethodBindingMethodExpression that = (MethodBindingMethodExpression) o;
85      return that._binding.equals(_binding);
86    }
87  
88    public int hashCode()
89    {
90      return _binding.hashCode();
91    }
92  
93    private final MethodBinding _binding;
94    private static final long serialVersionUID = 1L;
95  }