Interface LineAppendable
-
- All Superinterfaces:
java.lang.Appendable
,java.lang.Iterable<LineInfo>
- All Known Subinterfaces:
HtmlAppendable
- All Known Implementing Classes:
HtmlAppendableBase
,HtmlBuilder
,HtmlMarkdownWriter
,HtmlWriter
,LineAppendableImpl
,MarkdownWriter
,MarkdownWriterBase
public interface LineAppendable extends java.lang.Appendable, java.lang.Iterable<LineInfo>
Used to collect line text for further processingcontrol output of new lines limiting them to terminate text but not create blank lines, and control number of blank lines output, eliminate spaces before and after an \n, except in prefixes and indents controlled by this class.
allows appending unmodified text in preformatted regions created by
openPreFormatted(boolean)
andclosePreFormatted()
consecutive \n in the data are going go be collapsed to a single \n. To get blank lines use
blankLine()
orblankLine(int)
tab is converted to spaces if
F_CONVERT_TABS
orF_COLLAPSE_WHITESPACE
option is selectedspaces before and after \n are removed controlled by
F_TRIM_TRAILING_WHITESPACE
andF_TRIM_LEADING_WHITESPACE
use
line()
,lineIf(boolean)
,blankLine()
as an alternative to appending \n. useblankLineIf(boolean)
andblankLine(int)
for appending blank lines.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
LineAppendable.Options
-
Field Summary
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description @NotNull LineAppendable
addIndentOnFirstEOL(@NotNull java.lang.Runnable listener)
Add an indent on first EOL appended and run runnabledefault @NotNull LineAppendable
addOptions(int flags)
default @NotNull LineAppendable
addPrefix(@NotNull java.lang.CharSequence prefix)
Add to prefix appended after a new line character for every line and after a new line in pre-formatted sections@NotNull LineAppendable
addPrefix(@NotNull java.lang.CharSequence prefix, boolean afterEol)
Add to prefix appended after a new line character for every line and after a new line in pre-formatted sections@NotNull LineAppendable
append(char c)
@NotNull LineAppendable
append(char c, int count)
default @NotNull LineAppendable
append(@NotNull LineAppendable lineAppendable)
Append lines from another line formatting appendable.default @NotNull LineAppendable
append(@NotNull LineAppendable lineAppendable, boolean withPrefixes)
Append lines from another line formatting appendable.@NotNull LineAppendable
append(@NotNull LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes)
Append lines from another line formatting appendable.@NotNull LineAppendable
append(@NotNull java.lang.CharSequence csq)
@NotNull LineAppendable
append(@NotNull java.lang.CharSequence csq, int start, int end)
default @NotNull LineAppendable
appendAll(@NotNull java.lang.Iterable<java.lang.CharSequence> sequences)
default <T extends java.lang.Appendable>
TappendTo(T out)
append lines to appendable with 0 blank lines, if these are desired at the end of the output useappendTo(Appendable, int, int)
.<T extends java.lang.Appendable>
TappendTo(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)
append lines to appendable with given maximum trailing blank lines and given prefix to add to all linesdefault <T extends java.lang.Appendable>
TappendTo(T out, int maxTrailingBlankLines)
Deprecated.default <T extends java.lang.Appendable>
TappendTo(T out, int maxBlankLines, int maxTrailingBlankLines)
default <T extends java.lang.Appendable>
TappendTo(T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)
default <T extends java.lang.Appendable>
TappendToSilently(T out)
default <T extends java.lang.Appendable>
TappendToSilently(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)
default <T extends java.lang.Appendable>
TappendToSilently(T out, int maxBlankLines, int maxTrailingBlankLines)
default <T extends java.lang.Appendable>
TappendToSilently(T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)
@NotNull LineAppendable
blankLine()
Add a blank line, if there is not one already appended.@NotNull LineAppendable
blankLine(int count)
Add a blank lines, if there isn't already given number of blank lines appended.@NotNull LineAppendable
blankLineIf(boolean predicate)
Add a blank line, if predicate is true and there isn't already blank lines appended.@NotNull LineAppendable
changeOptions(int addFlags, int removeFlags)
default @NotNull LineAppendable
clearLineOnFirstText()
@NotNull LineAppendable
closePreFormatted()
Close preformatted section and suspend content modificationint
column()
Get column offset after last appendstatic java.lang.CharSequence
combinedPrefix(@Nullable java.lang.CharSequence prefix, @Nullable java.lang.CharSequence suffix)
default @NotNull LineAppendable
copyAppendable()
default @NotNull LineAppendable
copyAppendable(boolean withPrefixes)
default @NotNull LineAppendable
copyAppendable(int startLine)
default @NotNull LineAppendable
copyAppendable(int startLine, int endLine)
default @NotNull LineAppendable
copyAppendable(int startLine, int endLine, boolean withPrefixes)
Make a copy of this appendable with the given line rangeboolean
endsWithEOL()
default @NotNull LineInfo
get(int lineIndex)
Kotlin index operatorint
getAfterEolPrefixDelta()
Get pending prefix after EOL@NotNull BasedSequence
getBeforeEolPrefix()
Get prefix used before EOL@NotNull ISequenceBuilder<?,?>
getBuilder()
Get builder used for accumulation@NotNull LineAppendable
getEmptyAppendable()
@NotNull BasedSequence
getIndentPrefix()
Get prefix appended after a new line character for every indent level@NotNull BasedSequence
getLine(int lineIndex)
Get Line at given line indexdefault @NotNull BasedSequence
getLineContent(int lineIndex)
Get Line content of given lineint
getLineCount()
Get the number of lines appended, not including any unterminated onesint
getLineCountWithPending()
Get the number of lines appended, including any unterminated ones@NotNull LineInfo
getLineInfo(int lineIndex)
Get Line information at given line indexdefault @NotNull BasedSequence
getLinePrefix(int lineIndex)
Get prefix of given linedefault @NotNull java.lang.Iterable<BasedSequence>
getLines()
default @NotNull java.lang.Iterable<BasedSequence>
getLines(boolean withPrefixes)
default @NotNull java.lang.Iterable<BasedSequence>
getLines(int maxTrailingBlankLines)
default @NotNull java.lang.Iterable<BasedSequence>
getLines(int maxTrailingBlankLines, boolean withPrefixes)
@NotNull java.lang.Iterable<BasedSequence>
getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes)
Full line iterator over some linesdefault @NotNull java.lang.Iterable<LineInfo>
getLinesInfo()
default @NotNull java.lang.Iterable<LineInfo>
getLinesInfo(int maxTrailingBlankLines)
@NotNull java.lang.Iterable<LineInfo>
getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine)
Full line iterator with line infodefault int
getOptions()
Get current options as bit mask flags@NotNull BitFieldSet<LineAppendable.Options>
getOptionSet()
Get current options as set which can be used to modify optionsint
getPendingEOL()
Get number of EOLs at end of appendable, this is actually number of tail blank linesint
getPendingSpace()
Get number of spaces at end of pending text@NotNull BasedSequence
getPrefix()
Get prefix being applied to all lines, even in pre-formatted sections This is the prefix that will be set after EOLdefault int
getTrailingBlankLines()
int
getTrailingBlankLines(int endLine)
Get trailing blank line count ending on given line@NotNull LineAppendable
indent()
Increase the indent level, will terminate the current line if there is unterminated textvoid
insertLine(int lineIndex, @NotNull java.lang.CharSequence prefix, @NotNull java.lang.CharSequence text)
Insert a line at the index with given content and prefix for a linedefault boolean
isEmpty()
Kotlin compatibilitydefault boolean
isNotEmpty()
Kotlin compatibilityboolean
isPendingSpace()
Test if trailing text ends in space or tabboolean
isPreFormatted()
@NotNull java.util.Iterator<LineInfo>
iterator()
Full line iterator NOTE: will not issue line() to terminate any unterminated lines before iteration and will not include unterminated lines in iteration@NotNull LineAppendable
line()
Add a new line if there was any unterminated text appended or if this is a preformatted region@NotNull LineAppendable
lineIf(boolean predicate)
Add a new line, if predicate is true and line() would add an EOL.@NotNull LineAppendable
lineOnFirstText(boolean value)
@NotNull LineAppendable
lineWithTrailingSpaces(int count)
Add a new line, keep trailing spaces if there was any unterminated text appendeddefault @NotNull LineAppendable
noPreserveSpaces()
default @NotNull LineAppendable
noTrimLeading()
int
offset()
Get text offset of all output lines, excluding any text for the last line being accumulatedint
offsetWithPending()
Get offset after last append as if EOL was added but without the EOL itself@NotNull LineAppendable
openPreFormatted(boolean addPrefixToFirstLine)
Open preformatted section and suspend content modification@NotNull LineAppendable
popOptions()
default @NotNull LineAppendable
popPrefix()
Pop a prefix from the stack and set the current prefix@NotNull LineAppendable
popPrefix(boolean afterEol)
Pop a prefix from the stack and set the current prefixdefault @NotNull LineAppendable
preserveSpaces()
@NotNull LineAppendable
pushOptions()
@NotNull LineAppendable
pushPrefix()
Save the current prefix on the stackdefault LineAppendable
removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines)
LineAppendable
removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)
Normalize the appendable by removing extra blank lines in the body or at the end of given line range@NotNull LineAppendable
removeIndentOnFirstEOL(@NotNull java.lang.Runnable listener)
Remove runnable, has no effect if EOL was already appended and runnable was run@NotNull LineAppendable
removeLines(int startLine, int endLine)
default @NotNull LineAppendable
removeOptions(int flags)
@NotNull LineAppendable
setIndentPrefix(@Nullable java.lang.CharSequence prefix)
Set prefix to append after a new line character for every indent levelvoid
setLine(int lineIndex, @NotNull java.lang.CharSequence prefix, @NotNull java.lang.CharSequence text)
Set content and prefix for a linedefault @NotNull LineAppendable
setLineOnFirstText()
default @NotNull LineAppendable
setOptions(int flags)
Set options on processing textdefault @NotNull LineAppendable
setOptions(BitFieldSet<LineAppendable.Options> options)
Set options on processing textdefault @NotNull LineAppendable
setOptions(LineAppendable.Options... options)
default @NotNull LineAppendable
setPrefix(@NotNull java.lang.CharSequence prefix)
Set prefix appended after a new line character for every line and after a new line in pre-formatted sections@NotNull LineAppendable
setPrefix(@Nullable java.lang.CharSequence prefix, boolean afterEol)
Set prefix appended after a new line character for every line and after a new line in pre-formatted sectionsvoid
setPrefixLength(int lineIndex, int prefixLength)
Change prefix length for a given line without changing the line contentstatic BitFieldSet<LineAppendable.Options>
toOptionSet(int options)
static BitFieldSet<LineAppendable.Options>
toOptionSet(LineAppendable.Options... options)
default @NotNull java.lang.CharSequence
toSequence()
default @NotNull java.lang.CharSequence
toSequence(boolean withPrefixes)
default @NotNull java.lang.CharSequence
toSequence(int maxBlankLines, boolean withPrefixes)
default @NotNull java.lang.CharSequence
toSequence(int maxBlankLines, int maxTrailingBlankLines)
@NotNull java.lang.CharSequence
toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes)
get the resulting text for all linesdefault @NotNull java.lang.String
toString(boolean withPrefixes)
default @NotNull java.lang.String
toString(int maxBlankLines)
get the resulting text for all linesdefault @NotNull java.lang.String
toString(int maxBlankLines, boolean withPrefixes)
default @NotNull java.lang.String
toString(int maxBlankLines, int maxTrailingBlankLines)
@NotNull java.lang.String
toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes)
get the resulting text for all linesdefault @NotNull LineAppendable
trimLeading()
@NotNull LineAppendable
unIndent()
Decrease the indent level, min level is 0, will terminate the current line if there is unterminated text@NotNull LineAppendable
unIndentNoEol()
Decrease the indent level, if there is unterminated text then unindented prefix is to be applied after the next EOL.
-
-
-
Field Detail
-
O_CONVERT_TABS
static final LineAppendable.Options O_CONVERT_TABS
-
O_COLLAPSE_WHITESPACE
static final LineAppendable.Options O_COLLAPSE_WHITESPACE
-
O_TRIM_TRAILING_WHITESPACE
static final LineAppendable.Options O_TRIM_TRAILING_WHITESPACE
-
O_PASS_THROUGH
static final LineAppendable.Options O_PASS_THROUGH
-
O_TRIM_LEADING_WHITESPACE
static final LineAppendable.Options O_TRIM_LEADING_WHITESPACE
-
O_TRIM_LEADING_EOL
static final LineAppendable.Options O_TRIM_LEADING_EOL
-
O_PREFIX_PRE_FORMATTED
static final LineAppendable.Options O_PREFIX_PRE_FORMATTED
-
O_FORMAT_ALL
static final BitFieldSet<LineAppendable.Options> O_FORMAT_ALL
-
F_CONVERT_TABS
static final int F_CONVERT_TABS
-
F_COLLAPSE_WHITESPACE
static final int F_COLLAPSE_WHITESPACE
-
F_TRIM_TRAILING_WHITESPACE
static final int F_TRIM_TRAILING_WHITESPACE
-
F_PASS_THROUGH
static final int F_PASS_THROUGH
-
F_TRIM_LEADING_WHITESPACE
static final int F_TRIM_LEADING_WHITESPACE
-
F_TRIM_LEADING_EOL
static final int F_TRIM_LEADING_EOL
-
F_PREFIX_PRE_FORMATTED
static final int F_PREFIX_PRE_FORMATTED
-
F_FORMAT_ALL
static final int F_FORMAT_ALL
-
F_WHITESPACE_REMOVAL
static final int F_WHITESPACE_REMOVAL
-
CONVERT_TABS
@Deprecated static final int CONVERT_TABS
Deprecated.
-
COLLAPSE_WHITESPACE
@Deprecated static final int COLLAPSE_WHITESPACE
Deprecated.
-
TRIM_TRAILING_WHITESPACE
@Deprecated static final int TRIM_TRAILING_WHITESPACE
Deprecated.
-
PASS_THROUGH
@Deprecated static final int PASS_THROUGH
Deprecated.
-
ALLOW_LEADING_WHITESPACE
@Deprecated static final int ALLOW_LEADING_WHITESPACE
Deprecated.ALLOW_LEADING_WHITESPACE is now inverted and named F_TRIM_LEADING_WHITESPACE- See Also:
- Constant Field Values
-
TRIM_LEADING_WHITESPACE
@Deprecated static final int TRIM_LEADING_WHITESPACE
Deprecated.
-
ALLOW_LEADING_EOL
@Deprecated static final int ALLOW_LEADING_EOL
Deprecated.ALLOW_LEADING_EOL is now inverted and named F_TRIM_LEADING_EOL- See Also:
- Constant Field Values
-
PREFIX_PRE_FORMATTED
@Deprecated static final int PREFIX_PRE_FORMATTED
Deprecated.
-
FORMAT_ALL
@Deprecated static final int FORMAT_ALL
Deprecated.
-
-
Method Detail
-
toOptionSet
static BitFieldSet<LineAppendable.Options> toOptionSet(int options)
-
toOptionSet
static BitFieldSet<LineAppendable.Options> toOptionSet(LineAppendable.Options... options)
-
getOptions
default int getOptions()
Get current options as bit mask flags- Returns:
- option flags
-
getEmptyAppendable
@NotNull @NotNull LineAppendable getEmptyAppendable()
-
copyAppendable
@NotNull default @NotNull LineAppendable copyAppendable(int startLine, int endLine, boolean withPrefixes)
Make a copy of this appendable with the given line range- Parameters:
startLine
- start lineendLine
- end linewithPrefixes
- true if to include prefixes- Returns:
- copy of appendable with requested content
-
copyAppendable
@NotNull default @NotNull LineAppendable copyAppendable(int startLine, int endLine)
-
copyAppendable
@NotNull default @NotNull LineAppendable copyAppendable(int startLine)
-
copyAppendable
@NotNull default @NotNull LineAppendable copyAppendable()
-
copyAppendable
@NotNull default @NotNull LineAppendable copyAppendable(boolean withPrefixes)
-
getOptionSet
@NotNull @NotNull BitFieldSet<LineAppendable.Options> getOptionSet()
Get current options as set which can be used to modify options- Returns:
- mutable option set
-
pushOptions
@NotNull @NotNull LineAppendable pushOptions()
-
popOptions
@NotNull @NotNull LineAppendable popOptions()
-
noTrimLeading
@NotNull default @NotNull LineAppendable noTrimLeading()
-
trimLeading
@NotNull default @NotNull LineAppendable trimLeading()
-
preserveSpaces
@NotNull default @NotNull LineAppendable preserveSpaces()
-
noPreserveSpaces
@NotNull default @NotNull LineAppendable noPreserveSpaces()
-
removeOptions
@NotNull default @NotNull LineAppendable removeOptions(int flags)
-
addOptions
@NotNull default @NotNull LineAppendable addOptions(int flags)
-
changeOptions
@NotNull @NotNull LineAppendable changeOptions(int addFlags, int removeFlags)
-
setOptions
@NotNull default @NotNull LineAppendable setOptions(int flags)
Set options on processing text- Parameters:
flags
- option flags- Returns:
- this
-
setOptions
@NotNull default @NotNull LineAppendable setOptions(LineAppendable.Options... options)
-
setOptions
@NotNull default @NotNull LineAppendable setOptions(BitFieldSet<LineAppendable.Options> options)
Set options on processing text- Parameters:
options
- option set- Returns:
- this
-
getBuilder
@NotNull @NotNull ISequenceBuilder<?,?> getBuilder()
Get builder used for accumulation- Returns:
- builder used for accumulation
-
getTrailingBlankLines
int getTrailingBlankLines(int endLine)
Get trailing blank line count ending on given line- Parameters:
endLine
- end line- Returns:
- number of trailing blank lines
-
getTrailingBlankLines
default int getTrailingBlankLines()
-
endsWithEOL
boolean endsWithEOL()
- Returns:
- true if not empty and have no unterminated lines
-
append
@NotNull @NotNull LineAppendable append(@NotNull @NotNull java.lang.CharSequence csq)
- Specified by:
append
in interfacejava.lang.Appendable
-
append
@NotNull @NotNull LineAppendable append(@NotNull @NotNull java.lang.CharSequence csq, int start, int end)
- Specified by:
append
in interfacejava.lang.Appendable
-
append
@NotNull @NotNull LineAppendable append(char c)
- Specified by:
append
in interfacejava.lang.Appendable
-
append
@NotNull @NotNull LineAppendable append(char c, int count)
-
appendAll
@NotNull default @NotNull LineAppendable appendAll(@NotNull @NotNull java.lang.Iterable<java.lang.CharSequence> sequences)
-
append
@NotNull @NotNull LineAppendable append(@NotNull @NotNull LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes)
Append lines from another line formatting appendable.NOTE: does not apply formatting options. Instead, appends already formatted lines as is
If there is an accumulating line, it will be terminated by an EOL before appending lines
- Parameters:
lineAppendable
- lines to append, any unterminated lines will be terminated by aline()
invocation.startLine
- start line to appendendLine
- end line to append, endLine is excluded.withPrefixes
- true if to include prefixes from the lineAppendable.- Returns:
- this
-
append
@NotNull default @NotNull LineAppendable append(@NotNull @NotNull LineAppendable lineAppendable)
Append lines from another line formatting appendable.NOTE: does not apply formatting options other than prefix. Line text is used as is.
If there is an unterminated line its contents will be used as leading text of the first appended line
- Parameters:
lineAppendable
- lines to append- Returns:
- this
-
append
@NotNull default @NotNull LineAppendable append(@NotNull @NotNull LineAppendable lineAppendable, boolean withPrefixes)
Append lines from another line formatting appendable.NOTE: does not apply formatting options other than prefix. Line text is used as is.
If there is an unterminated line its contents will be used as leading text of the first appended line
- Parameters:
lineAppendable
- lines to appendwithPrefixes
- true if to include prefixes from the lineAppendable.- Returns:
- this
-
line
@NotNull @NotNull LineAppendable line()
Add a new line if there was any unterminated text appended or if this is a preformatted region- Returns:
- this
-
lineWithTrailingSpaces
@NotNull @NotNull LineAppendable lineWithTrailingSpaces(int count)
Add a new line, keep trailing spaces if there was any unterminated text appendedNOTE: only applies in preformatted region or if the line is not empty
- Parameters:
count
- number of trailing spaces to add- Returns:
- this
-
lineIf
@NotNull @NotNull LineAppendable lineIf(boolean predicate)
Add a new line, if predicate is true and line() would add an EOL.- Parameters:
predicate
- callline()
if value is true.- Returns:
- this
-
blankLine
@NotNull @NotNull LineAppendable blankLine()
Add a blank line, if there is not one already appended.- Returns:
- this
-
blankLineIf
@NotNull @NotNull LineAppendable blankLineIf(boolean predicate)
Add a blank line, if predicate is true and there isn't already blank lines appended.- Parameters:
predicate
- when true append blank line- Returns:
- this
-
blankLine
@NotNull @NotNull LineAppendable blankLine(int count)
Add a blank lines, if there isn't already given number of blank lines appended. Will append only enough blank lines to increase it to given level. If more are already in the wings then nothing is done.- Parameters:
count
- number of blank lines to append- Returns:
- this
-
isPreFormatted
boolean isPreFormatted()
- Returns:
- true if in pre-formatted region
-
openPreFormatted
@NotNull @NotNull LineAppendable openPreFormatted(boolean addPrefixToFirstLine)
Open preformatted section and suspend content modification- Parameters:
addPrefixToFirstLine
- if true will add the current prefix to first line- Returns:
- this
-
closePreFormatted
@NotNull @NotNull LineAppendable closePreFormatted()
Close preformatted section and suspend content modification- Returns:
- this
-
indent
@NotNull @NotNull LineAppendable indent()
Increase the indent level, will terminate the current line if there is unterminated textNOTE: this is equivalent to pushPrefix(), addPrefix(getIndentPrefix()) but adds a flag to validate that
unIndent()
is called only on prefixes added by this method- Returns:
- this
-
unIndent
@NotNull @NotNull LineAppendable unIndent()
Decrease the indent level, min level is 0, will terminate the current line if there is unterminated textNOTE: this is equivalent to popPrefix() but with validation that it is called only on prefixes added by
indent()
- Returns:
- this
-
unIndentNoEol
@NotNull @NotNull LineAppendable unIndentNoEol()
Decrease the indent level, if there is unterminated text then unindented prefix is to be applied after the next EOL.Will NOT terminate the current line if there is unterminated text
NOTE: should be used with
addIndentOnFirstEOL(Runnable)
if callback is invoked- Returns:
- this
-
getIndentPrefix
@NotNull @NotNull BasedSequence getIndentPrefix()
Get prefix appended after a new line character for every indent level- Returns:
- char sequence of the current indent prefix used for each indent level
-
setIndentPrefix
@NotNull @NotNull LineAppendable setIndentPrefix(@Nullable @Nullable java.lang.CharSequence prefix)
Set prefix to append after a new line character for every indent level- Parameters:
prefix
- prefix characters for new lines appended after this is set- Returns:
- this
-
getPrefix
@NotNull @NotNull BasedSequence getPrefix()
Get prefix being applied to all lines, even in pre-formatted sections This is the prefix that will be set after EOL- Returns:
- char sequence of the current prefix
-
getBeforeEolPrefix
@NotNull @NotNull BasedSequence getBeforeEolPrefix()
Get prefix used before EOL- Returns:
- char sequence of the current prefix
-
addPrefix
@NotNull @NotNull LineAppendable addPrefix(@NotNull @NotNull java.lang.CharSequence prefix, boolean afterEol)
Add to prefix appended after a new line character for every line and after a new line in pre-formatted sectionsThis appends the sequence to current prefix
- Parameters:
prefix
- prefix characters to add to current prefix for new lines appended after this is setafterEol
- if true prefix will take effect after EOL- Returns:
- this
-
setPrefix
@NotNull @NotNull LineAppendable setPrefix(@Nullable @Nullable java.lang.CharSequence prefix, boolean afterEol)
Set prefix appended after a new line character for every line and after a new line in pre-formatted sectionsThis appends the sequence to current prefix
- Parameters:
prefix
- prefix characters to add to current prefix for new lines appended after this is setafterEol
- if true prefix will take effect after EOL- Returns:
- this
-
addPrefix
@NotNull default @NotNull LineAppendable addPrefix(@NotNull @NotNull java.lang.CharSequence prefix)
Add to prefix appended after a new line character for every line and after a new line in pre-formatted sectionsThis appends the sequence to current prefix
- Parameters:
prefix
- prefix characters to add to current prefix for new lines appended after this is set- Returns:
- this
-
setPrefix
@NotNull default @NotNull LineAppendable setPrefix(@NotNull @NotNull java.lang.CharSequence prefix)
Set prefix appended after a new line character for every line and after a new line in pre-formatted sectionsThis appends the sequence to current prefix
- Parameters:
prefix
- prefix characters to add to current prefix for new lines appended after this is set- Returns:
- this
-
pushPrefix
@NotNull @NotNull LineAppendable pushPrefix()
Save the current prefix on the stack- Returns:
- this
-
popPrefix
@NotNull @NotNull LineAppendable popPrefix(boolean afterEol)
Pop a prefix from the stack and set the current prefix- Parameters:
afterEol
- if true prefix will take effect after EOL- Returns:
- this
-
popPrefix
@NotNull default @NotNull LineAppendable popPrefix()
Pop a prefix from the stack and set the current prefix- Returns:
- this
-
getAfterEolPrefixDelta
int getAfterEolPrefixDelta()
Get pending prefix after EOL- Returns:
- change in prefix length after next eol
-
column
int column()
Get column offset after last append- Returns:
- column offset after last append
-
offset
int offset()
Get text offset of all output lines, excluding any text for the last line being accumulated- Returns:
- offset of text as would be returned for all
-
offsetWithPending
int offsetWithPending()
Get offset after last append as if EOL was added but without the EOL itself- Returns:
- offset as would be returned by
offset()
after line() call less 1 for EOL
-
isPendingSpace
boolean isPendingSpace()
Test if trailing text ends in space or tab- Returns:
- true if ending in space or tab
-
getPendingSpace
int getPendingSpace()
Get number of spaces at end of pending text- Returns:
- number of eols at end of text
-
getPendingEOL
int getPendingEOL()
Get number of EOLs at end of appendable, this is actually number of tail blank lines- Returns:
- number of eols at end of text
-
lineOnFirstText
@NotNull @NotNull LineAppendable lineOnFirstText(boolean value)
-
setLineOnFirstText
@NotNull default @NotNull LineAppendable setLineOnFirstText()
-
clearLineOnFirstText
@NotNull default @NotNull LineAppendable clearLineOnFirstText()
-
addIndentOnFirstEOL
@NotNull @NotNull LineAppendable addIndentOnFirstEOL(@NotNull @NotNull java.lang.Runnable listener)
Add an indent on first EOL appended and run runnable- Parameters:
listener
- runnable to run if adding indent on first EOL- Returns:
- this
-
removeIndentOnFirstEOL
@NotNull @NotNull LineAppendable removeIndentOnFirstEOL(@NotNull @NotNull java.lang.Runnable listener)
Remove runnable, has no effect if EOL was already appended and runnable was run- Parameters:
listener
- runnable added with addIndentOnFirstEOL- Returns:
- this
-
getLineCount
int getLineCount()
Get the number of lines appended, not including any unterminated ones- Returns:
- number of full lines appended
-
isEmpty
default boolean isEmpty()
Kotlin compatibility- Returns:
- true if have no terminated lines
-
isNotEmpty
default boolean isNotEmpty()
Kotlin compatibility- Returns:
- true if have terminated lines
-
getLineCountWithPending
int getLineCountWithPending()
Get the number of lines appended, including any unterminated onesNOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly
- Returns:
- number of lines appended
-
getLineInfo
@NotNull @NotNull LineInfo getLineInfo(int lineIndex)
Get Line information at given line indexNOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly
- Parameters:
lineIndex
- line index for the info to get- Returns:
- line info
-
get
@NotNull default @NotNull LineInfo get(int lineIndex)
Kotlin index operator- Parameters:
lineIndex
- line index- Returns:
- line info
-
getLine
@NotNull @NotNull BasedSequence getLine(int lineIndex)
Get Line at given line indexNOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly
- Parameters:
lineIndex
- line index- Returns:
- line char sequence
-
iterator
@NotNull @NotNull java.util.Iterator<LineInfo> iterator()
Full line iterator NOTE: will not issue line() to terminate any unterminated lines before iteration and will not include unterminated lines in iteration- Specified by:
iterator
in interfacejava.lang.Iterable<LineInfo>
- Returns:
- iterator over lines
-
getLines
@NotNull @NotNull java.lang.Iterable<BasedSequence> getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes)
Full line iterator over some linesNOTE: will issue line() to terminate any unterminated lines before iteration
- Parameters:
maxTrailingBlankLines
- maximum trailing blank lines, -1 if trailing EOL should be removedstartLine
- start line indexendLine
- end line index, exclusivewithPrefixes
- true if prefixes should be included, else only non-prefix line text- Returns:
- iterator over lines
-
getLines
@NotNull default @NotNull java.lang.Iterable<BasedSequence> getLines(int maxTrailingBlankLines)
-
getLines
@NotNull default @NotNull java.lang.Iterable<BasedSequence> getLines()
-
getLines
@NotNull default @NotNull java.lang.Iterable<BasedSequence> getLines(int maxTrailingBlankLines, boolean withPrefixes)
-
getLines
@NotNull default @NotNull java.lang.Iterable<BasedSequence> getLines(boolean withPrefixes)
-
getLinesInfo
@NotNull @NotNull java.lang.Iterable<LineInfo> getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine)
Full line iterator with line infoNOTE: will issue line() to terminate any unterminated lines before iteration
- Parameters:
maxTrailingBlankLines
- maximum trailing blank lines, -1 if trailing EOL should be removedstartLine
- start line indexendLine
- end line index, exclusive- Returns:
- iterator over lines
-
getLinesInfo
@NotNull default @NotNull java.lang.Iterable<LineInfo> getLinesInfo(int maxTrailingBlankLines)
-
getLinesInfo
@NotNull default @NotNull java.lang.Iterable<LineInfo> getLinesInfo()
-
getLineContent
@NotNull default @NotNull BasedSequence getLineContent(int lineIndex)
Get Line content of given line- Parameters:
lineIndex
- line index- Returns:
- char sequence for the line
-
getLinePrefix
@NotNull default @NotNull BasedSequence getLinePrefix(int lineIndex)
Get prefix of given line- Parameters:
lineIndex
- line index- Returns:
- line prefix char sequence
-
setPrefixLength
void setPrefixLength(int lineIndex, int prefixLength)
Change prefix length for a given line without changing the line content- Parameters:
lineIndex
- index of the lineprefixLength
- new prefix length
-
setLine
void setLine(int lineIndex, @NotNull @NotNull java.lang.CharSequence prefix, @NotNull @NotNull java.lang.CharSequence text)
Set content and prefix for a line- Parameters:
lineIndex
- index of the lineprefix
- prefix of the linetext
- content text of the line
-
insertLine
void insertLine(int lineIndex, @NotNull @NotNull java.lang.CharSequence prefix, @NotNull @NotNull java.lang.CharSequence text)
Insert a line at the index with given content and prefix for a line- Parameters:
lineIndex
- index of the lineprefix
- prefix of the linetext
- content text of the line
-
removeLines
@NotNull @NotNull LineAppendable removeLines(int startLine, int endLine)
-
toString
@NotNull @NotNull java.lang.String toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes)
get the resulting text for all lines- Parameters:
maxBlankLines
- maximum blank lines to allow in the textmaxTrailingBlankLines
- maximum trailing blank lineswithPrefixes
- true if to include prefixes- Returns:
- resulting text
-
toString
@NotNull default @NotNull java.lang.String toString(int maxBlankLines, int maxTrailingBlankLines)
-
toString
@NotNull default @NotNull java.lang.String toString(int maxBlankLines, boolean withPrefixes)
-
toString
@NotNull default @NotNull java.lang.String toString(boolean withPrefixes)
-
toString
@NotNull default @NotNull java.lang.String toString(int maxBlankLines)
get the resulting text for all lines- Parameters:
maxBlankLines
- maximum blank lines to allow, if -1 then no trailing EOL will be generated- Returns:
- resulting text
-
toSequence
@NotNull @NotNull java.lang.CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes)
get the resulting text for all lines- Parameters:
maxBlankLines
- maximum blank lines to allow in the textmaxTrailingBlankLines
- maximum trailing blank lineswithPrefixes
- true if to include prefixes- Returns:
- resulting text
-
toSequence
@NotNull default @NotNull java.lang.CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines)
-
toSequence
@NotNull default @NotNull java.lang.CharSequence toSequence(int maxBlankLines, boolean withPrefixes)
-
toSequence
@NotNull default @NotNull java.lang.CharSequence toSequence(boolean withPrefixes)
-
toSequence
@NotNull default @NotNull java.lang.CharSequence toSequence()
-
appendTo
@Deprecated default <T extends java.lang.Appendable> T appendTo(@NotNull T out, int maxTrailingBlankLines) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
appendTo
<T extends java.lang.Appendable> T appendTo(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws java.io.IOException
append lines to appendable with given maximum trailing blank lines and given prefix to add to all linesNOTE:
- Type Parameters:
T
- type of out- Parameters:
out
- appendable to output the resulting lineswithPrefixes
- true if to include prefixesmaxBlankLines
- maximum blank lines to allow in the body,maxTrailingBlankLines
- maximum trailing blank lines at the end, if <maxBlankLines then maxBlankLines will be used, if -1 then no trailing EOL will be addedstartLine
- line from which to start outputendLine
- line at which to stop output- Returns:
- out
- Throws:
java.io.IOException
- if thrown by appendable
-
appendTo
default <T extends java.lang.Appendable> T appendTo(@NotNull T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws java.io.IOException
- Throws:
java.io.IOException
-
appendTo
default <T extends java.lang.Appendable> T appendTo(@NotNull T out, int maxBlankLines, int maxTrailingBlankLines) throws java.io.IOException
- Throws:
java.io.IOException
-
appendTo
default <T extends java.lang.Appendable> T appendTo(@NotNull T out) throws java.io.IOException
append lines to appendable with 0 blank lines, if these are desired at the end of the output useappendTo(Appendable, int, int)
.- Type Parameters:
T
- type of out- Parameters:
out
- appendable to output the resulting lines- Returns:
- out
- Throws:
java.io.IOException
- thrown byout
.
-
appendToSilently
default <T extends java.lang.Appendable> T appendToSilently(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)
-
appendToSilently
default <T extends java.lang.Appendable> T appendToSilently(@NotNull T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)
-
appendToSilently
default <T extends java.lang.Appendable> T appendToSilently(@NotNull T out, int maxBlankLines, int maxTrailingBlankLines)
-
appendToSilently
default <T extends java.lang.Appendable> T appendToSilently(@NotNull T out)
-
removeExtraBlankLines
LineAppendable removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)
Normalize the appendable by removing extra blank lines in the body or at the end of given line range- Parameters:
maxBlankLines
- maximum blank lines to allow in the bodymaxTrailingBlankLines
- maximum trailing blank lines ending on endLine, if <maxBlankLines then maxBlankLines will be usedstartLine
- line from which to start outputendLine
- line at which to stop output- Returns:
- this
-
removeExtraBlankLines
default LineAppendable removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines)
-
combinedPrefix
static java.lang.CharSequence combinedPrefix(@Nullable @Nullable java.lang.CharSequence prefix, @Nullable @Nullable java.lang.CharSequence suffix)
-
-