Coverage report

  %line %branch
org.apache.turbine.modules.screens.Error
0% 
0% 

 1  
 package org.apache.turbine.modules.screens;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 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 java.util.Iterator;
 20  
 import java.util.Map;
 21  
 
 22  
 import org.apache.ecs.ConcreteElement;
 23  
 import org.apache.ecs.html.B;
 24  
 import org.apache.ecs.html.H3;
 25  
 import org.apache.ecs.html.H4;
 26  
 import org.apache.ecs.html.PRE;
 27  
 import org.apache.ecs.html.TD;
 28  
 import org.apache.ecs.html.TR;
 29  
 import org.apache.ecs.html.Table;
 30  
 import org.apache.turbine.modules.Screen;
 31  
 import org.apache.turbine.util.RunData;
 32  
 
 33  
 /**
 34  
  * This is a sample Error Screen module.
 35  
  *
 36  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 37  
  * @version $Id: Error.java 264148 2005-08-29 14:21:04Z henning $
 38  
  */
 39  0
 public class Error extends Screen
 40  
 {
 41  
     /**
 42  
      * Build screen.
 43  
      *
 44  
      * @param data Turbine information.
 45  
      * @return ConcreteElement the page with all the error information.
 46  
      * @throws Exception a generic exception.
 47  
      */
 48  
     public ConcreteElement doBuild(RunData data) throws Exception
 49  
     {
 50  0
         data.setTitle("There has been an error!");
 51  
 
 52  0
         Table table = new Table().setBorder(0);
 53  0
         boolean hasValues = false;
 54  0
         for (Iterator it = data.getParameters().keySet().iterator();
 55  0
              it.hasNext();)
 56  
         {
 57  0
             String key = (String) it.next();
 58  0
             String value = data.getParameters().getString(key);
 59  0
             TR tr =
 60  
                 new TR().addElement(
 61  
                     new TD().addElement(class="keyword">new B(key))).addElement(
 62  
                     new TD().addElement(" = " + value));
 63  0
             table.addElement(tr);
 64  0
             hasValues = true;
 65  
         }
 66  
 
 67  0
         Table table2 = new Table().setBorder(0);
 68  0
         Map varDebug = data.getDebugVariables();
 69  
 
 70  0
         boolean hasValues2 = false;
 71  0
         for (Iterator i = varDebug.keySet().iterator(); i.hasNext();)
 72  
         {
 73  0
             String key = (String) i.next();
 74  0
             String value = varDebug.get(key).toString();
 75  0
             TR tr =
 76  
                 new TR().addElement(
 77  
                     new TD().addElement(class="keyword">new B(key))).addElement(
 78  
                     new TD().addElement(" = " + value));
 79  0
             table2.addElement(tr);
 80  0
             hasValues2 = true;
 81  
         }
 82  
 
 83  0
         data.getPage().getBody().addElement(
 84  
             new H3(
 85  
                 data.getTitle()
 86  
                     + " Please review the exception below "
 87  
                     + "for more information."));
 88  
 
 89  0
         if (hasValues)
 90  
         {
 91  0
             data.getPage().getBody().addElement(
 92  
                 new H4().addElement("Get/Post Data:"));
 93  0
             data.getPage().getBody().addElement(table);
 94  
         }
 95  
 
 96  0
         if (hasValues2)
 97  
         {
 98  0
             data.getPage().getBody().addElement(
 99  
                 new H4().addElement("Debugging Data:"));
 100  0
             data.getPage().getBody().addElement(table2);
 101  
         }
 102  
 
 103  0
         String trace = data.getStackTrace();
 104  0
         if (trace != null)
 105  
         {
 106  0
             data
 107  
                 .getPage()
 108  
                 .getBody()
 109  
                 .addElement(new H4().addElement("The exception is:"))
 110  
                 .addElement(new PRE(trace))
 111  
                 .addElement(new PRE(data.getStackTraceException().toString()));
 112  
         }
 113  0
         return null;
 114  
     }
 115  
 }

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