Coverage Report - org.apache.turbine.util.template.TemplateScreen
 
Classes in this File Line Coverage Branch Coverage Complexity
TemplateScreen
0%
0/15
0%
0/2
1,667
 
 1  
 package org.apache.turbine.util.template;
 2  
 
 3  
 
 4  
 import org.apache.logging.log4j.LogManager;
 5  
 
 6  
 /*
 7  
  * Licensed to the Apache Software Foundation (ASF) under one
 8  
  * or more contributor license agreements.  See the NOTICE file
 9  
  * distributed with this work for additional information
 10  
  * regarding copyright ownership.  The ASF licenses this file
 11  
  * to you under the Apache License, Version 2.0 (the
 12  
  * "License"); you may not use this file except in compliance
 13  
  * with the License.  You may obtain a copy of the License at
 14  
  *
 15  
  *   http://www.apache.org/licenses/LICENSE-2.0
 16  
  *
 17  
  * Unless required by applicable law or agreed to in writing,
 18  
  * software distributed under the License is distributed on an
 19  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 20  
  * KIND, either express or implied.  See the License for the
 21  
  * specific language governing permissions and limitations
 22  
  * under the License.
 23  
  */
 24  
 
 25  
 
 26  
 import org.apache.logging.log4j.Logger;
 27  
 import org.apache.turbine.modules.ScreenLoader;
 28  
 import org.apache.turbine.pipeline.PipelineData;
 29  
 
 30  
 /**
 31  
  * Returns output of a Screen module.  An instance of this is
 32  
  * placed in the Velocity context by the VelocityDirectLayout.  This
 33  
  * allows the screen to be executed only at rendering.
 34  
  * Here's how it's used in a template:
 35  
  *
 36  
  * <p>
 37  
  * <code>
 38  
  * $screen_placeholder
 39  
  * </code>
 40  
  * <p>
 41  
  * <code>
 42  
  * $screen_placeholder.setScreen("Test")
 43  
  * </code>
 44  
  * </p>
 45  
  *
 46  
  * @author <a href="raphael@apache.org">RaphaĆ«l Luta</a>
 47  
  * @version $Id: TemplateScreen.java 1854797 2019-03-04 20:41:39Z tv $
 48  
  */
 49  
 public class TemplateScreen
 50  
 {
 51  
     /** Logging */
 52  0
     private static final Logger log = LogManager.getLogger(TemplateScreen.class);
 53  
 
 54  
     /* The PipelineData object. */
 55  
     private final PipelineData pipelineData;
 56  
 
 57  
     /* The name of the screen template. */
 58  
     private String screen;
 59  
 
 60  
     /**
 61  
      * Constructor
 62  
      *
 63  
      * @param pipelineData A Turbine PipelineData object.
 64  
      */
 65  
     public TemplateScreen(PipelineData pipelineData)
 66  0
     {
 67  0
         this.pipelineData = pipelineData;
 68  0
         this.screen = pipelineData.getRunData().getScreen();
 69  0
     }
 70  
 
 71  
     /**
 72  
      * Set the screen.
 73  
      *
 74  
      * @param screen A String with the name of the screen module
 75  
      * @return A TemplateScreen (self).
 76  
      */
 77  
     public TemplateScreen setScreen(String screen)
 78  
     {
 79  0
         this.screen = screen;
 80  0
         return this;
 81  
     }
 82  
 
 83  
     /**
 84  
      * Builds the output of the navigation template.
 85  
      *
 86  
      * @return A String.
 87  
      */
 88  
     @Override
 89  
     public String toString()
 90  
     {
 91  0
         String returnValue = "";
 92  
 
 93  
         try
 94  
         {
 95  0
             String results = ScreenLoader.getInstance().eval(pipelineData, this.screen);
 96  
 
 97  0
             if (results != null)
 98  
             {
 99  0
                 returnValue = results;
 100  
             }
 101  
         }
 102  0
         catch (Exception e)
 103  
         {
 104  0
             log.error(e);
 105  0
         }
 106  
 
 107  0
         return returnValue;
 108  
     }
 109  
 }