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