Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 90   Methods: 4
NCLOC: 49   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
BindingSourceImpl.java 100% 100% 100% 100%
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.services.impl;
 16   
 
 17   
 import java.util.HashMap;
 18   
 import java.util.Iterator;
 19   
 import java.util.List;
 20   
 import java.util.Map;
 21   
 
 22   
 import org.apache.hivemind.Location;
 23   
 import org.apache.tapestry.IBinding;
 24   
 import org.apache.tapestry.IComponent;
 25   
 import org.apache.tapestry.binding.BindingFactory;
 26   
 import org.apache.tapestry.binding.BindingSource;
 27   
 
 28   
 /**
 29   
  * Implementation of the <code>tapestry.bindings.BindingSource</code> service.
 30   
  * 
 31   
  * @author Howard Lewis Ship
 32   
  * @since 4.0
 33   
  */
 34   
 public class BindingSourceImpl implements BindingSource
 35   
 {
 36   
     private List _contributions;
 37   
 
 38   
     private BindingFactory _literalBindingFactory;
 39   
 
 40   
     /**
 41   
      * Keyed on prefix, value is {@link BindingFactory}.
 42   
      */
 43   
     private Map _factoryMap = new HashMap();
 44   
 
 45  47
     public void initializeService()
 46   
     {
 47  47
         Iterator i = _contributions.iterator();
 48   
 
 49  47
         while (i.hasNext())
 50   
         {
 51  443
             BindingPrefixContribution c = (BindingPrefixContribution) i.next();
 52   
 
 53  443
             _factoryMap.put(c.getPrefix(), c.getFactory());
 54   
         }
 55   
     }
 56   
 
 57  1673
     public IBinding createBinding(IComponent component, String bindingDescription,
 58   
             String reference, String defaultPrefix, Location location)
 59   
     {
 60  1673
         String prefix = defaultPrefix;
 61  1673
         String path = reference;
 62   
 
 63  1673
         int colonx = reference.indexOf(':');
 64   
 
 65  1673
         if (colonx > 1)
 66   
         {
 67  1129
             prefix = reference.substring(0, colonx);
 68   
 
 69  1129
             if (_factoryMap.containsKey(prefix))
 70  1021
                 path = reference.substring(colonx + 1);
 71   
         }
 72   
 
 73  1673
         BindingFactory factory = (BindingFactory) _factoryMap.get(prefix);
 74   
 
 75  1673
         if (factory == null)
 76  109
             factory = _literalBindingFactory;
 77   
 
 78  1673
         return factory.createBinding(component, bindingDescription, path, location);
 79   
     }
 80   
 
 81  47
     public void setContributions(List contributions)
 82   
     {
 83  47
         _contributions = contributions;
 84   
     }
 85   
 
 86  46
     public void setLiteralBindingFactory(BindingFactory literalBindingFactory)
 87   
     {
 88  46
         _literalBindingFactory = literalBindingFactory;
 89   
     }
 90   
 }