public class TextHelpAppendable extends FilterHelpAppendable
| Modifier and Type | Field | Description |
|---|---|---|
static int |
DEFAULT_INDENT |
The number of space characters to be prefixed to each description line: 3.
|
static int |
DEFAULT_LEFT_PAD |
The default padding to the left of each line: 1.
|
static int |
DEFAULT_LIST_INDENT |
The number of space characters before a list continuation line: 7.
|
static int |
DEFAULT_WIDTH |
The default number of characters per line: 74.
|
output| Constructor | Description |
|---|---|
TextHelpAppendable(Appendable output) |
Constructs an appendable filter built on top of the specified underlying appendable.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected TableDefinition |
adjustTableFormat(TableDefinition table) |
Adjusts the table format.
|
void |
appendHeader(int level,
CharSequence text) |
Appends a header.
|
void |
appendList(boolean ordered,
Collection<CharSequence> list) |
Appends a list.
|
void |
appendParagraph(CharSequence paragraph) |
Appends a paragraph.
|
void |
appendTable(TableDefinition rawTable) |
Appends a table.
|
void |
appendTitle(CharSequence title) |
Appends a title.
|
int |
getIndent() |
Gets the indent for the output.
|
int |
getLeftPad() |
Returns the left padding for the output.
|
int |
getMaxWidth() |
Gets the maximum width for the output
|
TextStyle.Builder |
getTextStyleBuilder() |
Gets the style builder used to format text that is not otherwise formatted.
|
static int |
indexOfWrap(CharSequence text,
int width,
int startPos) |
Finds the next text wrap position after
startPos for the text in text with the column width width. |
protected Queue<String> |
makeColumnQueue(CharSequence columnData,
TextStyle style) |
Creates a queue comprising strings extracted from columnData where the alignment and length are determined by the style.
|
protected List<Queue<String>> |
makeColumnQueues(List<String> columnData,
List<TextStyle> styles) |
For each column in the
columnData apply the associated TextStyle and generated a queue of strings that are the maximum size of the column
+ the left pad. |
void |
printWrapped(String text) |
Prints wrapped text using the TextHelpAppendable output style.
|
void |
printWrapped(String text,
TextStyle style) |
Prints wrapped text.
|
protected TextStyle.Builder |
resize(TextStyle.Builder builder,
double fraction) |
Resizes a TextStyle builder based on the fractional size.
|
void |
setIndent(int indent) |
Sets the indent for the output.
|
void |
setLeftPad(int leftPad) |
Sets the left padding: the number of characters from the left edge to start output.
|
void |
setMaxWidth(int maxWidth) |
Sets the maximum width for the output.
|
protected static TextHelpAppendable |
systemOut() |
Creates a new TextHelpAppendable on
System.out. |
protected void |
writeColumnQueues(List<Queue<String>> columnQueues,
List<TextStyle> styles) |
Writes one line from each of the
columnQueues until all the queues are exhausted. |
append, append, appendclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitappendFormat, appendParagraphFormatpublic static final int DEFAULT_WIDTH
public static final int DEFAULT_LEFT_PAD
public static final int DEFAULT_INDENT
public static final int DEFAULT_LIST_INDENT
public TextHelpAppendable(Appendable output)
output - the underlying appendable to be assigned to the field this.output for later use, or null if this instance is to be created
without an underlying stream.public static int indexOfWrap(CharSequence text, int width, int startPos)
startPos for the text in text with the column width width. The wrap point is the last
position before startPos+width having a whitespace character (space, \n, \r). If there is no whitespace character before startPos+width, it will return
startPos+width.text - The text being searched for the wrap positionwidth - width of the wrapped textstartPos - position from which to start the lookup whitespace characterprotected static TextHelpAppendable systemOut()
System.out.System.out.protected TableDefinition adjustTableFormat(TableDefinition table)
Given the width of the page and the size of the table attempt to resize the columns to fit the page width if necessary. Adjustments are made as follows:
Note: it is possible for the size of the columns to exceed the declared page width. In this case the table will extend beyond the desired page width.
table - the table to adjust.public void appendHeader(int level, CharSequence text) throws IOException
HelpAppendablelevel - the level of the header. This is equivalent to the "1", "2", or "3" in the HTML "h1", "h2", "h3" tags.text - the text for the header, null is a noop.IOException - If an output error occurs.public void appendList(boolean ordered, Collection<CharSequence> list) throws IOException
HelpAppendableordered - true if the list should be ordered.list - the list to write, null is a noop.IOException - If an output error occurs.public void appendParagraph(CharSequence paragraph) throws IOException
HelpAppendableparagraph - the paragraph to write, null is a noop.IOException - If an output error occurs.public void appendTable(TableDefinition rawTable) throws IOException
HelpAppendablerawTable - the table definition to write, null is a noop.IOException - If an output error occurs.public void appendTitle(CharSequence title) throws IOException
HelpAppendabletitle - the title to write, null is a noop.IOException - If an output error occurs.public int getIndent()
public int getLeftPad()
public int getMaxWidth()
public TextStyle.Builder getTextStyleBuilder()
protected Queue<String> makeColumnQueue(CharSequence columnData, TextStyle style)
columnData - The string to wrapstyle - The TextStyle to guide the wrapping.protected List<Queue<String>> makeColumnQueues(List<String> columnData, List<TextStyle> styles)
columnData apply the associated TextStyle and generated a queue of strings that are the maximum size of the column
+ the left pad.columnData - The column data to output.styles - the styles to apply.public void printWrapped(String text) throws IOException
text - the text to wrapIOException - on output error.public void printWrapped(String text, TextStyle style) throws IOException
text - the text to wrapstyle - the style for the wrapped text.IOException - on output error.protected TextStyle.Builder resize(TextStyle.Builder builder, double fraction)
builder - the builder to adjust.fraction - the fractional size (for example percentage of the current size) that the builder should be.public void setIndent(int indent)
indent - the indent used for paragraphs.public void setLeftPad(int leftPad)
leftPad - the left padding.public void setMaxWidth(int maxWidth)
maxWidth - the maximum width for the output.protected void writeColumnQueues(List<Queue<String>> columnQueues, List<TextStyle> styles) throws IOException
columnQueues until all the queues are exhausted. If an exhausted queue is encountered while other queues
continue to have content the exhausted queue will produce empty text for the output width of the column (maximum width + left pad).columnQueues - the List of queues that represent the columns of data.styles - the TextStyle for each column.IOException - on output error.Copyright © 2002-2025 The Apache Software Foundation. All rights reserved.Apache Commons CLI | Issue management | Source repository