Package org.apache.commons.cli.help
Class TextStyle
- java.lang.Object
-
- org.apache.commons.cli.help.TextStyle
-
public final class TextStyle extends java.lang.ObjectThe 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 aHelpAppendable. 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 Classes Modifier and Type Class Description static classTextStyle.AlignmentThe alignment possibilities.static classTextStyle.BuilderThe builder for the TextStyle.
-
Field Summary
Fields Modifier and Type Field Description private TextStyle.AlignmentalignmentThe alignment.static TextStyleDEFAULTThe default style as generated by the default Builder.private intindentThe size of the indent on the second and any subsequent lines of text.private intleftPadThe size of the left pad.private intmaxWidthThe maximum size of the text.private intminWidthThe minimum size of the text.private booleanscalableThe scaling allowed for the block.static intUNSET_MAX_WIDTHThe unset value for maxWidth: 2147483647.
-
Constructor Summary
Constructors Modifier Constructor Description privateTextStyle(TextStyle.Builder builder)Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TextStyle.Builderbuilder()Creates a new builder.TextStyle.AlignmentgetAlignment()Gets the alignment.intgetIndent()Gets the indent value.intgetLeftPad()Gets the left padding.intgetMaxWidth()gets the maximum width.intgetMinWidth()gets the minimum width.booleanisScalable()Specifies if the column can be made wider or to narrower width to fit constraints of the HelpAppendable and formatting.java.lang.CharSequencepad(boolean addIndent, java.lang.CharSequence text)Pads a string to the maximum width or optionally to the maximum width - indent.java.lang.StringtoString()
-
-
-
Field Detail
-
UNSET_MAX_WIDTH
public static final int UNSET_MAX_WIDTH
The unset value for maxWidth: 2147483647.- See Also:
- Constant Field Values
-
DEFAULT
public static final TextStyle DEFAULT
The default style as generated by the default Builder.
-
alignment
private final TextStyle.Alignment alignment
The alignment.
-
leftPad
private final int leftPad
The size of the left pad. This is placed before each line of text.
-
indent
private final int indent
The size of the indent on the second and any subsequent lines of text.
-
scalable
private final boolean scalable
The scaling allowed for the block.
-
minWidth
private final int minWidth
The minimum size of the text.
-
maxWidth
private final int maxWidth
The maximum size of the text.
-
-
Constructor Detail
-
TextStyle
private TextStyle(TextStyle.Builder builder)
Constructs a new instance.- Parameters:
builder- the builder to build the text style from.
-
-
Method Detail
-
builder
public static TextStyle.Builder builder()
Creates a new builder.- Returns:
- a new builder.
-
getAlignment
public TextStyle.Alignment 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
public java.lang.CharSequence pad(boolean addIndent, java.lang.CharSequence text)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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-