Coverage Report - org.apache.myfaces.view.facelets.el.FaceletStateValueExpression
 
Classes in this File Line Coverage Branch Coverage Complexity
FaceletStateValueExpression
0%
0/49
0%
0/26
2
 
 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.PropertyNotFoundException;
 28  
 import javax.el.PropertyNotWritableException;
 29  
 import javax.el.ValueExpression;
 30  
 import javax.faces.FacesWrapper;
 31  
 import javax.faces.component.UIViewRoot;
 32  
 import javax.faces.context.FacesContext;
 33  
 import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
 34  
 import org.apache.myfaces.view.facelets.tag.jsf.FaceletState;
 35  
 
 36  
 /**
 37  
  *
 38  
  */
 39  0
 public class FaceletStateValueExpression extends ValueExpression 
 40  
     implements Externalizable, FacesWrapper<ValueExpression>
 41  
 {
 42  
     private String uniqueId;
 43  
     private String key;
 44  
 
 45  
     public FaceletStateValueExpression()
 46  0
     {
 47  0
     }
 48  
     
 49  
     public FaceletStateValueExpression(String uniqueId, String key)
 50  0
     {
 51  0
         this.uniqueId = uniqueId;
 52  0
         this.key = key;
 53  0
     }
 54  
     
 55  
     @Override
 56  
     public ValueExpression getWrapped()
 57  
     {
 58  0
         FacesContext facesContext = FacesContext.getCurrentInstance();
 59  0
         UIViewRoot root = facesContext.getViewRoot();
 60  0
         FaceletState map = (FaceletState) root.getAttributes().get(
 61  
             ComponentSupport.FACELET_STATE_INSTANCE);
 62  0
         if (map == null)
 63  
         {
 64  0
             map = (FaceletState)root.getTransientStateHelper().getTransient(
 65  
                     ComponentSupport.FACELET_STATE_INSTANCE);
 66  
         }
 67  0
         return map.getBinding(uniqueId, key);
 68  
     }
 69  
     
 70  
     public ValueExpression getWrapped(ELContext context)
 71  
     {
 72  0
         FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
 73  0
         if (facesContext == null)
 74  
         {
 75  0
             facesContext = FacesContext.getCurrentInstance();
 76  
         }
 77  0
         UIViewRoot root = facesContext.getViewRoot();
 78  0
         FaceletState map = (FaceletState) root.getAttributes().get(
 79  
             ComponentSupport.FACELET_STATE_INSTANCE);
 80  0
         if (map == null)
 81  
         {
 82  0
             map = (FaceletState)root.getTransientStateHelper().getTransient(
 83  
                     ComponentSupport.FACELET_STATE_INSTANCE);
 84  
         }
 85  0
         return map.getBinding(uniqueId, key);
 86  
     }
 87  
 
 88  
 
 89  
     @Override
 90  
     public Class<?> getExpectedType()
 91  
     {
 92  0
         return getWrapped().getExpectedType();
 93  
     }
 94  
 
 95  
     @Override
 96  
     public Class<?> getType(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException
 97  
     {
 98  0
         return getWrapped(context).getType(context);
 99  
     }
 100  
 
 101  
     @Override
 102  
     public boolean isReadOnly(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException
 103  
     {
 104  0
         return getWrapped(context).isReadOnly(context);
 105  
     }
 106  
 
 107  
     @Override
 108  
     public void setValue(ELContext context, Object value) 
 109  
         throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException
 110  
     {
 111  0
         getWrapped(context).setValue(context, value);
 112  0
     }
 113  
 
 114  
     @Override
 115  
     public Object getValue(ELContext context) throws NullPointerException, PropertyNotFoundException, ELException
 116  
     {
 117  0
         return getWrapped(context).getValue(context);
 118  
     }
 119  
 
 120  
     @Override
 121  
     public String getExpressionString()
 122  
     {
 123  0
         return getWrapped().getExpressionString();
 124  
     }
 125  
 
 126  
     @Override
 127  
     public boolean isLiteralText()
 128  
     {
 129  0
         return getWrapped().isLiteralText();
 130  
     }
 131  
 
 132  
     @Override
 133  
     public void writeExternal(ObjectOutput out) throws IOException
 134  
     {
 135  0
         out.writeUTF(uniqueId);
 136  0
         out.writeUTF(key);
 137  0
     }
 138  
 
 139  
     @Override
 140  
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
 141  
     {
 142  0
         uniqueId = (String) in.readUTF();
 143  0
         key = (String) in.readUTF();
 144  0
     }
 145  
 
 146  
     @Override
 147  
     public int hashCode()
 148  
     {
 149  0
         int hash = 7;
 150  0
         hash = 37 * hash + (this.uniqueId != null ? this.uniqueId.hashCode() : 0);
 151  0
         hash = 37 * hash + (this.key != null ? this.key.hashCode() : 0);
 152  0
         return hash;
 153  
     }
 154  
 
 155  
     @Override
 156  
     public boolean equals(Object obj)
 157  
     {
 158  0
         if (obj == null)
 159  
         {
 160  0
             return false;
 161  
         }
 162  0
         if (getClass() != obj.getClass())
 163  
         {
 164  0
             return false;
 165  
         }
 166  0
         final FaceletStateValueExpression other = (FaceletStateValueExpression) obj;
 167  0
         if ((this.uniqueId == null) ? (other.uniqueId != null) : !this.uniqueId.equals(other.uniqueId))
 168  
         {
 169  0
             return false;
 170  
         }
 171  0
         if ((this.key == null) ? (other.key != null) : !this.key.equals(other.key))
 172  
         {
 173  0
             return false;
 174  
         }
 175  0
         return true;
 176  
     }
 177  
 
 178  
 }