Clover coverage report - Code Coverage for tapestry release 4.0.2
Coverage timestamp: Thu Apr 13 2006 10:52:06 EDT
file stats: LOC: 134   Methods: 7
NCLOC: 85   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RequestDisplay.java 100% 100% 100% 100%
coverage
 1    // Copyright 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.html;
 16   
 17    import java.util.Collections;
 18    import java.util.Iterator;
 19    import java.util.List;
 20    import java.util.Properties;
 21    import java.util.StringTokenizer;
 22   
 23    import org.apache.tapestry.BaseComponent;
 24    import org.apache.tapestry.IMarkupWriter;
 25    import org.apache.tapestry.IRender;
 26    import org.apache.tapestry.IRequestCycle;
 27    import org.apache.tapestry.describe.ReportStatusHub;
 28    import org.apache.tapestry.web.WebUtils;
 29   
 30    /**
 31    * Supports the {@link org.apache.tapestry.pages.Exception} page by displaying the request,
 32    * session, servlet context and servlet object for the current request.
 33    *
 34    * @author Howard M. Lewis Ship
 35    * @since 4.0
 36    */
 37    public abstract class RequestDisplay extends BaseComponent
 38    {
 39    private boolean _even;
 40   
 41    // Injected
 42   
 43    public abstract ReportStatusHub getReportStatusHub();
 44   
 45  17 public void renderSystemProperties(IMarkupWriter writer)
 46    {
 47  17 _even = true;
 48   
 49  17 Properties p = System.getProperties();
 50   
 51  17 String pathSeparator = p.getProperty("path.separator");
 52   
 53  17 writer.begin("div");
 54  17 writer.attribute("class", "described-object-title");
 55  17 writer.print("JVM System Properties");
 56  17 writer.end();
 57  17 writer.println();
 58   
 59  17 writer.begin("table");
 60  17 writer.attribute("class", "described-object");
 61   
 62  17 Iterator i = WebUtils.toSortedList(p.keys()).iterator();
 63   
 64  17 while (i.hasNext())
 65    {
 66  1122 String key = (String) i.next();
 67  1122 String value = p.getProperty(key);
 68   
 69  1122 renderKeyAndValue(writer, key, value, pathSeparator);
 70    }
 71   
 72  17 writer.end();
 73    }
 74   
 75  1122 private void renderKeyAndValue(IMarkupWriter writer, String key, String value,
 76    String pathSeparator)
 77    {
 78  1122 String[] values = split(key, value, pathSeparator);
 79   
 80  1122 for (int i = 0; i < values.length; i++)
 81    {
 82  1904 writer.begin("tr");
 83   
 84  1904 writer.attribute("class", _even ? "even" : "odd");
 85   
 86  1904 _even = !_even;
 87   
 88  1904 writer.begin("th");
 89   
 90  1904 if (i == 0)
 91  1122 writer.print(key);
 92   
 93  1904 writer.end();
 94  1904 writer.begin("td");
 95  1904 writer.print(values[i]);
 96  1904 writer.end("tr");
 97  1904 writer.println();
 98    }
 99    }
 100   
 101  1122 private String[] split(String key, String value, String pathSeparator)
 102    {
 103  1122 if (!key.endsWith(".path"))
 104  1037 return new String[]
 105    { value };
 106   
 107  85 StringTokenizer tokenizer = new StringTokenizer(value, pathSeparator);
 108  85 List values = Collections.list(tokenizer);
 109   
 110  85 return (String[]) values.toArray(new String[values.size()]);
 111    }
 112   
 113  17 public IRender getSystemPropertiesRenderer()
 114    {
 115  17 return new IRender()
 116    {
 117  17 public void render(IMarkupWriter writer, IRequestCycle cycle)
 118    {
 119  17 renderSystemProperties(writer);
 120    }
 121    };
 122    }
 123   
 124  17 public IRender getReportStatusRenderer()
 125    {
 126  17 return new IRender()
 127    {
 128  17 public void render(IMarkupWriter writer, IRequestCycle cycle)
 129    {
 130  17 getReportStatusHub().fireReportStatus(writer);
 131    }
 132    };
 133    }
 134    }