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