Class TextFormatting
java.lang.Object
de.chojo.jdautil.text.TextFormatting
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic StringTrims a text to the desired length.static StringfillString(String string, int fill) Appends white spaces to a string to match the given length.static StringgetRangeAsString(String delimiter, String[] source, int from, int to) Returns a range of a string array as string.static TextFormatting.TableBuildergetTableBuilder(int size, @NotNull String... columnNames) static TextFormatting.TableBuildergetTableBuilder(Collection<?> collection, @NotNull String... columnNames) Create a new TableBuilder.static StringGet the current time as string.static StringmapBooleanTo(boolean bool, String trueTo, String falseTo) Changes the boolean in to a specified String.
-
Method Details
-
fillString
-
getRangeAsString
Returns a range of a string array as string.- Parameters:
delimiter- delimiter for string joinsource- source arrayfrom- start index (included). Use negative counts to count from the last index.to- end index (excluded). Use negative counts to count from the last index.- Returns:
- range as string
-
cropText
Trims a text to the desired length. Returns unmodified input if max chars is larger or equal string.length().- Parameters:
string- String to trimendSequence- end sequence which should be append at the end of the string. included in max chars.maxChars- max char length.keepWords- true if no word should be cut.- Returns:
- String with length of maxChars of shorter.
-
mapBooleanTo
-
getTableBuilder
public static TextFormatting.TableBuilder getTableBuilder(Collection<?> collection, @NotNull @NotNull String... columnNames) Create a new TableBuilder.- Parameters:
collection- Collection to determine the row size.columnNames- Determines the name and amount of the columns. Empty column names are possible- Returns:
- new Table builder object.
-
getTableBuilder
public static TextFormatting.TableBuilder getTableBuilder(int size, @NotNull @NotNull String... columnNames) -
getTimeAsString
Get the current time as string.- Returns:
- time in format: HH:mm dd.MM.yyyy
-