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