Clover coverage report - Code Coverage for tapestry release 4.0-beta-9
Coverage timestamp: Sat Oct 1 2005 08:36:20 EDT
file stats: LOC: 107   Methods: 6
NCLOC: 63   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.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  45 public void initializeService()
 44    {
 45  45 Iterator i = _contributions.iterator();
 46  45 while (i.hasNext())
 47    {
 48  168 PropertyPersistenceStrategyContribution c = (PropertyPersistenceStrategyContribution) i
 49    .next();
 50   
 51  168 _strategies.put(c.getName(), c.getStrategy());
 52    }
 53    }
 54   
 55  22 public PropertyPersistenceStrategy getStrategy(String name)
 56    {
 57  22 if (!_strategies.containsKey(name))
 58  1 throw new ApplicationRuntimeException(RecordMessages.unknownPersistenceStrategy(name));
 59   
 60  21 return (PropertyPersistenceStrategy) _strategies.get(name);
 61    }
 62   
 63  190 public Collection getAllStoredChanges(String pageName, IRequestCycle cycle)
 64    {
 65  190 Collection result = new ArrayList();
 66   
 67  190 Iterator i = _strategies.values().iterator();
 68   
 69  190 while (i.hasNext())
 70    {
 71  757 PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 72   
 73  757 result.addAll(s.getStoredChanges(pageName, cycle));
 74    }
 75   
 76  190 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  140 public void addParametersForPersistentProperties(ServiceEncoding encoding, IRequestCycle cycle, boolean post)
 92    {
 93  140 Iterator i = _strategies.values().iterator();
 94   
 95  140 while (i.hasNext())
 96    {
 97  554 PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i.next();
 98   
 99  554 s.addParametersForPersistentProperties(encoding, cycle, post);
 100    }
 101    }
 102   
 103  46 public void setContributions(List contributions)
 104    {
 105  46 _contributions = contributions;
 106    }
 107    }