Package org.spongepowered.asm.util
Class PrettyPrinter
java.lang.Object
org.spongepowered.asm.util.PrettyPrinter
Prints information in a pretty box
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTable column alignmentstatic interfaceInterface for object which supports printing to pretty printer -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected intKey/value key widthprotected intBox with (adapts to contents)protected intWrap width used when an explicit wrap width is not specified -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd()Adds a blank line to the outputAdds the specified object to the outputAdd elements of the array to the output, one per lineAdd elements of the array to the output, one per lineAdds the specified object to the outputadd(StackTraceElement[] stackTrace, int indent) Print a formatted representation of the specified stack trace with the specified indentAdds a string line to the outputAdds a formatted line to the outputPrint a formatted representation of the specified throwable with the default indent (4)Print a formatted representation of the specified throwable with the specified indentAdd all values of the specified map to this printer as key/value pairsadd(PrettyPrinter.IPrettyPrintable printable) Adds a pretty-printable object to the output, the object is responsible for adding its own representation to this printeraddIndexed(Object[] array) Add elements of the array to the output, one per line, with array indicesaddWithIndices(Collection<?> c) Add elements of the collection to the output, one per line, with indicesaddWrapped(int width, String format, Object... args) Adds a formatted line to the output, and attempts to wrap the line content to the specified widthaddWrapped(String format, Object... args) Adds a formatted line to the output, and attempts to wrap the line content to the current wrap widthcentre()Centre the last line addedstatic voidConvenience method, alternative to using Thread.dumpStack which prints to stderr in pretty-printed format.hr()Adds a horizontal rule to the outputhr(char ruleChar) Adds a horizontal rule of the specified char to the outputAdd a key/value pair to the outputAdd a formatted key/value pair to the outputkvWidth(int width) Set the minimum key display widthWrite this printer to the specified logger atLevel.INFOWrite this printer to the specified loggerWrite this printer to the specified logger atLevel.INFOprint()Print this printer to stderrprint(PrintStream stream) Print this printer to the specified outputstatic voidConvenience methods, pretty-prints the specified throwable to stderrspacing(int spacing) Set the column spacing for the current table.table()Begin a new table with no header and adaptive column widthsBegin a new table with the specified format.Begin a new table with the specified headers and adaptive column widthsth()Print the current table header.Print a table row with the specified values.trace()Outputs this printer to stderr and to a logger decorated with the calling class name with levelLevel.DEBUGtrace(PrintStream stream) Outputs this printer to the specified stream and to a logger decorated with the calling class name with levelLevel.DEBUGtrace(PrintStream stream, String logger) Outputs this printer to the specified stream and to a logger with the specified name with levelLevel.DEBUGtrace(PrintStream stream, String logger, Level level) Outputs this printer to the specified stream and to a logger with the specified name at the specified leveltrace(PrintStream stream, ILogger logger) Outputs this printer to the specified stream and to the supplied logger with levelLevel.DEBUGtrace(PrintStream stream, ILogger logger, Level level) Outputs this printer to the specified stream and to the supplied logger with at the specified leveltrace(PrintStream stream, Level level) Outputs this printer to the specified stream and to a logger decorated with the calling class name with the specified levelOutputs this printer to stderr and to a logger decorated with specified name with levelLevel.DEBUGOutputs this printer to stderr and to a logger decorated with specified name with the specified levelOutputs this printer to stderr and to the supplied logger with levelLevel.DEBUGOutputs this printer to stderr and to the supplied logger with the specified levelOutputs this printer to stderr and to a logger decorated with the calling class name at the specified levelintwrapTo()Get the current wrap widthwrapTo(int wrapWidth) Set the wrap width (default 80 columns)
-
Field Details
-
width
protected int widthBox with (adapts to contents) -
wrapWidth
protected int wrapWidthWrap width used when an explicit wrap width is not specified -
kvKeyWidth
protected int kvKeyWidthKey/value key width -
kvFormat
-
-
Constructor Details
-
PrettyPrinter
public PrettyPrinter() -
PrettyPrinter
public PrettyPrinter(int width)
-
-
Method Details
-
wrapTo
Set the wrap width (default 80 columns)- Parameters:
wrapWidth- new width (in characters) to wrap to- Returns:
- fluent interface
-
wrapTo
public int wrapTo()Get the current wrap width- Returns:
- the current wrap width
-
table
Begin a new table with no header and adaptive column widths- Returns:
- fluent interface
-
table
Begin a new table with the specified headers and adaptive column widths- Parameters:
titles- Column titles- Returns:
- fluent interface
-
table
Begin a new table with the specified format. The format is specified as a sequence of values withStrings defining column titles,Integers defining column widths, andPrettyPrinter.Alignments defining column alignments. Widths and alignment specifiers should follow the relevant column title. Specify a negative value to specify the maximum width for a column (values will be truncated).For example, to specify a table with two columns of width 10:
printer.table("Column 1", 10, "Column 2", 10);A table with a column 30 characters wide and a right-aligned column 20 characters wide:
printer.table("Column 1", 30, "Column 2", 20, Alignment.RIGHT);- Parameters:
format- format string, see description- Returns:
- fluent interface
-
spacing
Set the column spacing for the current table. Default = 2- Parameters:
spacing- Column spacing in characters- Returns:
- fluent interface
-
th
Print the current table header. The table header is automatically printed before the first row if not explicitly specified by calling this method.- Returns:
- fluent interface
-
tr
Print a table row with the specified values. If more columns are specified than exist in the table, then the table is automatically expanded.- Parameters:
args- column values- Returns:
- fluent interface
-
add
Adds a blank line to the output- Returns:
- fluent interface
-
add
Adds a string line to the output- Parameters:
string- format string- Returns:
- fluent interface
-
add
Adds a formatted line to the output- Parameters:
format- format stringargs- arguments- Returns:
- fluent interface
-
add
Add elements of the array to the output, one per line- Parameters:
array- Array of objects to print- Returns:
- fluent interface
-
add
Add elements of the array to the output, one per line- Parameters:
array- Array of objects to printformat- Format for each row- Returns:
- fluent interface
-
addIndexed
Add elements of the array to the output, one per line, with array indices- Parameters:
array- Array of objects to print- Returns:
- fluent interface
-
addWithIndices
Add elements of the collection to the output, one per line, with indices- Parameters:
c- Collection of objects to print- Returns:
- fluent interface
-
add
Adds a pretty-printable object to the output, the object is responsible for adding its own representation to this printer- Parameters:
printable- object to add- Returns:
- fluent interface
-
add
Print a formatted representation of the specified throwable with the default indent (4)- Parameters:
th- Throwable to print- Returns:
- fluent interface
-
add
Print a formatted representation of the specified throwable with the specified indent- Parameters:
th- Throwable to printindent- Indent size for stacktrace lines- Returns:
- fluent interface
-
add
Print a formatted representation of the specified stack trace with the specified indent- Parameters:
stackTrace- stack trace to printindent- Indent size for stacktrace lines- Returns:
- fluent interface
-
add
Adds the specified object to the output- Parameters:
object- object to add- Returns:
- fluent interface
-
add
Adds the specified object to the output- Parameters:
object- object to addindent- indent amount- Returns:
- fluent interface
-
addWrapped
Adds a formatted line to the output, and attempts to wrap the line content to the current wrap width- Parameters:
format- format stringargs- arguments- Returns:
- fluent interface
-
addWrapped
Adds a formatted line to the output, and attempts to wrap the line content to the specified width- Parameters:
width- wrap width to use for this contentformat- format stringargs- arguments- Returns:
- fluent interface
-
kv
Add a formatted key/value pair to the output- Parameters:
key- Keyformat- Value formatargs- Value args- Returns:
- fluent interface
-
kv
Add a key/value pair to the output- Parameters:
key- Keyvalue- Value- Returns:
- fluent interface
-
kvWidth
Set the minimum key display width- Parameters:
width- width to set- Returns:
- fluent
-
add
Add all values of the specified map to this printer as key/value pairs- Parameters:
map- Map with entries to add- Returns:
- fluent
-
hr
Adds a horizontal rule to the output- Returns:
- fluent interface
-
hr
Adds a horizontal rule of the specified char to the output- Parameters:
ruleChar- character to use for the horizontal rule- Returns:
- fluent interface
-
centre
Centre the last line added- Returns:
- fluent interface
-
trace
Outputs this printer to stderr and to a logger decorated with the calling class name with levelLevel.DEBUG- Returns:
- fluent interface
-
trace
Outputs this printer to stderr and to a logger decorated with the calling class name at the specified level- Parameters:
level- Log level to write messages- Returns:
- fluent interface
-
trace
Outputs this printer to stderr and to a logger decorated with specified name with levelLevel.DEBUG- Parameters:
logger- Logger name to write to- Returns:
- fluent interface
-
trace
Outputs this printer to stderr and to a logger decorated with specified name with the specified level- Parameters:
logger- Logger name to write tolevel- Log level to write messages- Returns:
- fluent interface
-
trace
Outputs this printer to stderr and to the supplied logger with levelLevel.DEBUG- Parameters:
logger- Logger to write to- Returns:
- fluent interface
-
trace
Outputs this printer to stderr and to the supplied logger with the specified level- Parameters:
logger- Logger to write tolevel- Log level to write messages- Returns:
- fluent interface
-
trace
Outputs this printer to the specified stream and to a logger decorated with the calling class name with levelLevel.DEBUG- Parameters:
stream- Output stream to print to- Returns:
- fluent interface
-
trace
Outputs this printer to the specified stream and to a logger decorated with the calling class name with the specified level- Parameters:
stream- Output stream to print tolevel- Log level to write messages- Returns:
- fluent interface
-
trace
Outputs this printer to the specified stream and to a logger with the specified name with levelLevel.DEBUG- Parameters:
stream- Output stream to print tologger- Logger name to write to- Returns:
- fluent interface
-
trace
Outputs this printer to the specified stream and to a logger with the specified name at the specified level- Parameters:
stream- Output stream to print tologger- Logger name to write tolevel- Log level to write messages- Returns:
- fluent interface
-
trace
Outputs this printer to the specified stream and to the supplied logger with levelLevel.DEBUG- Parameters:
stream- Output stream to print tologger- Logger to write to- Returns:
- fluent interface
-
trace
Outputs this printer to the specified stream and to the supplied logger with at the specified level- Parameters:
stream- Output stream to print tologger- Logger to write tolevel- Log level to write messages- Returns:
- fluent interface
-
print
Print this printer to stderr- Returns:
- fluent interface
-
print
Print this printer to the specified output- Parameters:
stream- stream to print to- Returns:
- fluent interface
-
log
Write this printer to the specified logger atLevel.INFO- Parameters:
logger- logger to log to- Returns:
- fluent interface
-
log
Write this printer to the specified logger atLevel.INFO- Parameters:
level- log level- Returns:
- fluent interface
-
log
Write this printer to the specified logger- Parameters:
logger- logger to log tolevel- log level- Returns:
- fluent interface
-
dumpStack
public static void dumpStack()Convenience method, alternative to using Thread.dumpStack which prints to stderr in pretty-printed format. -
print
Convenience methods, pretty-prints the specified throwable to stderr- Parameters:
th- Throwable to log
-