Clover coverage report - Code Coverage for tapestry release 4.0-rc-2
Coverage timestamp: Sat Dec 17 2005 09:39:46 PST
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  43 public void initializeService()
 43    {
 44  43 Iterator i = _contributions.iterator();
 45  43 while (i.hasNext())
 46    {
 47  160 PropertyPersistenceStrategyContribution c = (PropertyPersistenceStrategyContribution) i
 48    .next();
 49   
 50  160 _strategies.put(c.getName(), c.getStrategy());
 51    }
 52    }
 53   
 54  22 public PropertyPersistenceStrategy getStrategy(String name)
 55    {
 56  22 if (!_strategies.containsKey(name))
 57  1 throw new ApplicationRuntimeException(RecordMessages.unknownPersistenceStrategy(name));
 58   
 59  21 return (PropertyPersistenceStrategy) _strategies.get(name);
 60    }
 61   
 62  176 public Collection getAllStoredChanges(String pageName)
 63    {
 64  176 Collection result = new ArrayList();
 65   
 66  176 Iterator i = _strategies.values().iterator();
 67   
 68  176 while (i.hasNext())
 69    {
 70  701 PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 71   
 72  701 result.addAll(s.getStoredChanges(pageName));
 73    }
 74   
 75  176 return result;
 76    }
 77   
 78  1 public void discardAllStoredChanged(String pageName)
 79    {
 80  1 Iterator i = _strategies.values().iterator();
 81   
 82  1 while (i.hasNext())
 83    {
 84  1 PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 85   
 86  1 s.discardStoredChanges(pageName);
 87    }
 88    }
 89   
 90  115 public void addParametersForPersistentProperties(ServiceEncoding encoding, boolean post)
 91    {
 92  115 Iterator i = _strategies.values().iterator();
 93   
 94  115 while (i.hasNext())
 95    {
 96  454 PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 97   
 98  454 s.addParametersForPersistentProperties(encoding, post);
 99    }
 100    }
 101   
 102  44 public void setContributions(List contributions)
 103    {
 104  44 _contributions = contributions;
 105    }
 106    }