##### Coverage Report - org.apache.turbine.util.template.TemplateScreen

Classes in this File | Line Coverage | Branch Coverage | Complexity
TemplateScreen |
0% | 0/16
0% | 0/2
| 1.6666666666666667;1,667

1 |  |
     package org.apache.turbine.util.template;
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.commons.logging.Log;
25 |  |
     import org.apache.commons.logging.LogFactory;
26 |  |
     import org.apache.ecs.ConcreteElement;
27 |  |
     import org.apache.turbine.modules.Screen;
28 |  |
     import org.apache.turbine.modules.ScreenLoader;
29 |  |
     import org.apache.turbine.services.assemblerbroker.TurbineAssemblerBroker;
30 |  |
     import org.apache.turbine.util.RunData;
31 |  |
32 |  |
     /**
33 |  |
      * Returns output of a Screen module.  An instance of this is
34 |  |
      * placed in the Velocity context by the VelocityDirectLayout.  This
35 |  |
      * allows the screen to be executed only at rendering.
36 |  |
      * Here's how it's used in a template:
37 |  |
      *
38 |  |
      * <p>
39 |  |
      * <code>
40 |  |
      * $screen_placeholder
41 |  |
      * </code>
42 |  |
      * <p>
43 |  |
      * <code>
44 |  |
      * $screen_placeholder.setScreen("Test")
45 |  |
      * </code>
46 |  |
      * </p>
47 |  |
      *
48 |  |
      * @author <a href="raphael@apache.org">Raphaël Luta</a>
49 |  |
      * @version $Id: TemplateScreen.java 1071044 2011-02-15 20:47:31Z tv $
50 |  |
      */
51 |  |
     public class TemplateScreen
52 |  |
     {
53 |  |
         /** Logging */
54 | 0 |
         private static Log log = LogFactory.getLog(TemplateScreen.class);
55 |  |
56 |  |
         /* The RunData object. */
57 |  |
         private RunData data;
58 |  |
59 |  |
         /* The name of the screen template. */
60 |  |
         private String screen;
61 |  |
62 |  |
         private ScreenLoader screenLoader;
63 |  |
64 |  |
         /**
65 |  |
          * Constructor
66 |  |
          *
67 |  |
          * @param data A Turbine RunData object.
68 |  |
          */
69 |  |
         public TemplateScreen(RunData data)
70 | 0 |
         {
71 | 0 |
             this.data = data;
72 | 0 |
             this.screen = data.getScreen();
73 | 0 |
             this.screenLoader = (ScreenLoader)TurbineAssemblerBroker.getLoader(Screen.NAME);
74 | 0 |
         }
75 |  |
76 |  |
         /**
77 |  |
          * Set the screen.
78 |  |
          *
79 |  |
          * @param screen A String with the name of the screen module
80 |  |
          * @return A TemplateScreen (self).
81 |  |
          */
82 |  |
         public TemplateScreen setScreen(String screen)
83 |  |
         {
84 | 0 |
             this.screen = screen;
85 | 0 |
             return this;
86 |  |
         }
87 |  |
88 |  |
         /**
89 |  |
          * Builds the output of the navigation template.
90 |  |
          *
91 |  |
          * @return A String.
92 |  |
          */
93 |  |
         public String toString()
94 |  |
         {
95 | 0 |
             String returnValue = "";
96 |  |
97 |  |
             try
98 |  |
             {
99 | 0 |
                 ConcreteElement results = screenLoader.eval(data, this.screen);
100 |  |
101 | 0 |
                 if (results != null)
102 |  |
                 {
103 | 0 |
                     returnValue = results.toString();
104 |  |
                 }
105 |  |
             }
106 | 0 |
             catch (Exception e)
107 |  |
             {
108 | 0 |
                 log.error(e);
109 | 0 |
             }
110 |  |
111 | 0 |
             return returnValue;
112 |  |
         }
113 |  |
     }