Clover coverage report - Code Coverage for tapestry release 4.0-beta-2
Coverage timestamp: Sat Jul 9 2005 22:02:17 EDT
file stats: LOC: 111   Methods: 5
NCLOC: 69   Classes: 1
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover
 
 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.web.WebUtils;
 28   
 29    /**
 30    * Supports the {@link org.apache.tapestry.pages.Exception} page by displaying the request,
 31    * session, servlet context and servlet object for the current request.
 32    *
 33    * @author Howard M. Lewis Ship
 34    * @since 4.0
 35    */
 36    public abstract class RequestDisplay extends BaseComponent
 37    {
 38   
 39  21 public void renderSystemProperties(IMarkupWriter writer)
 40    {
 41   
 42  21 Properties p = System.getProperties();
 43   
 44  21 String pathSeparator = p.getProperty("path.separator");
 45   
 46  21 writer.begin("div");
 47  21 writer.attribute("class", "described-object-title");
 48  21 writer.print("JVM System Properties");
 49  21 writer.end();
 50  21 writer.println();
 51   
 52  21 writer.begin("table");
 53  21 writer.attribute("class", "described-object");
 54   
 55  21 Iterator i = WebUtils.toSortedList(p.keys()).iterator();
 56   
 57  21 while (i.hasNext())
 58    {
 59  1113 String key = (String) i.next();
 60  1113 String value = p.getProperty(key);
 61   
 62  1113 renderKeyAndValue(writer, key, value, pathSeparator);
 63    }
 64   
 65  21 writer.end();
 66    }
 67   
 68  1113 private void renderKeyAndValue(IMarkupWriter writer, String key, String value,
 69    String pathSeparator)
 70    {
 71  1113 String[] values = split(key, value, pathSeparator);
 72   
 73  1113 for (int i = 0; i < values.length; i++)
 74    {
 75  2142 writer.begin("tr");
 76  2142 writer.begin("th");
 77   
 78  2142 if (i == 0)
 79  1113 writer.print(key);
 80   
 81  2142 writer.end();
 82  2142 writer.begin("td");
 83  2142 writer.print(values[i]);
 84  2142 writer.end("tr");
 85  2142 writer.println();
 86    }
 87    }
 88   
 89  1113 private String[] split(String key, String value, String pathSeparator)
 90    {
 91  1113 if (!key.endsWith(".path"))
 92  1029 return new String[]
 93    { value };
 94   
 95  84 StringTokenizer tokenizer = new StringTokenizer(value, pathSeparator);
 96  84 List values = Collections.list(tokenizer);
 97   
 98  84 return (String[]) values.toArray(new String[values.size()]);
 99    }
 100   
 101  21 public IRender getSystemPropertiesRenderer()
 102    {
 103  21 return new IRender()
 104    {
 105  21 public void render(IMarkupWriter writer, IRequestCycle cycle)
 106    {
 107  21 renderSystemProperties(writer);
 108    }
 109    };
 110    }
 111    }