Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.tapestry.util.exception
Class ExceptionAnalyzer  view ExceptionAnalyzer download ExceptionAnalyzer.java

java.lang.Object
  extended byorg.apache.tapestry.util.exception.ExceptionAnalyzer

public class ExceptionAnalyzer
extends java.lang.Object

Analyzes an exception, creating one or more ExceptionDescriptions from it.


Field Summary
static com.cortexeb.tools.clover.d __CLOVER_406_0
           
private  java.util.List exceptionDescriptions
           
private  boolean exhaustive
           
private static int LIST_SIZE
           
private  java.util.List propertyDescriptions
           
private static int SKIP_LEADING_WHITESPACE
           
private static int SKIP_OTHER_WHITESPACE
           
private static int SKIP_T
           
private  java.io.CharArrayWriter writer
           
 
Constructor Summary
ExceptionAnalyzer()
           
 
Method Summary
 ExceptionDescription[] analyze(java.lang.Throwable exception)
          Analyzes the exceptions.
protected  java.lang.Throwable buildDescription(java.lang.Throwable exception)
           
protected  java.lang.String[] getStackTrace(java.lang.Throwable exception)
          Gets the stack trace for the exception, and converts it into an array of strings.
 boolean isExhaustive()
          If true, then stack trace is extracted for each exception.
 void reportException(java.lang.Throwable exception, java.io.PrintStream stream)
          Produces a text based exception report to the provided stream.
 void setExhaustive(boolean value)
           
private  java.lang.String stripFrame(java.lang.String frame)
          Sun's JVM prefixes each line in the stack trace with "at ", other JVMs don't.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__CLOVER_406_0

public static com.cortexeb.tools.clover.d __CLOVER_406_0

exceptionDescriptions

private java.util.List exceptionDescriptions

propertyDescriptions

private java.util.List propertyDescriptions

writer

private java.io.CharArrayWriter writer

LIST_SIZE

private static final int LIST_SIZE
See Also:
Constant Field Values

exhaustive

private boolean exhaustive

SKIP_LEADING_WHITESPACE

private static final int SKIP_LEADING_WHITESPACE
See Also:
Constant Field Values

SKIP_T

private static final int SKIP_T
See Also:
Constant Field Values

SKIP_OTHER_WHITESPACE

private static final int SKIP_OTHER_WHITESPACE
See Also:
Constant Field Values
Constructor Detail

ExceptionAnalyzer

public ExceptionAnalyzer()
Method Detail

isExhaustive

public boolean isExhaustive()
If true, then stack trace is extracted for each exception. If false, the default, then stack trace is extracted for only the deepest exception.


setExhaustive

public void setExhaustive(boolean value)

analyze

public ExceptionDescription[] analyze(java.lang.Throwable exception)
Analyzes the exceptions. This builds an ExceptionDescription for the exception. It also looks for a non-null java.lang.Throwable property. If one exists, then a second ExceptionDescription is created. This continues until no more nested exceptions can be found.

The description includes a set of name/value properties (as ExceptionProperty) object. This list contains all non-null properties that are not, themselves, java.lang.Throwable.

The name is the display name (not the logical name) of the property. The value is the toString() value of the property. Only properties defined in subclasses of java.lang.Throwable are included.

A future enhancement will be to alphabetically sort the properties by name.


buildDescription

protected java.lang.Throwable buildDescription(java.lang.Throwable exception)

getStackTrace

protected java.lang.String[] getStackTrace(java.lang.Throwable exception)
Gets the stack trace for the exception, and converts it into an array of strings.

This involves parsing the string generated indirectly from Throwable.printStackTrace(PrintWriter). This method can get confused if the message (presumably, the first line emitted by printStackTrace()) spans multiple lines.

Different JVMs format the exception in different ways.

A possible expansion would be more flexibility in defining the pattern used. Hopefully all 'mainstream' JVMs are close enough for this to continue working.


stripFrame

private java.lang.String stripFrame(java.lang.String frame)
Sun's JVM prefixes each line in the stack trace with "at ", other JVMs don't. This method looks for and strips such stuff.


reportException

public void reportException(java.lang.Throwable exception,
                            java.io.PrintStream stream)
Produces a text based exception report to the provided stream.