Coverage Report - org.apache.turbine.modules.NavigationLoader
 
Classes in this File Line Coverage Branch Coverage Complexity
NavigationLoader
72%
8/11
N/A
1
 
 1  
 package org.apache.turbine.modules;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.turbine.Turbine;
 23  
 import org.apache.turbine.pipeline.PipelineData;
 24  
 
 25  
 /**
 26  
  * The purpose of this class is to allow one to load and execute
 27  
  * Navigation modules.
 28  
  *
 29  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 30  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 31  
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
 32  
  * @version $Id: NavigationLoader.java 1773378 2016-12-09 13:19:59Z tv $
 33  
  */
 34  21
 public class NavigationLoader
 35  
     extends GenericLoader<Navigation>
 36  
     implements Loader<Navigation>
 37  
 {
 38  
     /** The single instance of this class. */
 39  32
     private static NavigationLoader instance = new NavigationLoader();
 40  
 
 41  
     /**
 42  
      * These ctor's are private to force clients to use getInstance()
 43  
      * to access this class.
 44  
      */
 45  
     private NavigationLoader()
 46  
     {
 47  32
         super();
 48  32
     }
 49  
 
 50  
     /**
 51  
      * Attempts to load and execute the external Navigation. This is
 52  
      * used when you want to execute a Navigation which returns its
 53  
      * output via a MultiPartElement instead of out the data.getPage()
 54  
      * value.  This allows you to easily chain the execution of
 55  
      * Navigation modules together.
 56  
      *
 57  
      * @param pipelineData Turbine information.
 58  
      * @param name Name of object that will execute the navigation.
 59  
      * @return the navigation module output
 60  
      * @throws Exception a generic exception.
 61  
      */
 62  
     public String eval(PipelineData pipelineData, String name)
 63  
             throws Exception
 64  
     {
 65  
         // Execute Navigation
 66  0
         return getAssembler(name).build(pipelineData);
 67  
     }
 68  
 
 69  
     /**
 70  
      * Attempts to load and execute the external Navigation.
 71  
      *
 72  
      * @param pipelineData Turbine information.
 73  
      * @param name Name of object instance.
 74  
      * @throws Exception a generic exception.
 75  
      */
 76  
     @Override
 77  
     public void exec(PipelineData pipelineData, String name)
 78  
                     throws Exception
 79  
     {
 80  0
         this.eval(pipelineData, name);
 81  0
     }
 82  
 
 83  
     /**
 84  
      * Pulls out an instance of the object by name.  Name is just the
 85  
      * single name of the object.
 86  
      *
 87  
      * @param name Name of object instance.
 88  
      * @return A Layout with the specified name, or null.
 89  
      * @throws Exception a generic exception.
 90  
      */
 91  
     @Override
 92  
     public Navigation getAssembler(String name)
 93  
         throws Exception
 94  
     {
 95  21
         return getAssembler(Navigation.class, name);
 96  
     }
 97  
 
 98  
     /**
 99  
      * @see org.apache.turbine.modules.Loader#getCacheSize()
 100  
      */
 101  
     @Override
 102  
     public int getCacheSize()
 103  
     {
 104  78
         return NavigationLoader.getConfiguredCacheSize();
 105  
     }
 106  
 
 107  
     /**
 108  
      * The method through which this class is accessed.
 109  
      *
 110  
      * @return The single instance of this class.
 111  
      */
 112  
     public static NavigationLoader getInstance()
 113  
     {
 114  66
         return instance;
 115  
     }
 116  
 
 117  
     /**
 118  
      * Helper method to get the configured cache size for this module
 119  
      *
 120  
      * @return the configure cache size
 121  
      */
 122  
     private static int getConfiguredCacheSize()
 123  
     {
 124  78
         return Turbine.getConfiguration().getInt(Navigation.CACHE_SIZE_KEY,
 125  
                 Navigation.CACHE_SIZE_DEFAULT);
 126  
     }
 127  
 }