Coverage Report - org.apache.tapestry5.internal.transform.IncludeStylesheetWorker
 
Classes in this File Line Coverage Branch Coverage Complexity
IncludeStylesheetWorker
100%
8/8
100%
2/2
1.333
 
 1  
 // Copyright 2007 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.transform;
 16  
 
 17  
 import org.apache.tapestry5.Asset;
 18  
 import org.apache.tapestry5.RenderSupport;
 19  
 import org.apache.tapestry5.annotations.IncludeStylesheet;
 20  
 import org.apache.tapestry5.ioc.services.SymbolSource;
 21  
 import org.apache.tapestry5.model.MutableComponentModel;
 22  
 import org.apache.tapestry5.services.AssetSource;
 23  
 import org.apache.tapestry5.services.ClassTransformation;
 24  
 
 25  
 /**
 26  
  * Recognizes the {@link org.apache.tapestry5.annotations.IncludeStylesheet} annotation and ensures that {@link
 27  
  * org.apache.tapestry5.RenderSupport#addStylesheetLink(org.apache.tapestry5.Asset, String)} is invoked.
 28  
  */
 29  
 public class IncludeStylesheetWorker extends AbstractIncludeAssetWorker
 30  
 {
 31  
     private final RenderSupport renderSupport;
 32  
 
 33  
     public IncludeStylesheetWorker(AssetSource assetSource, RenderSupport renderSupport,
 34  
                                    SymbolSource symbolSource)
 35  
     {
 36  58
         super(assetSource, symbolSource);
 37  
 
 38  58
         this.renderSupport = renderSupport;
 39  58
     }
 40  
 
 41  
     public void transform(ClassTransformation transformation, final MutableComponentModel model)
 42  
     {
 43  812
         IncludeStylesheet annotation = transformation.getAnnotation(IncludeStylesheet.class);
 44  
 
 45  812
         if (annotation != null) addOperationForAssetPaths(transformation, model, annotation.value());
 46  812
     }
 47  
 
 48  
 
 49  
     protected void handleAsset(Asset asset)
 50  
     {
 51  1894
         renderSupport.addStylesheetLink(asset, null);
 52  1894
     }
 53  
 }