Package org.apache.commons.cli.help
Class TextStyle
java.lang.Object
org.apache.commons.cli.help.TextStyle
The definition for styling recommendations blocks of text. Most common usage is to style columns in a table, but may also be used to specify default styling
for a
HelpAppendable. HelpWriters are free to ignore the TextStyle recommendations particularly where they are not supported or contradict common
usage.- Since:
- 1.10.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe alignment possibilities.static final classThe builder for the TextStyle. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TextStyle.AlignmentThe alignment.static final TextStyleThe default style as generated by the default Builder.private final intThe size of the indent on the second and any subsequent lines of text.private final intThe size of the left pad.private final intThe maximum size of the text.private final intThe minimum size of the text.private final booleanThe scaling allowed for the block.static final intThe unset value for maxWidth: 2147483647. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateTextStyle(TextStyle.Builder builder) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic TextStyle.Builderbuilder()Creates a new builder.Gets the alignment.intGets the indent value.intGets the left padding.intgets the maximum width.intgets the minimum width.booleanSpecifies if the column can be made wider or to narrower width to fit constraints of the HelpAppendable and formatting.pad(boolean addIndent, CharSequence text) Pads a string to the maximum width or optionally to the maximum width - indent.toString()
-
Field Details
-
UNSET_MAX_WIDTH
public static final int UNSET_MAX_WIDTHThe unset value for maxWidth: 2147483647.- See Also:
-
DEFAULT
The default style as generated by the default Builder. -
alignment
The alignment. -
leftPad
private final int leftPadThe size of the left pad. This is placed before each line of text. -
indent
private final int indentThe size of the indent on the second and any subsequent lines of text. -
scalable
private final boolean scalableThe scaling allowed for the block. -
minWidth
private final int minWidthThe minimum size of the text. -
maxWidth
private final int maxWidthThe maximum size of the text.
-
-
Constructor Details
-
TextStyle
Constructs a new instance.- Parameters:
builder- the builder to build the text style from.
-
-
Method Details
-
builder
Creates a new builder.- Returns:
- a new builder.
-
getAlignment
Gets the alignment.- Returns:
- the alignment.
-
getIndent
public int getIndent()Gets the indent value.- Returns:
- the indent value.
-
getLeftPad
public int getLeftPad()Gets the left padding.- Returns:
- the left padding.
-
getMaxWidth
public int getMaxWidth()gets the maximum width.- Returns:
- The maximum width.
-
getMinWidth
public int getMinWidth()gets the minimum width.- Returns:
- The minimum width.
-
isScalable
public boolean isScalable()Specifies if the column can be made wider or to narrower width to fit constraints of the HelpAppendable and formatting.- Returns:
- the scaling value.
-
pad
Pads a string to the maximum width or optionally to the maximum width - indent.- Returns the string unchanged if it is longer than the specified length.
- Will add the padding based on the alignment.
- Parameters:
addIndent- iftrueaccount for the indent when padding the string.text- the text to pad.- Returns:
- the padded string.
-
toString
-