Coverage Report - org.apache.myfaces.el.convert.MethodExpressionToMethodBinding
 
Classes in this File Line Coverage Branch Coverage Complexity
MethodExpressionToMethodBinding
0%
0/22
N/A
0
 
 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.convert;
 20  
 
 21  
 import javax.el.ELException;
 22  
 import javax.el.MethodExpression;
 23  
 import javax.faces.component.StateHolder;
 24  
 import javax.faces.context.FacesContext;
 25  
 import javax.faces.el.EvaluationException;
 26  
 import javax.faces.el.MethodBinding;
 27  
 import javax.faces.el.MethodNotFoundException;
 28  
 
 29  
 /**
 30  
  * Converts a MethodExpression to a MethodBinding.  
 31  
  * See JSF 1.2 spec section 5.8.4
 32  
  *
 33  
  * ATTENTION: If you make changes to this class, treat 
 34  
  * javax.faces.component._MethodExpressionToMethodBinding
 35  
  * accordingly.
 36  
  *
 37  
  * @author Stan Silvert
 38  
  * @see javax.faces.component._MethodExpressionToMethodBinding
 39  
  */
 40  
 public final class MethodExpressionToMethodBinding extends MethodBinding implements StateHolder {
 41  
     
 42  
     private MethodExpression methodExpression;
 43  
     
 44  0
     private boolean isTransient = false;
 45  
     
 46  0
     public MethodExpressionToMethodBinding() {
 47  0
         methodExpression = null;
 48  0
     }
 49  
 
 50  
     /** Creates a new instance of MethodExpressionToMethodBinding */
 51  0
     public MethodExpressionToMethodBinding(final MethodExpression methodExpression) {
 52  0
         this.methodExpression = methodExpression;
 53  0
     }
 54  
     
 55  
     @Override
 56  
     public String getExpressionString()
 57  
     {
 58  0
         return methodExpression.getExpressionString();
 59  
     }
 60  
 
 61  
     public Class getType(FacesContext facesContext) 
 62  
         throws MethodNotFoundException {
 63  
         
 64  
         try {
 65  0
             return methodExpression.getMethodInfo(facesContext.getELContext()).getReturnType();
 66  0
         } catch (javax.el.MethodNotFoundException e) {
 67  0
             throw new javax.faces.el.MethodNotFoundException(e);
 68  
         }
 69  
     }
 70  
 
 71  
     public Object invoke(final FacesContext facesContext, final Object[] params)
 72  
         throws EvaluationException, MethodNotFoundException {
 73  
         
 74  
         try {
 75  0
             return methodExpression.invoke(facesContext.getELContext(), params);
 76  0
         } catch (javax.el.MethodNotFoundException e) {
 77  0
             throw new javax.faces.el.MethodNotFoundException(e);
 78  0
         } catch (ELException e) {
 79  0
             throw new EvaluationException(e.getCause());
 80  
         }
 81  
     }
 82  
 
 83  
 // -------- StateHolder methods -------------------------------------------    
 84  
     
 85  
     public void restoreState(final FacesContext context, final Object state) {
 86  0
         methodExpression = (MethodExpression)state;
 87  0
     }
 88  
 
 89  
     public Object saveState(final FacesContext context) {
 90  0
         return methodExpression;
 91  
     }
 92  
 
 93  
     public void setTransient(final boolean newTransientValue) {
 94  0
         isTransient = newTransientValue;
 95  0
     }
 96  
 
 97  
     public boolean isTransient() {
 98  0
         return isTransient;
 99  
     }
 100  
     
 101  
 }