Modifier and Type | Method and Description |
---|---|
WordWrap.Builder |
breakWords(boolean breakWords)
If a word is longer than
maxWidth and breakWords is true then
such a word will be broken across two or more lines (with or without a hyphen
according to insertHyphens(boolean) ). |
WordWrap.Builder |
excludeExtraWordChars(String excludeWordChars)
Adds extra word characters to be excluded.
|
WordWrap.Builder |
extraWordChars(Set<Character> extraWordChars)
Sets all extra word characters (characters that will be treated like normal
alphabetic characters for defining word boundaries).
|
WordWrap.Builder |
extraWordChars(String extraWordChars)
Sets all extra word characters (characters that will be treated like normal
alphabetic characters for defining word boundaries).
|
WordWrap.Builder |
includeExtraWordChars(String includeWordChars)
Adds more word characters (characters that will be treated like normal
alphabetic characters for defining word boundaries).
|
WordWrap.Builder |
insertHyphens(boolean insertHyphens)
Sets if to break words using a hyphen character.
|
WordWrap.Builder |
maxWidth(Number maxWidth)
Sets the maximum width of a line using the
stringWidth function. |
WordWrap.Builder |
newLine(String newLine)
Sets the newLine string to be used.
|
WordWrap.Builder |
stringWidth(Function<? super CharSequence,? extends Number> stringWidth)
Sets the string width function used to determine if a line is at maximum
width (and therefore needing wrapping or splitting).
|
String |
wrap()
Performs the wrapping of the source text and returns output as a String.
|
void |
wrap(File file,
Charset charset)
Performs the wrapping of the source text and writes output to the given file
with the given character set encoding.
|
void |
wrap(LineConsumer consumer) |
void |
wrap(String filename,
Charset charset)
Performs the wrapping of the source text and writes the output to a file with
the given filename using the given encoding.
|
void |
wrap(Writer out)
Performs the wrapping of the source text and writes output to the given
Writer . |
List<String> |
wrapToList() |
void |
wrapUtf8(File file)
Performs the wrapping of the source text and writes the output to the given
file using UTF-8 encoding.
|
void |
wrapUtf8(String filename)
Performs the wrapping of the source text and writes the output to a file with
the given filename.
|
public WordWrap.Builder maxWidth(Number maxWidth)
stringWidth
function. Word
wrapping/splitting will be attempted for lines with greater than
maxWidth
. If not set the default is 80.maxWidth
- maximum width of a line using the stringWidth
function.IllegalArgumentException
- if maxWidth
is less than or equal to
zeropublic WordWrap.Builder stringWidth(Function<? super CharSequence,? extends Number> stringWidth)
stringWidth
- function that returns the width of a sequence of
characterspublic WordWrap.Builder newLine(String newLine)
newLine
- string to be output on for a new line delimiterpublic WordWrap.Builder extraWordChars(Set<Character> extraWordChars)
extraWordChars
- extra word characters (in addtion to alphabetic
characters)public WordWrap.Builder extraWordChars(String extraWordChars)
extraWordChars
- extra word characters (in addtion to alphabetic
characters)public WordWrap.Builder includeExtraWordChars(String includeWordChars)
includeWordChars
- more word characterspublic WordWrap.Builder excludeExtraWordChars(String excludeWordChars)
excludeWordChars
- extra word characters to be excludedpublic WordWrap.Builder insertHyphens(boolean insertHyphens)
insertHyphens
- whether to break hyphenspublic WordWrap.Builder breakWords(boolean breakWords)
maxWidth
and breakWords
is true then
such a word will be broken across two or more lines (with or without a hyphen
according to insertHyphens(boolean)
).breakWords
- if true then break words across linespublic void wrap(Writer out)
Writer
.out
- output for wrapped textpublic void wrap(LineConsumer consumer)
public void wrap(File file, Charset charset)
file
- file to receive wrapped outputcharset
- encoding to use for outputpublic void wrapUtf8(File file)
file
- output file for wrapped textpublic void wrapUtf8(String filename)
filename
- output file for wrapped textpublic void wrap(String filename, Charset charset)
filename
- output file for the wrapped textcharset
- encoding to use for outputpublic String wrap()
Copyright © 2018–2024. All rights reserved.