Coverage Report - org.apache.tapestry.html.ExceptionDisplay
 
Classes in this File Line Coverage Branch Coverage Complexity
ExceptionDisplay
0%
0/23
0%
0/10
1.5
 
 1  
 // Copyright 2004, 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 org.apache.tapestry.BaseComponent;
 18  
 import org.apache.tapestry.IMarkupWriter;
 19  
 import org.apache.tapestry.IRequestCycle;
 20  
 import org.apache.tapestry.bean.EvenOdd;
 21  
 import org.apache.tapestry.util.exception.ExceptionDescription;
 22  
 
 23  
 import java.util.List;
 24  
 
 25  
 /**
 26  
  * Component used to display an already formatted exception. [ <a
 27  
  * href="../../../../../components/general/exceptiondisplay.html">Component
 28  
  * Reference </a>]
 29  
  * 
 30  
  * @author Howard Lewis Ship
 31  
  */
 32  
 
 33  0
 public abstract class ExceptionDisplay extends BaseComponent
 34  
 {
 35  
     private ExceptionDescription _exception;
 36  
 
 37  
     private EvenOdd _evenOdd;
 38  
 
 39  
     public abstract int getIndex();
 40  
 
 41  
     public abstract int getCount();
 42  
 
 43  
     public abstract void setCount(int count);
 44  
 
 45  
     public abstract ExceptionDescription[] getExceptions();
 46  
     
 47  
     /** @since 4.1.4 */
 48  
     public abstract List getPackages();
 49  
     
 50  
     public abstract String getTrace();
 51  
     
 52  
     /**
 53  
      * Each time the current exception is set, as a side effect, the evenOdd
 54  
      * helper bean is reset to even.
 55  
      */
 56  
 
 57  
     public void setException(ExceptionDescription value)
 58  
     {
 59  0
         _exception = value;
 60  
 
 61  0
         _evenOdd.setEven(true);
 62  0
     }
 63  
 
 64  
     public ExceptionDescription getException()
 65  
     {
 66  0
         return _exception;
 67  
     }
 68  
 
 69  
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 70  
     {
 71  0
         ExceptionDescription[] exceptions = getExceptions();
 72  
 
 73  0
         setCount(exceptions.length);
 74  
 
 75  
         try
 76  
         {
 77  0
             _evenOdd = (EvenOdd) getBeans().getBean("evenOdd");
 78  
 
 79  0
             super.renderComponent(writer, cycle);
 80  
         }
 81  
         finally
 82  
         {
 83  0
             _exception = null;
 84  0
             _evenOdd = null;
 85  0
         }
 86  0
     }
 87  
 
 88  
     public boolean isLast()
 89  
     {
 90  0
         return getIndex() == (getCount() - 1);
 91  
     }
 92  
     
 93  
     public boolean isInPackage() {
 94  0
         List packages = getPackages();
 95  0
         if (packages == null) 
 96  0
             return false;
 97  
         
 98  0
         String trace = getTrace();
 99  0
         for (int i=0; i<packages.size(); i++)
 100  
         {
 101  0
             if (trace.startsWith((String)packages.get(i)))
 102  0
                 return true;
 103  
         }
 104  
         
 105  0
         return false;
 106  
     }
 107  
     
 108  
     public String getStackClass()
 109  
     {
 110  0
         return isInPackage() ? "stackSelected" : null;
 111  
     }
 112  
 }