Coverage Report - org.apache.myfaces.view.facelets.tag.jstl.core.MappedValueExpression
 
Classes in this File Line Coverage Branch Coverage Complexity
MappedValueExpression
0%
0/29
0%
0/8
1.5
MappedValueExpression$Entry
0%
0/7
N/A
1.5
 
 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.tag.jstl.core;
 20  
 
 21  
 import java.io.Serializable;
 22  
 import java.util.Map;
 23  
 
 24  
 import javax.el.ELContext;
 25  
 import javax.el.ValueExpression;
 26  
 
 27  
 /**
 28  
  * @author Jacob Hookom
 29  
  * @version $Id$
 30  
  */
 31  
 public final class MappedValueExpression extends ValueExpression
 32  
 {
 33  
     private final static class Entry implements Map.Entry, Serializable
 34  
     {
 35  
         private final Map src;
 36  
         private final Object key;
 37  
 
 38  
         public Entry(Map src, Object key)
 39  0
         {
 40  0
             this.src = src;
 41  0
             this.key = key;
 42  0
         }
 43  
 
 44  
         public Object getKey()
 45  
         {
 46  0
             return key;
 47  
         }
 48  
 
 49  
         public Object getValue()
 50  
         {
 51  0
             return src.get(key);
 52  
         }
 53  
 
 54  
         public Object setValue(Object value)
 55  
         {
 56  0
             return src.put(key, value);
 57  
         }
 58  
 
 59  
     }
 60  
 
 61  
     /**
 62  
      * 
 63  
      */
 64  
     private static final long serialVersionUID = 1L;
 65  
 
 66  
     private final Object key;
 67  
 
 68  
     private final ValueExpression orig;
 69  
 
 70  
     /**
 71  
      * 
 72  
      */
 73  
     public MappedValueExpression(ValueExpression orig, Map.Entry entry)
 74  0
     {
 75  0
         this.orig = orig;
 76  0
         this.key = entry.getKey();
 77  0
     }
 78  
 
 79  
     /*
 80  
      * (non-Javadoc)
 81  
      * 
 82  
      * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
 83  
      */
 84  
     public Object getValue(ELContext context)
 85  
     {
 86  0
         Object base = this.orig.getValue(context);
 87  0
         if (base != null)
 88  
         {
 89  0
             context.setPropertyResolved(true);
 90  0
             return new Entry((Map) base, key);
 91  
 
 92  
         }
 93  0
         return null;
 94  
     }
 95  
 
 96  
     /*
 97  
      * (non-Javadoc)
 98  
      * 
 99  
      * @see javax.el.ValueExpression#setValue(javax.el.ELContext, java.lang.Object)
 100  
      */
 101  
     public void setValue(ELContext context, Object value)
 102  
     {
 103  0
         Object base = this.orig.getValue(context);
 104  0
         if (base != null)
 105  
         {
 106  0
             context.setPropertyResolved(false);
 107  0
             context.getELResolver().setValue(context, base, key, value);
 108  
         }
 109  0
     }
 110  
 
 111  
     /*
 112  
      * (non-Javadoc)
 113  
      * 
 114  
      * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
 115  
      */
 116  
     public boolean isReadOnly(ELContext context)
 117  
     {
 118  0
         Object base = this.orig.getValue(context);
 119  0
         if (base != null)
 120  
         {
 121  0
             context.setPropertyResolved(false);
 122  0
             return context.getELResolver().isReadOnly(context, base, key);
 123  
         }
 124  0
         return true;
 125  
     }
 126  
 
 127  
     /*
 128  
      * (non-Javadoc)
 129  
      * 
 130  
      * @see javax.el.ValueExpression#getType(javax.el.ELContext)
 131  
      */
 132  
     public Class getType(ELContext context)
 133  
     {
 134  0
         Object base = this.orig.getValue(context);
 135  0
         if (base != null)
 136  
         {
 137  0
             context.setPropertyResolved(false);
 138  0
             return context.getELResolver().getType(context, base, key);
 139  
         }
 140  0
         return null;
 141  
     }
 142  
 
 143  
     /*
 144  
      * (non-Javadoc)
 145  
      * 
 146  
      * @see javax.el.ValueExpression#getExpectedType()
 147  
      */
 148  
     public Class getExpectedType()
 149  
     {
 150  0
         return Object.class;
 151  
     }
 152  
 
 153  
     /*
 154  
      * (non-Javadoc)
 155  
      * 
 156  
      * @see javax.el.Expression#getExpressionString()
 157  
      */
 158  
     public String getExpressionString()
 159  
     {
 160  0
         return this.orig.getExpressionString();
 161  
     }
 162  
 
 163  
     /*
 164  
      * (non-Javadoc)
 165  
      * 
 166  
      * @see javax.el.Expression#equals(java.lang.Object)
 167  
      */
 168  
     public boolean equals(Object obj)
 169  
     {
 170  0
         return this.orig.equals(obj);
 171  
     }
 172  
 
 173  
     /*
 174  
      * (non-Javadoc)
 175  
      * 
 176  
      * @see javax.el.Expression#hashCode()
 177  
      */
 178  
     public int hashCode()
 179  
     {
 180  
         // TODO Auto-generated method stub
 181  0
         return 0;
 182  
     }
 183  
 
 184  
     /*
 185  
      * (non-Javadoc)eturn new Map.Entry<K, V>
 186  
      * 
 187  
      * @see javax.el.Expression#isLiteralText()
 188  
      */
 189  
     public boolean isLiteralText()
 190  
     {
 191  
         // TODO Auto-generated method stub
 192  0
         return false;
 193  
     }
 194  
 
 195  
 }