Clover coverage report - Code Coverage for tapestry release 4.0.3
Coverage timestamp: Fri May 5 2006 21:17:42 CDT
file stats: LOC: 106   Methods: 6
NCLOC: 62   Classes: 1
 
 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.engine.ServiceEncoding;
 26   
 27    /**
 28    * Implementation of the <code>tapestry.persist.PropertyPersistenceStrategySource</code> service.
 29    * Allows access to other services, that implement the
 30    * {@link org.apache.tapestry.record.PropertyPersistenceStrategy} interface.
 31    *
 32    * @author Howard M. Lewis Ship
 33    * @since 4.0
 34    */
 35    public class PropertyPersistenceStrategySourceImpl implements PropertyPersistenceStrategySource
 36    {
 37    // Set from tapestry.props.PersistenceStrategy
 38    private List _contributions;
 39   
 40    private Map _strategies = new HashMap();
 41   
 42  129 public void initializeService()
 43    {
 44  129 Iterator i = _contributions.iterator();
 45  129 while (i.hasNext())
 46    {
 47  480 PropertyPersistenceStrategyContribution c = (PropertyPersistenceStrategyContribution) i
 48    .next();
 49   
 50  480 _strategies.put(c.getName(), c.getStrategy());
 51    }
 52    }
 53   
 54  66 public PropertyPersistenceStrategy getStrategy(String name)
 55    {
 56  66 if (!_strategies.containsKey(name))
 57  3 throw new ApplicationRuntimeException(RecordMessages.unknownPersistenceStrategy(name));
 58   
 59  63 return (PropertyPersistenceStrategy) _strategies.get(name);
 60    }
 61   
 62  528 public Collection getAllStoredChanges(String pageName)
 63    {
 64  528 Collection result = new ArrayList();
 65   
 66  528 Iterator i = _strategies.values().iterator();
 67   
 68  528 while (i.hasNext())
 69    {
 70  2103 PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 71   
 72  2103 result.addAll(s.getStoredChanges(pageName));
 73    }
 74   
 75  528 return result;
 76    }
 77   
 78  3 public void discardAllStoredChanged(String pageName)
 79    {
 80  3 Iterator i = _strategies.values().iterator();
 81   
 82  3 while (i.hasNext())
 83    {
 84  3 PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 85   
 86  3 s.discardStoredChanges(pageName);
 87    }
 88    }
 89   
 90  342 public void addParametersForPersistentProperties(ServiceEncoding encoding, boolean post)
 91    {
 92  342 Iterator i = _strategies.values().iterator();
 93   
 94  342 while (i.hasNext())
 95    {
 96  1350 PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 97   
 98  1350 s.addParametersForPersistentProperties(encoding, post);
 99    }
 100    }
 101   
 102  132 public void setContributions(List contributions)
 103    {
 104  132 _contributions = contributions;
 105    }
 106    }