Coverage Report - org.apache.tapestry.pageload.QueuedInheritInformalBindings
 
Classes in this File Line Coverage Branch Coverage Complexity
QueuedInheritInformalBindings
0%
0/19
0%
0/12
4
 
 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.pageload;
 16  
 
 17  
 import java.util.Iterator;
 18  
 
 19  
 import org.apache.tapestry.IBinding;
 20  
 import org.apache.tapestry.IComponent;
 21  
 import org.apache.tapestry.spec.IComponentSpecification;
 22  
 
 23  
 /**
 24  
  * Used to defer connection of inherited informal bindings.
 25  
  * 
 26  
  * @author Howard Lewis Ship
 27  
  * @since 4.0
 28  
  */
 29  
 class QueuedInheritInformalBindings implements IQueuedInheritedBinding
 30  
 {
 31  
 
 32  
     private IComponent _component;
 33  
 
 34  
     QueuedInheritInformalBindings(IComponent component)
 35  0
     {
 36  0
         _component = component;
 37  0
     }
 38  
 
 39  
     public void connect()
 40  
     {
 41  
 
 42  0
         IComponent container = _component.getContainer();
 43  
 
 44  0
         for(Iterator it = container.getBindingNames().iterator(); it.hasNext();)
 45  
         {
 46  0
             String bindingName = (String) it.next();
 47  0
             connectInformalBinding(container, _component, bindingName);
 48  0
         }
 49  0
     }
 50  
 
 51  
     private void connectInformalBinding(IComponent container,
 52  
             IComponent component, String bindingName)
 53  
     {
 54  0
         IComponentSpecification componentSpec = component.getSpecification();
 55  0
         IComponentSpecification containerSpec = container.getSpecification();
 56  
 
 57  
         // check if binding already exists in the component
 58  0
         if (component.getBinding(bindingName) != null) return;
 59  
 
 60  
         // check if parameter is informal for the component
 61  0
         if (componentSpec.getParameter(bindingName) != null
 62  0
                 || componentSpec.isReservedParameterName(bindingName)) return;
 63  
 
 64  
         // check if parameter is informal for the container
 65  0
         if (containerSpec.getParameter(bindingName) != null
 66  0
                 || containerSpec.isReservedParameterName(bindingName)) return;
 67  
 
 68  
         // if everything passes, establish binding
 69  0
         IBinding binding = container.getBinding(bindingName);
 70  0
         component.setBinding(bindingName, binding);
 71  0
     }
 72  
 }