Clover coverage report - Code Coverage for tapestry-portlet release 4.0-beta-2
Coverage timestamp: Sat Jul 9 2005 22:06:11 EDT
file stats: LOC: 86   Methods: 4
NCLOC: 48   Classes: 1
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
MatchingPortletPageResolver.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.portlet;
 16   
 17    import java.util.ArrayList;
 18    import java.util.Collections;
 19    import java.util.Iterator;
 20    import java.util.List;
 21   
 22    import javax.portlet.PortletRequest;
 23   
 24    import org.apache.tapestry.IRequestCycle;
 25    import org.apache.tapestry.PageNotFoundException;
 26   
 27    /**
 28    * Uses the tapestry.portlet.resolver.PageResolverRules configuration point to find a match.
 29    *
 30    * @author Howard M. Lewis Ship
 31    * @since 4.0
 32    */
 33    public class MatchingPortletPageResolver implements PortletPageResolver
 34    {
 35    private List _contributions;
 36   
 37    private List _sortedContributions;
 38   
 39    private PortletRequest _request;
 40   
 41  5 public void initializeService()
 42    {
 43  5 _sortedContributions = new ArrayList(_contributions);
 44  5 Collections.sort(_sortedContributions);
 45    }
 46   
 47  5 public String getPageNameForRequest(IRequestCycle cycle)
 48    {
 49  5 Iterator i = _sortedContributions.iterator();
 50  5 while (i.hasNext())
 51    {
 52  6 PageResolverContribution c = (PageResolverContribution) i.next();
 53   
 54  6 if (c.match(_request))
 55    {
 56  3 String pageName = c.getPageName();
 57   
 58  3 try
 59    {
 60  3 cycle.getPage(pageName);
 61   
 62  2 return pageName;
 63    }
 64    catch (PageNotFoundException ex)
 65    {
 66    // Ignore.
 67    }
 68    }
 69    }
 70   
 71    // No match, or no matches where the page actually exists.
 72   
 73  3 return null;
 74    }
 75   
 76  5 public void setContributions(List contributions)
 77    {
 78  5 _contributions = contributions;
 79    }
 80   
 81  5 public void setRequest(PortletRequest request)
 82    {
 83  5 _request = request;
 84    }
 85   
 86    }