Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 107   Methods: 6
NCLOC: 63   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
PropertyPersistenceStrategySourceImpl.java 100% 100% 100% 100%
coverage
 1   
 // Copyright 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.tapestry.record;
 16   
 
 17   
 import java.util.ArrayList;
 18   
 import java.util.Collection;
 19   
 import java.util.HashMap;
 20   
 import java.util.Iterator;
 21   
 import java.util.List;
 22   
 import java.util.Map;
 23   
 
 24   
 import org.apache.hivemind.ApplicationRuntimeException;
 25   
 import org.apache.tapestry.IRequestCycle;
 26   
 import org.apache.tapestry.engine.ServiceEncoding;
 27   
 
 28   
 /**
 29   
  * Implementation of the <code>tapestry.persist.PropertyPersistenceStrategySource</code> service.
 30   
  * Allows access to other services, that implement the
 31   
  * {@link org.apache.tapestry.record.PropertyPersistenceStrategy} interface.
 32   
  * 
 33   
  * @author Howard M. Lewis Ship
 34   
  * @since 4.0
 35   
  */
 36   
 public class PropertyPersistenceStrategySourceImpl implements PropertyPersistenceStrategySource
 37   
 {
 38   
     // Set from tapestry.props.PersistenceStrategy
 39   
     private List _contributions;
 40   
 
 41   
     private Map _strategies = new HashMap();
 42   
 
 43  49
     public void initializeService()
 44   
     {
 45  49
         Iterator i = _contributions.iterator();
 46  49
         while (i.hasNext())
 47   
         {
 48  94
             PropertyPersistenceStrategyContribution c = (PropertyPersistenceStrategyContribution) i
 49   
                     .next();
 50   
 
 51  94
             _strategies.put(c.getName(), c.getStrategy());
 52   
         }
 53   
     }
 54   
 
 55  32
     public PropertyPersistenceStrategy getStrategy(String name)
 56   
     {
 57  32
         if (!_strategies.containsKey(name))
 58  1
             throw new ApplicationRuntimeException(RecordMessages.unknownPersistenceStrategy(name));
 59   
 
 60  31
         return (PropertyPersistenceStrategy) _strategies.get(name);
 61   
     }
 62   
 
 63  213
     public Collection getAllStoredChanges(String pageName, IRequestCycle cycle)
 64   
     {
 65  213
         Collection result = new ArrayList();
 66   
 
 67  213
         Iterator i = _strategies.values().iterator();
 68   
 
 69  213
         while (i.hasNext())
 70   
         {
 71  425
             PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 72   
 
 73  425
             result.addAll(s.getStoredChanges(pageName, cycle));
 74   
         }
 75   
 
 76  213
         return result;
 77   
     }
 78   
 
 79  1
     public void discardAllStoredChanged(String pageName, IRequestCycle cycle)
 80   
     {
 81  1
         Iterator i = _strategies.values().iterator();
 82   
 
 83  1
         while (i.hasNext())
 84   
         {
 85  1
             PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 86   
 
 87  1
             s.discardStoredChanges(pageName, cycle);
 88   
         }
 89   
     }
 90   
 
 91  161
     public void addParametersForPersistentProperties(ServiceEncoding encoding, IRequestCycle cycle)
 92   
     {
 93  161
         Iterator i = _strategies.values().iterator();
 94   
 
 95  161
         while (i.hasNext())
 96   
         {
 97  321
             PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 98   
 
 99  321
             s.addParametersForPersistentProperties(encoding, cycle);
 100   
         }
 101   
     }
 102   
 
 103  50
     public void setContributions(List contributions)
 104   
     {
 105  50
         _contributions = contributions;
 106   
     }
 107   
 }