Coverage Report - net.sf.tacos.binding.AbsoluteAssetBinding
 
Classes in this File Line Coverage Branch Coverage Complexity
AbsoluteAssetBinding
0% 
0% 
1,667
 
 1  
 /*
 2  
  *  Copyright 2007 Tacos.
 3  
  * 
 4  
  *  Licensed under the Apache License, Version 2.0 (the "License");
 5  
  *  you may not use this file except in compliance with the License.
 6  
  *  You may obtain a copy of the License at
 7  
  * 
 8  
  *       http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  *  Unless required by applicable law or agreed to in writing, software
 11  
  *  distributed under the License is distributed on an "AS IS" BASIS,
 12  
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  *  See the License for the specific language governing permissions and
 14  
  *  limitations under the License.
 15  
  *  under the License.
 16  
  */
 17  
 package net.sf.tacos.binding;
 18  
 
 19  
 import net.sf.tacos.asset.AbsoluteAsset;
 20  
 import org.apache.hivemind.Location;
 21  
 import org.apache.hivemind.util.Defense;
 22  
 import org.apache.tapestry.BindingException;
 23  
 import org.apache.tapestry.IAsset;
 24  
 import org.apache.tapestry.IComponent;
 25  
 import org.apache.tapestry.binding.AbstractBinding;
 26  
 import org.apache.tapestry.coerce.ValueConverter;
 27  
 import org.apache.tapestry.services.AbsoluteURLBuilder;
 28  
 
 29  
 /**
 30  
  * A binding that is connected to an asset provided by a component.
 31  
  * 
 32  
  * @author Andreas Andreou
 33  
  * @since 4.1
 34  
  */
 35  
 public class AbsoluteAssetBinding extends AbstractBinding
 36  
 {
 37  
     private final IComponent component;
 38  
     private AbsoluteURLBuilder absoluteURLBuilder;
 39  
 
 40  
     public AbsoluteAssetBinding(String description, ValueConverter valueConverter, 
 41  
             AbsoluteURLBuilder absoluteURLBuilder, Location location, IComponent component, String assetName)
 42  
     {
 43  0
         super(assetName, valueConverter, location);
 44  
 
 45  0
         Defense.notNull(component, "component");
 46  0
         Defense.notNull(assetName, "assetName");
 47  
 
 48  0
         this.component = component;
 49  0
         this.absoluteURLBuilder = absoluteURLBuilder;
 50  0
     }
 51  
 
 52  
     public Object getObject()
 53  
     {
 54  0
         IAsset asset = component.getAsset(_description);
 55  
 
 56  0
         if (asset == null)
 57  0
             throw new BindingException("Component " + component.getExtendedId() + 
 58  
                     " does not contain an asset named ''" + _description + "''.",
 59  
                     component, getLocation(), this, null);
 60  
 
 61  0
         return new AbsoluteAsset(asset, absoluteURLBuilder);
 62  
     }
 63  
 
 64  
     public Object getComponent()
 65  
     {
 66  0
         return component;
 67  
     }
 68  
 }
 69