Coverage Report - org.apache.myfaces.view.facelets.el.MethodExpressionMethodExpression
 
Classes in this File Line Coverage Branch Coverage Complexity
MethodExpressionMethodExpression
0%
0/31
0%
0/10
2.1
 
 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.ELException;
 27  
 import javax.el.MethodExpression;
 28  
 import javax.el.MethodInfo;
 29  
 import javax.el.MethodNotFoundException;
 30  
 import javax.el.PropertyNotFoundException;
 31  
 
 32  
 /**
 33  
  *
 34  
  * @author Leonardo Uribe
 35  
  */
 36  
 public class MethodExpressionMethodExpression extends MethodExpression implements Externalizable
 37  
 {
 38  
     
 39  0
     private static final Object[] EMPTY_PARAMS = new Object[0];
 40  
     
 41  
     private MethodExpression methodExpressionOneArg;
 42  
     private MethodExpression methodExpressionZeroArg;
 43  
 
 44  
     public MethodExpressionMethodExpression()
 45  0
     {
 46  0
     }
 47  
     
 48  
     public MethodExpressionMethodExpression(MethodExpression methodExpressionOneArg,
 49  
                                             MethodExpression methodExpressionZeroArg)
 50  0
     {
 51  0
         this.methodExpressionOneArg = methodExpressionOneArg;
 52  0
         this.methodExpressionZeroArg = methodExpressionZeroArg;
 53  0
     }
 54  
 
 55  
     @Override
 56  
     public MethodInfo getMethodInfo(ELContext context)
 57  
             throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException
 58  
     {
 59  
         try
 60  
         {
 61  
             // call to the one argument MethodExpression
 62  0
             return methodExpressionOneArg.getMethodInfo(context);
 63  
         }
 64  0
         catch (MethodNotFoundException mnfe)
 65  
         {
 66  
             // call to the zero argument MethodExpression
 67  0
             return methodExpressionZeroArg.getMethodInfo(context);
 68  
         }
 69  
     }
 70  
 
 71  
     @Override
 72  
     public Object invoke(ELContext context, Object[] params)
 73  
             throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException
 74  
     {
 75  
         try
 76  
         {
 77  
             // call to the one argument MethodExpression
 78  0
             return methodExpressionOneArg.invoke(context, params);
 79  
         }
 80  0
         catch (MethodNotFoundException mnfe)
 81  
         {
 82  
             // call to the zero argument MethodExpression
 83  0
             return methodExpressionZeroArg.invoke(context, EMPTY_PARAMS);
 84  
         }
 85  
     }
 86  
 
 87  
     @Override
 88  
     public String getExpressionString()
 89  
     {
 90  
         try
 91  
         {
 92  
             // call to the one argument MethodExpression
 93  0
             return methodExpressionOneArg.getExpressionString();
 94  
         }
 95  0
         catch (MethodNotFoundException mnfe)
 96  
         {
 97  
             // call to the zero argument MethodExpression
 98  0
             return methodExpressionZeroArg.getExpressionString();
 99  
         }
 100  
     }
 101  
 
 102  
     @Override
 103  
     public boolean isLiteralText()
 104  
     {
 105  0
         return false;
 106  
     }
 107  
 
 108  
     public void writeExternal(ObjectOutput out) throws IOException
 109  
     {
 110  0
         out.writeObject(methodExpressionOneArg);
 111  0
         out.writeObject(methodExpressionZeroArg);
 112  0
     }
 113  
 
 114  
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
 115  
     {
 116  0
         methodExpressionOneArg = (MethodExpression) in.readObject();
 117  0
         methodExpressionZeroArg = (MethodExpression) in.readObject();
 118  0
     }
 119  
 
 120  
     @Override
 121  
     public boolean equals(Object obj)
 122  
     {
 123  0
         if (obj instanceof MethodExpressionMethodExpression)
 124  
         {
 125  0
             MethodExpressionMethodExpression me = (MethodExpressionMethodExpression) obj;
 126  0
             return methodExpressionOneArg.equals(me.methodExpressionOneArg) &&
 127  
                    methodExpressionZeroArg.equals(me.methodExpressionZeroArg);
 128  
         }
 129  0
         return false;
 130  
     }
 131  
 
 132  
     @Override
 133  
     public int hashCode()
 134  
     {
 135  0
         int hash = 31;
 136  0
         hash = 19 * hash + (this.methodExpressionOneArg != null ? this.methodExpressionOneArg.hashCode() : 0);
 137  0
         hash = 19 * hash + (this.methodExpressionZeroArg != null ? this.methodExpressionZeroArg.hashCode() : 0);
 138  0
         return hash;
 139  
     }
 140  
 }