Coverage report

  %line %branch
org.apache.turbine.modules.navigations.VelocityNavigation
23% 
100% 

 1  
 package org.apache.turbine.modules.navigations;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2004 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import org.apache.commons.logging.Log;
 20  
 import org.apache.commons.logging.LogFactory;
 21  
 
 22  
 import org.apache.ecs.ConcreteElement;
 23  
 import org.apache.ecs.StringElement;
 24  
 
 25  
 import org.apache.turbine.TurbineConstants;
 26  
 import org.apache.turbine.services.template.TurbineTemplate;
 27  
 import org.apache.turbine.services.velocity.TurbineVelocity;
 28  
 import org.apache.turbine.util.RunData;
 29  
 
 30  
 import org.apache.velocity.context.Context;
 31  
 
 32  
 /**
 33  
  * VelocityNavigation.  This screen relies on the VelocityPage
 34  
  * being set as the default page.  The doBuildTemplate() assumes the
 35  
  * user has put the template filename in the RunData parameter and set
 36  
  * it to the value of the template file to execute.  Specialized
 37  
  * Navigations screens should extend this class and overide the
 38  
  * doBuildTemplate( data , context) method.
 39  
  *
 40  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 41  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 42  
  * @version $Id: VelocityNavigation.java,v 1.5.2.2 2004/05/20 03:03:53 seade Exp $
 43  
  */
 44  4
 public class VelocityNavigation
 45  
         extends TemplateNavigation
 46  
 {
 47  
     /** Logging */
 48  2
     private static Log log = LogFactory.getLog(VelocityNavigation.class);
 49  
 
 50  
     /** The prefix for lookup up navigation pages */
 51  4
     private String prefix = TurbineConstants.NAVIGATION_PREFIX + "/";
 52  
 
 53  
     /**
 54  
      * Velocity Navigations extending this class should overide this
 55  
      * method to perform any particular business logic and add
 56  
      * information to the context.
 57  
      *
 58  
      * @param data Turbine information.
 59  
      * @param context Context for web pages.
 60  
      * @exception Exception, a generic exception.
 61  
      */
 62  
     protected void doBuildTemplate(RunData data,
 63  
                                    Context context)
 64  
             throws Exception
 65  
     {
 66  0
     }
 67  
 
 68  
     /**
 69  
      * Needs to be implemented to make TemplateNavigation like us.
 70  
      * The actual method that you should override is the one with the
 71  
      * context in the parameter list.
 72  
      *
 73  
      * @param data Turbine information.
 74  
      * @exception Exception, a generic exception.
 75  
      */
 76  
     protected void doBuildTemplate(RunData data)
 77  
             throws Exception
 78  
     {
 79  0
         doBuildTemplate(data, TurbineVelocity.getContext(data));
 80  0
     }
 81  
 
 82  
     /**
 83  
      * This Builds the Velocity template.
 84  
      *
 85  
      * @param data Turbine information.
 86  
      * @return A ConcreteElement.
 87  
      * @exception Exception, a generic exception.
 88  
      */
 89  
     public ConcreteElement buildTemplate(RunData data)
 90  
             throws Exception
 91  
     {
 92  0
         Context context = TurbineVelocity.getContext(data);
 93  
 
 94  0
         String navigationTemplate = data.getTemplateInfo().getNavigationTemplate();
 95  0
         String templateName
 96  
                 = TurbineTemplate.getNavigationTemplateName(navigationTemplate);
 97  
 
 98  0
         StringElement output = new StringElement();
 99  0
         output.setFilterState(false);
 100  0
         output.addElement(TurbineVelocity
 101  
                 .handleRequest(context, prefix + templateName));
 102  0
         return output;
 103  
     }
 104  
 
 105  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.