Coverage Report - org.apache.turbine.modules.Screen
 
Classes in this File Line Coverage Branch Coverage Complexity
Screen
N/A
N/A
0
 
 1  
 package org.apache.turbine.modules;
 2  
 
 3  
 
 4  
 /*
 5  
  * Licensed to the Apache Software Foundation (ASF) under one
 6  
  * or more contributor license agreements.  See the NOTICE file
 7  
  * distributed with this work for additional information
 8  
  * regarding copyright ownership.  The ASF licenses this file
 9  
  * to you under the Apache License, Version 2.0 (the
 10  
  * "License"); you may not use this file except in compliance
 11  
  * with the License.  You may obtain a copy of the License at
 12  
  *
 13  
  *   http://www.apache.org/licenses/LICENSE-2.0
 14  
  *
 15  
  * Unless required by applicable law or agreed to in writing,
 16  
  * software distributed under the License is distributed on an
 17  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 18  
  * KIND, either express or implied.  See the License for the
 19  
  * specific language governing permissions and limitations
 20  
  * under the License.
 21  
  */
 22  
 
 23  
 
 24  
 import org.apache.turbine.pipeline.PipelineData;
 25  
 import org.apache.turbine.util.RunData;
 26  
 
 27  
 /**
 28  
  * This is the interface which defines the Screen modules.
 29  
  *
 30  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 31  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 32  
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
 33  
  * @version $Id: Screen.java 1854797 2019-03-04 20:41:39Z tv $
 34  
  */
 35  
 @FunctionalInterface
 36  
 public interface Screen extends Assembler
 37  
 {
 38  
     /** Prefix for screen related classes and templates */
 39  
     String PREFIX = "screens";
 40  
 
 41  
     /** Property for the size of the screen cache if caching is on */
 42  
     String CACHE_SIZE_KEY = "screen.cache.size";
 43  
 
 44  
     /** The default size for the screen cache */
 45  
     int CACHE_SIZE_DEFAULT = 50;
 46  
 
 47  
     /** Represents Screen Objects */
 48  
     String NAME = "screen";
 49  
 
 50  
     /**
 51  
      * A subclass must implement this method to build itself.
 52  
      * Subclasses override this method to store the screen in RunData
 53  
      * or to write the screen to the output stream referenced in
 54  
      * RunData.
 55  
      * @param pipelineData Turbine information.
 56  
      * @return the content of the screen
 57  
      * @throws Exception a generic exception.
 58  
      */
 59  
     String doBuild(PipelineData pipelineData) throws Exception;
 60  
 
 61  
     /**
 62  
      * Subclasses can override this method to add additional
 63  
      * functionality.
 64  
      *
 65  
      * @param pipelineData Turbine information.
 66  
      * @return the content of the screen
 67  
      * @throws Exception a generic exception.
 68  
      */
 69  
     default String build(PipelineData pipelineData)
 70  
         throws Exception
 71  
     {
 72  
         return doBuild(pipelineData);
 73  
     }
 74  
 
 75  
     /**
 76  
      * If the Layout has not been defined by the Screen then set the
 77  
      * layout to be "DefaultLayout".  The Screen object can also
 78  
      * override this method to provide intelligent determination of
 79  
      * the Layout to execute.  You can also define that logic here as
 80  
      * well if you want it to apply on a global scale.  For example,
 81  
      * if you wanted to allow someone to define Layout "preferences"
 82  
      * where they could dynamically change the Layout for the entire
 83  
      * site.  The information for the request is passed in with the
 84  
      * PipelineData object.
 85  
      *
 86  
      * @param pipelineData Turbine information.
 87  
      * @return A String with the Layout.
 88  
      */
 89  
     default String getLayout(PipelineData pipelineData)
 90  
     {
 91  
         RunData data = pipelineData.getRunData();
 92  
         return data.getLayout();
 93  
     }
 94  
 
 95  
     /**
 96  
      * Set the layout for a Screen.
 97  
      *
 98  
      * @param pipelineData Turbine information.
 99  
      * @param layout The layout name.
 100  
      */
 101  
     default void setLayout(PipelineData pipelineData, String layout)
 102  
     {
 103  
         RunData data = pipelineData.getRunData();
 104  
         data.setLayout(layout);
 105  
     }
 106  
 }