Coverage Report - javax.faces.component._ViewAttributeMap
 
Classes in this File Line Coverage Branch Coverage Complexity
_ViewAttributeMap
10%
5/48
0%
0/32
2.412
 
 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 javax.faces.component;
 20  
 
 21  
 import java.io.Serializable;
 22  
 import java.util.Collection;
 23  
 import java.util.Map;
 24  
 import java.util.Map.Entry;
 25  
 import java.util.Set;
 26  
 
 27  0
 class _ViewAttributeMap implements Map<String, Object>, Serializable
 28  
 {
 29  
     private static final long serialVersionUID = -9106832109394257866L;
 30  
 
 31  
     private static final String RESET_SAVE_STATE_MODE_KEY = 
 32  
             "oam.view.resetSaveStateMode";
 33  
 
 34  
     /**
 35  
      * Key under UIViewRoot to generated unique ids for components added 
 36  
      * by @ResourceDependency effect.
 37  
      */
 38  
     private static final String RESOURCE_DEPENDENCY_UNIQUE_ID_KEY =
 39  
               "oam.view.resourceDependencyUniqueId";
 40  
     private static final String UNIQUE_ID_COUNTER_KEY =
 41  
               "oam.view.uniqueIdCounter";
 42  
     
 43  
     private Map<String, Object> _delegate;
 44  
     private UIViewRoot _root;
 45  
 
 46  
     public _ViewAttributeMap(UIViewRoot root, Map<String, Object> delegate)
 47  6
     {
 48  6
         this._delegate = delegate;
 49  6
         this._root = root;
 50  6
     }
 51  
 
 52  
     public int size()
 53  
     {
 54  0
         return _delegate.size();
 55  
     }
 56  
 
 57  
     public boolean isEmpty()
 58  
     {
 59  0
         return _delegate.isEmpty();
 60  
     }
 61  
 
 62  
     public boolean containsKey(Object key)
 63  
     {
 64  64
         return _delegate.containsKey(key);
 65  
     }
 66  
 
 67  
     public boolean containsValue(Object value)
 68  
     {
 69  0
         return _delegate.containsValue(value);
 70  
     }
 71  
 
 72  
     public Object get(Object key)
 73  
     {
 74  0
         checkKey(key);
 75  0
         int keyLength = ((String)key).length();
 76  
 
 77  0
         if (RESET_SAVE_STATE_MODE_KEY.length() == keyLength
 78  
             && RESET_SAVE_STATE_MODE_KEY.equals(key))
 79  
         {
 80  0
             return _root.getResetSaveStateMode();
 81  
         }
 82  0
         if (RESOURCE_DEPENDENCY_UNIQUE_ID_KEY.length() == keyLength
 83  
             && RESOURCE_DEPENDENCY_UNIQUE_ID_KEY.equals(key))
 84  
         {
 85  0
             return _root.isResourceDependencyUniqueId();
 86  
         }
 87  0
         if (UNIQUE_ID_COUNTER_KEY.length() == keyLength
 88  
             && UNIQUE_ID_COUNTER_KEY.equals(key))
 89  
         {
 90  0
             return _root.getStateHelper().get(UIViewRoot.PropertyKeys.uniqueIdCounter);
 91  
         }
 92  0
         return _delegate.get(key);
 93  
     }
 94  
 
 95  
     public Object put(String key, Object value)
 96  
     {
 97  0
         int keyLength = ((String)key).length();
 98  
 
 99  0
         if (RESET_SAVE_STATE_MODE_KEY.length() == keyLength
 100  
             && RESET_SAVE_STATE_MODE_KEY.equals(key))
 101  
         {
 102  0
             Integer b = _root.getResetSaveStateMode();
 103  0
             _root.setResetSaveStateMode(value == null ? 0 : (Integer) value);
 104  0
             return b;
 105  
         }
 106  0
         if (RESOURCE_DEPENDENCY_UNIQUE_ID_KEY.length() == keyLength
 107  
             && RESOURCE_DEPENDENCY_UNIQUE_ID_KEY.equals(key))
 108  
         {
 109  0
             boolean b = _root.isResourceDependencyUniqueId();
 110  0
             _root.setResourceDependencyUniqueId(value == null ? false : (Boolean) value);
 111  0
             return b;
 112  
         }
 113  0
         if (UNIQUE_ID_COUNTER_KEY.length() == keyLength
 114  
             && UNIQUE_ID_COUNTER_KEY.equals(key))
 115  
         {
 116  0
             Integer v = (Integer) _root.getStateHelper().get(UIViewRoot.PropertyKeys.uniqueIdCounter);
 117  0
             _root.getStateHelper().put(UIViewRoot.PropertyKeys.uniqueIdCounter, value);
 118  0
             return v;
 119  
         }
 120  0
         return _delegate.put(key, value);
 121  
     }
 122  
 
 123  
     public Object remove(Object key)
 124  
     {
 125  0
         return _delegate.remove(key);
 126  
     }
 127  
 
 128  
     public void putAll(Map<? extends String, ? extends Object> m)
 129  
     {
 130  0
         _delegate.putAll(m);
 131  0
     }
 132  
 
 133  
     public void clear()
 134  
     {
 135  0
         _delegate.clear();
 136  0
     }
 137  
 
 138  
     public Set<String> keySet()
 139  
     {
 140  0
         return _delegate.keySet();
 141  
     }
 142  
 
 143  
     public Collection<Object> values()
 144  
     {
 145  0
         return _delegate.values();
 146  
     }
 147  
 
 148  
     public Set<Entry<String, Object>> entrySet()
 149  
     {
 150  0
         return _delegate.entrySet();
 151  
     }
 152  
 
 153  
     public boolean equals(Object o)
 154  
     {
 155  0
         return _delegate.equals(o);
 156  
     }
 157  
 
 158  
     public int hashCode()
 159  
     {
 160  0
         return _delegate.hashCode();
 161  
     }
 162  
 
 163  
     public String toString()
 164  
     {
 165  0
         return _delegate.toString();
 166  
     }
 167  
     
 168  
     private void checkKey(Object key)
 169  
     {
 170  0
         if (key == null)
 171  
         {
 172  0
             throw new NullPointerException("key");
 173  
         }
 174  0
         if (!(key instanceof String))
 175  
         {
 176  0
             throw new ClassCastException("key is not a String");
 177  
         }
 178  0
     }
 179  
 }