Coverage Report - org.apache.tapestry5.internal.bindings.RenderVariableBinding
 
Classes in this File Line Coverage Branch Coverage Complexity
RenderVariableBinding
91%
10/11
N/A
0
 
 1  
 // Copyright 2008, 2009 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.tapestry5.internal.bindings;
 16  
 
 17  
 import org.apache.tapestry5.ComponentResources;
 18  
 import org.apache.tapestry5.ioc.Location;
 19  
 
 20  
 public class RenderVariableBinding extends AbstractBinding
 21  
 {
 22  
     private final String description;
 23  
     private final ComponentResources resources;
 24  
     private final String name;
 25  
 
 26  
     public RenderVariableBinding(Location location, String description, ComponentResources resources, String name
 27  
     )
 28  
     {
 29  18
         super(location);
 30  
 
 31  18
         this.description = description;
 32  18
         this.resources = resources;
 33  18
         this.name = name;
 34  18
     }
 35  
 
 36  
     @Override
 37  
     public void set(Object value)
 38  
     {
 39  6604
         resources.storeRenderVariable(name, value);
 40  6604
     }
 41  
 
 42  
     /**
 43  
      * Returns false, render variables are always variable.
 44  
      */
 45  
     @Override
 46  
     public boolean isInvariant()
 47  
     {
 48  1026
         return false;
 49  
     }
 50  
 
 51  
     @Override
 52  
     public String toString()
 53  
     {
 54  0
         return String.format("RenderVariable[%s %s]", description, name);
 55  
     }
 56  
 
 57  
 
 58  
     public Object get()
 59  
     {
 60  6616
         return resources.getRenderVariable(name);
 61  
     }
 62  
 
 63  
     /**
 64  
      * Always returns Object since we don't (statically) know the type of object.
 65  
      */
 66  
     @Override
 67  
     public Class getBindingType()
 68  
     {
 69  6612
         return Object.class;
 70  
     }
 71  
 }