Clover coverage report - Code Coverage for tapestry release 3.1-alpha-1
Coverage timestamp: Mon Feb 21 2005 09:16:14 EST
file stats: LOC: 82   Methods: 4
NCLOC: 32   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
DelegatingPropertySource.java 100% 100% 75% 94.4%
coverage coverage
 1   
 // Copyright 2004, 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.util;
 16   
 
 17   
 import java.util.ArrayList;
 18   
 import java.util.List;
 19   
 
 20   
 import org.apache.tapestry.engine.IPropertySource;
 21   
 
 22   
 /**
 23   
  *  An implementation of {@link IPropertySource}
 24   
  *  that delegates to a list of other implementations.  This makes
 25   
  *  it possible to create a search path for property values.
 26   
  *
 27   
  *  @author Howard Lewis Ship
 28   
  *  @since 2.3
 29   
  *
 30   
  **/
 31   
 
 32   
 public class DelegatingPropertySource implements IPropertySource
 33   
 {
 34   
     private List _sources = new ArrayList();
 35   
     
 36  0
     public DelegatingPropertySource()
 37   
     {
 38   
     }
 39   
     
 40  1
     public DelegatingPropertySource(IPropertySource delegate)
 41   
     {
 42  1
         addSource(delegate);
 43   
     }
 44   
     
 45   
     /**
 46   
      *  Adds another source to the list of delegate property sources.
 47   
      *  This is typically only done during initialization
 48   
      *  of this DelegatingPropertySource.
 49   
      * 
 50   
      **/
 51   
     
 52  2
     public void addSource(IPropertySource source)
 53   
     {
 54  2
         _sources.add(source);
 55   
     }
 56   
     
 57   
     /**
 58   
      *  Re-invokes the method on each delegate property source, 
 59   
      *  in order, return the first non-null value found.
 60   
      * 
 61   
      **/
 62   
     
 63  3
     public String getPropertyValue(String propertyName)
 64   
     {
 65  3
         String result = null;
 66  3
         int count = _sources.size();
 67   
         
 68  3
         for (int i = 0; i < count; i++)
 69   
         {
 70  5
             IPropertySource source = (IPropertySource)_sources.get(i);
 71   
             
 72  5
             result = source.getPropertyValue(propertyName);
 73   
             
 74  5
             if (result != null)
 75  1
                 break;
 76   
         }
 77   
         
 78  3
         return result;        
 79   
     }
 80   
 
 81   
 }
 82