net.wotonomy.ui.swing.util
Class StackTraceInspector

java.lang.Object
  extended by net.wotonomy.ui.swing.util.StackTraceInspector
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.util.EventListener, javax.swing.table.TableModel

public class StackTraceInspector
extends java.lang.Object
implements javax.swing.table.TableModel, java.awt.event.MouseListener, java.awt.event.ActionListener

The StackTraceInspector displays a JFrame containing stack trace information for a Throwable.

There are also a few static methods for obtaining information about the current stack, which is useful for determining who's calling you at runtime.

Version:
$Revision: 904 $
Author:
michael@mpowers.net

Field Summary
static java.lang.String COPY
           
protected  java.util.List methodNames
           
protected  javax.swing.JTable table
           
protected  java.util.List tableModelListeners
           
 
Constructor Summary
StackTraceInspector()
          Displays the current stack trace at the time of instantiation in a table on a frame.
StackTraceInspector(java.util.List aStringList)
          Simply displays the list items in a dialog.
StackTraceInspector(java.lang.String aMessage)
          Displays the current stack trace at the time of instantiation in a table on a frame annotated with the specified message.
StackTraceInspector(java.lang.Throwable aThrowable)
          Displays the stack trace for the given throwable in a table on a frame.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
           
 void addTableModelListener(javax.swing.event.TableModelListener l)
           
 void copyToClipboard()
          Copies the contents of the table to the clipboard as a tab-delimited string.
 java.lang.Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int columnIndex)
           
static java.lang.String getMyCaller()
          Convenience method that obtains a String representing the caller's caller.
 int getRowCount()
           
 java.lang.String getSelectedStackString()
          Converts the selected contents of the table to a string.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
           
protected  void initLayout(java.util.List items, java.lang.String message)
           
protected  void invokeFileFromString(java.lang.String aString)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 void mouseClicked(java.awt.event.MouseEvent e)
          Double click to call invokeFileFromString.
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
static java.util.List parseStackTrace(java.lang.Throwable aThrowable)
          Obtains a list of strings representing the stack trace associated with this throwable starting with the most recent call.
static void printShortStackTrace()
          Prints a stack trace up to the first method whose fully qualified class name begins with "java" to System.out.
 void removeTableModelListener(javax.swing.event.TableModelListener l)
           
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected javax.swing.JTable table

tableModelListeners

protected java.util.List tableModelListeners

methodNames

protected java.util.List methodNames

COPY

public static final java.lang.String COPY
See Also:
Constant Field Values
Constructor Detail

StackTraceInspector

public StackTraceInspector()
Displays the current stack trace at the time of instantiation in a table on a frame.


StackTraceInspector

public StackTraceInspector(java.lang.String aMessage)
Displays the current stack trace at the time of instantiation in a table on a frame annotated with the specified message.


StackTraceInspector

public StackTraceInspector(java.lang.Throwable aThrowable)
Displays the stack trace for the given throwable in a table on a frame.

Parameters:
aThrowable - A Throwable whose stack will be examined.

StackTraceInspector

public StackTraceInspector(java.util.List aStringList)
Simply displays the list items in a dialog. Presumably (but not necessarily) called from the other constructors. (I guess if you just want a frame with strings in table, you can call this.)

Parameters:
aStringList - A List containing Strings.
Method Detail

initLayout

protected void initLayout(java.util.List items,
                          java.lang.String message)

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int columnIndex)
Specified by:
getColumnName in interface javax.swing.table.TableModel

getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface javax.swing.table.TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface javax.swing.table.TableModel

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Specified by:
getValueAt in interface javax.swing.table.TableModel

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface javax.swing.table.TableModel

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
addTableModelListener in interface javax.swing.table.TableModel

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
removeTableModelListener in interface javax.swing.table.TableModel

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Double click to call invokeFileFromString.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

copyToClipboard

public void copyToClipboard()
Copies the contents of the table to the clipboard as a tab-delimited string.


getSelectedStackString

public java.lang.String getSelectedStackString()
Converts the selected contents of the table to a string.

Returns:
A String containing the text contents of the table.

parseStackTrace

public static java.util.List parseStackTrace(java.lang.Throwable aThrowable)
Obtains a list of strings representing the stack trace associated with this throwable starting with the most recent call.

Parameters:
aThrowable - A Throwable whose stack trace is parsed.
Returns:
a List containing the method names as Strings.

getMyCaller

public static java.lang.String getMyCaller()
Convenience method that obtains a String representing the caller's caller.

Returns:
a String representing a method in stack trace format.

printShortStackTrace

public static void printShortStackTrace()
Prints a stack trace up to the first method whose fully qualified class name begins with "java" to System.out.


invokeFileFromString

protected void invokeFileFromString(java.lang.String aString)


Copyright © 2006 null. All Rights Reserved.