Coverage Report - org.apache.myfaces.flow.impl.FlowScopeMap
 
Classes in this File Line Coverage Branch Coverage Complexity
FlowScopeMap
0%
0/44
0%
0/16
2.071
 
 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.flow.impl;
 20  
 
 21  
 import java.util.Collection;
 22  
 import java.util.Map;
 23  
 import java.util.Set;
 24  
 import javax.faces.context.FacesContext;
 25  
 
 26  
 /**
 27  
  *
 28  
  * @author Leonardo Uribe
 29  
  */
 30  
 class FlowScopeMap implements Map<Object,Object>
 31  
 {
 32  
     private DefaultFacesFlowProvider _provider;
 33  
     
 34  
     private String _flowMapKey;
 35  
     
 36  
     private Map<Object,Object> _delegate;
 37  
         
 38  
     public FlowScopeMap(DefaultFacesFlowProvider provider, String flowMapKey)
 39  0
     {
 40  0
         this._provider = provider;
 41  0
         this._flowMapKey = flowMapKey;
 42  0
     }
 43  
     
 44  
     private Map<Object,Object> getWrapped(boolean create)
 45  
     {
 46  0
         if (_delegate == null)
 47  
         {
 48  0
             String fullToken = DefaultFacesFlowProvider.FLOW_SESSION_MAP_SUBKEY_PREFIX + 
 49  
                 DefaultFacesFlowProvider.SEPARATOR_CHAR + _flowMapKey;
 50  0
             FacesContext context = FacesContext.getCurrentInstance();
 51  0
             _delegate = _provider.createOrRestoreMap(context, fullToken, create);
 52  
         }
 53  0
         return _delegate;
 54  
     }
 55  
 
 56  
     public int size()
 57  
     {
 58  0
         Map<Object,Object> map = getWrapped(false);
 59  0
         if (map == null)
 60  
         {
 61  0
             return 0;
 62  
         }
 63  0
         return map.size();
 64  
     }
 65  
 
 66  
     public boolean isEmpty()
 67  
     {
 68  0
         Map<Object,Object> map = getWrapped(false);
 69  0
         if (map == null)
 70  
         {
 71  0
             return false;
 72  
         }
 73  0
         return map.isEmpty();
 74  
     }
 75  
 
 76  
     public boolean containsKey(Object key)
 77  
     {
 78  0
         Map<Object,Object> map = getWrapped(false);
 79  0
         if (map == null)
 80  
         {
 81  0
             return false;
 82  
         }
 83  0
         return map.containsKey(key);
 84  
     }
 85  
 
 86  
     public boolean containsValue(Object value)
 87  
     {
 88  0
         Map<Object,Object> map = getWrapped(false);
 89  0
         if (map == null)
 90  
         {
 91  0
             return false;
 92  
         }
 93  0
         return map.containsValue(value);
 94  
     }
 95  
 
 96  
     public Object get(Object key)
 97  
     {
 98  0
         Map<Object,Object> map = getWrapped(false);
 99  0
         if (map == null)
 100  
         {
 101  0
             return null;
 102  
         }
 103  0
         return map.get(key);
 104  
     }
 105  
 
 106  
     public Object put(Object key, Object value)
 107  
     {
 108  0
         return getWrapped(true).put(key, value);
 109  
     }
 110  
 
 111  
     public Object remove(Object key)
 112  
     {
 113  0
         Map<Object,Object> map = getWrapped(false);
 114  0
         if (map == null)
 115  
         {
 116  0
             return null;
 117  
         }
 118  0
         return map.remove(key);
 119  
     }
 120  
 
 121  
     public void putAll(Map<? extends Object, ? extends Object> m)
 122  
     {
 123  0
         getWrapped(true).putAll(m);
 124  0
     }
 125  
 
 126  
     public void clear()
 127  
     {
 128  0
         Map<Object,Object> map = getWrapped(false);
 129  0
         if (map == null)
 130  
         {
 131  0
             return;
 132  
         }
 133  0
         map.clear();
 134  0
     }
 135  
 
 136  
     public Set<Object> keySet()
 137  
     {
 138  0
         return getWrapped(true).keySet();
 139  
     }
 140  
 
 141  
     public Collection<Object> values()
 142  
     {
 143  0
         return getWrapped(true).values();
 144  
     }
 145  
 
 146  
     public Set<Entry<Object, Object>> entrySet()
 147  
     {
 148  0
         return getWrapped(true).entrySet();
 149  
     }
 150  
     
 151  
 }