public class ColumnarTextFormat extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_EOL
Maximum length allowed for formatted help text output.
|
static int |
DEFAULT_MAXIMUM_LINE_LENGTH
Maximum length allowed for formatted help text output.
|
Constructor and Description |
---|
ColumnarTextFormat() |
Modifier and Type | Method and Description |
---|---|
static String |
alignBlock(String toFormat,
int leftSpaces)
Utility method that formats the provided String according to the
assumption that it is composed of one continuous block of text that
should be justified, using the default maximum line length.
|
static String |
alignBlock(String toFormat,
int leftSpaces,
int maximumLineLength,
String eol)
Utility method that formats the provided String according to the
assumption that it is composed of one continuous block of text that
should be justified.
|
static String |
alignTwoColumns(String toFormat,
int leftSpaces,
int separatingSpaces)
Utility method that formats the provided String according to the
assumption that it is composed of newline-delimited lines, and that
each line has the space-delimited format "left right".
|
static String |
alignTwoColumns(String toFormat,
int leftSpaces,
int separation,
int separator)
Utility method that formats the provided String according to the
assumption that it is composed of newline-delimited lines, and that
each line has the space-delimited format "left right".
|
static String |
alignTwoColumns(String toFormat,
int leftSpaces,
int separation,
int separator,
int maximumLineLength)
Utility method that formats the provided String according to the
assumption that it is composed of newline-delimited lines, and that
each line has the space-delimited format "left right".
|
static String |
alignTwoColumns(String toFormat,
int leftSpaces,
int separation,
int separator,
int maximumLineLength,
String eol)
Utility method that formats the provided String according to the
assumption that it is composed of newline-delimited lines, and that
each line has the space-delimited format "left right".
|
static String |
produceTwoColumns(List<String> leftColumn,
int leftOffsetSpaces,
List<String> rightColumn,
int betweenOffset,
int betweenCharacter,
int maximumLineLength,
String eol)
Formats one String combining the contents of the provided Vectors
assuming each to be parallel in number of entries.
|
public static final int DEFAULT_MAXIMUM_LINE_LENGTH
public static final String DEFAULT_EOL
public static String alignBlock(String toFormat, int leftSpaces)
toFormat
- string to be formattedleftSpaces
- number of spaces on the left indentpublic static String alignBlock(String toFormat, int leftSpaces, int maximumLineLength, String eol)
toFormat
- string to be formattedleftSpaces
- number of spaces on the left indentmaximumLineLength
- max line length before wrapping to next lineeol
- end of line string to use for wrapping to next linepublic static String alignTwoColumns(String toFormat, int leftSpaces, int separatingSpaces)
toFormat
- string to be formattedleftSpaces
- number of spaces on the left indentseparatingSpaces
- number of spaces for separating two columnspublic static String alignTwoColumns(String toFormat, int leftSpaces, int separation, int separator)
toFormat
- string to be formattedleftSpaces
- number of spaces on the left indentseparation
- number of separators for separating two columnsseparator
- separator characterpublic static String alignTwoColumns(String toFormat, int leftSpaces, int separation, int separator, int maximumLineLength)
toFormat
- string to be formattedleftSpaces
- number of spaces on the left indentseparation
- number of separators for separating two columnsseparator
- separator charactermaximumLineLength
- max line length before wrapping to next linepublic static String alignTwoColumns(String toFormat, int leftSpaces, int separation, int separator, int maximumLineLength, String eol)
toFormat
- string to be formattedleftSpaces
- number of spaces on the left indentseparation
- number of separators for separating two columnsseparator
- separator charactermaximumLineLength
- max line length before wrapping to next lineeol
- end of line string to use for wrapping to next linepublic static String produceTwoColumns(List<String> leftColumn, int leftOffsetSpaces, List<String> rightColumn, int betweenOffset, int betweenCharacter, int maximumLineLength, String eol)
left right
The left values are extracted from one Vector and the right values from a separate vector, with the number of blank spaces maintained on the left and between columns user-specifiable. The leftmost values are assumed to be relatively short in length. The rightmost values are assumed to be (potentially) long, and will be split into lines. Note that both left and right values may each be multiple words, but the left value will not be split into lines even so. Each right value is split into its individual tokens using a space separator. The longest leftmost value is found, then all left values are justified so they line up and are indented by the specified number of spaces. Then the rightmost values are split into multiple lines by how much space remains on a line and indented appropriately.
The separation between columns will actually be a number of the specified separating characters bookended by blank spaces, one on each end. If two or fewer separating characters then only spaces are applied.
This method can be built on top of a more generalized method at some point when there is more time available.
leftColumn
- left column valuesleftOffsetSpaces
- left offsetrightColumn
- right column valuesbetweenOffset
- spacing offsetbetweenCharacter
- spacing charactermaximumLineLength
- maximum line lengtheol
- of of line stringCopyright © 2016. All Rights Reserved.