Class InfoTable
- java.lang.Object
-
- ca.cgjennings.apps.arkham.plugins.debugging.InfoTable
-
public class InfoTable extends java.lang.Object
Used to package and unpackage tabular information to aid with debugging. If you wish to add a new kind of table data that can be viewed with debuggers that support this feature, you must implement aTableGenerator
and register it withTables
.- Since:
- 3.0
- Author:
- Chris Jennings
- See Also:
TableGenerator
,Tables
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String... row)
Adds a new row of data to the table.static InfoTable
errorTable(java.lang.String message, java.lang.Throwable t)
Creates a dummy table that is filled in with an error message.static java.lang.String
escape(java.lang.String s)
Escapes the content of a cell string into the format used for serialization.java.lang.String
get(int row, int col)
Returns the table cell for the requested row and column.java.lang.String[]
getColumns()
Returns an array of the column names for this table.void
install(javax.swing.JTable t)
Install this table's data in aJTable
, replacing the existing table model.void
section(java.lang.String name)
Inserts a new section into the table data.void
serialize(java.lang.StringBuilder b)
Serializes this table's content by writing a string into aStringBuilder
.void
setColumns(java.lang.String... cols)
Sets the column names used by this table.static java.lang.String
unescape(java.lang.String s)
Unescapes a previously escaped string from the format used for serialization.
-
-
-
Method Detail
-
setColumns
public void setColumns(java.lang.String... cols)
Sets the column names used by this table. The columns can only be set once.- Parameters:
cols
- an array of column names- Throws:
java.lang.NullPointerException
- ifcols
isnull
java.lang.IllegalArgumentException
- if the columns
-
getColumns
public java.lang.String[] getColumns()
Returns an array of the column names for this table.- Returns:
- the columns previously set on this table
-
section
public void section(java.lang.String name)
Inserts a new section into the table data. A section is a row with only one column.- Parameters:
name
- the name of the section- Throws:
java.lang.IllegalStateException
- if the columns have not been set
-
add
public void add(java.lang.String... row)
Adds a new row of data to the table. One string is passed per column; if the number of strings passed in is less than the number of columns, additional empty columns will be appended to fill out the row. If too many strings are passed in, the superfluous strings are ignored.- Parameters:
row
- the strings that make up the cells in the this row- Throws:
java.lang.IllegalStateException
- if the columns have not been set
-
get
public java.lang.String get(int row, int col)
Returns the table cell for the requested row and column.- Parameters:
row
- the index of the cell's rowcol
- the index of the cell's column- Returns:
- the cell data at the requested row and column
- Throws:
java.lang.IndexOutOfBoundsException
- if the row or column is outside of the table
-
serialize
public void serialize(java.lang.StringBuilder b)
Serializes this table's content by writing a string into aStringBuilder
. This prepares the table for transport to a debugging client running in a separate process.- Parameters:
b
- the string builder to append the table to
-
install
public void install(javax.swing.JTable t)
Install this table's data in aJTable
, replacing the existing table model.- Parameters:
t
- the table component to use to display the data
-
escape
public static java.lang.String escape(java.lang.String s)
Escapes the content of a cell string into the format used for serialization. You do not typically call this directly; the table implementation handles escaping and unescaping transparently.- Parameters:
s
- the string to escape- Returns:
- an escaped string that is ready to serialize
-
unescape
public static java.lang.String unescape(java.lang.String s)
Unescapes a previously escaped string from the format used for serialization. You do not typically call this directly; the table implementation handles escaping and unescaping transparently.- Parameters:
s
- the string to unescape- Returns:
- an unescaped string
-
errorTable
public static InfoTable errorTable(java.lang.String message, java.lang.Throwable t)
Creates a dummy table that is filled in with an error message. This can be used to generate a stand-in table when table generation fails.- Parameters:
message
- an optional messaget
- an optional exception- Returns:
- a table that describes the error
-
-