public class LineAppendableImpl extends Object implements LineAppendable
LineAppendable.OptionsALLOW_LEADING_EOL, ALLOW_LEADING_WHITESPACE, COLLAPSE_WHITESPACE, CONVERT_TABS, F_COLLAPSE_WHITESPACE, F_CONVERT_TABS, F_FORMAT_ALL, F_PASS_THROUGH, F_PREFIX_PRE_FORMATTED, F_TRIM_LEADING_EOL, F_TRIM_LEADING_WHITESPACE, F_TRIM_TRAILING_WHITESPACE, F_WHITESPACE_REMOVAL, FORMAT_ALL, O_COLLAPSE_WHITESPACE, O_CONVERT_TABS, O_FORMAT_ALL, O_PASS_THROUGH, O_PREFIX_PRE_FORMATTED, O_TRIM_LEADING_EOL, O_TRIM_LEADING_WHITESPACE, O_TRIM_TRAILING_WHITESPACE, PASS_THROUGH, PREFIX_PRE_FORMATTED, TRIM_LEADING_WHITESPACE, TRIM_TRAILING_WHITESPACE| Constructor and Description |
|---|
LineAppendableImpl(@Nullable Appendable appendable,
com.vladsch.flexmark.util.misc.BitFieldSet<LineAppendable.Options> formatOptions) |
LineAppendableImpl(@Nullable Appendable builder,
int formatOptions) |
LineAppendableImpl(int formatOptions) |
| Modifier and Type | Method and Description |
|---|---|
@NotNull LineAppendable |
addIndentOnFirstEOL(@NotNull Runnable listener)
Add an indent on first EOL appended and run runnable
|
@NotNull LineAppendable |
addPrefix(@NotNull 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) |
@NotNull LineAppendable |
append(@NotNull CharSequence csq) |
@NotNull LineAppendable |
append(@NotNull CharSequence csq,
int start,
int end) |
@NotNull LineAppendable |
append(@NotNull LineAppendable lineAppendable,
int startLine,
int endLine,
boolean withPrefixes)
Append lines from another line formatting appendable.
|
<T extends Appendable> |
appendTo(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 lines
|
<T extends Appendable> |
appendToNoLine(T out,
boolean withPrefixes,
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) |
@NotNull LineAppendable |
closePreFormatted()
Close preformatted section and suspend content modification
|
int |
column()
Get column offset after last append
|
boolean |
endsWithEOL() |
int |
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 index
|
int |
getLineCount()
Get the number of lines appended, not including any unterminated ones
|
int |
getLineCountWithPending()
Get the number of lines appended, including any unterminated ones
|
@NotNull LineInfo |
getLineInfo(int lineIndex)
Get Line information at given line index
|
@NotNull Iterable<BasedSequence> |
getLines(int maxTrailingBlankLines,
int startLine,
int endLine,
boolean withPrefixes)
Full line iterator over some lines
|
@NotNull Iterable<LineInfo> |
getLinesInfo(int maxTrailingBlankLines,
int startLine,
int endLine)
Full line iterator with line info
|
@NotNull com.vladsch.flexmark.util.misc.BitFieldSet<LineAppendable.Options> |
getOptionSet()
Get current options as set which can be used to modify options
|
int |
getPendingEOL()
Get number of EOLs at end of appendable, this is actually number of tail blank lines
|
int |
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 EOL
|
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 text
|
void |
insertLine(int lineIndex,
@NotNull CharSequence prefix,
@NotNull CharSequence content)
Insert a line at the index with given content and prefix for a line
|
boolean |
isPendingSpace()
Test if trailing text ends in space or tab
|
boolean |
isPreFormatted() |
@NotNull 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 appended
|
int |
offset()
Get text offset of all output lines, excluding any text for the last line being accumulated
|
int |
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() |
@NotNull LineAppendable |
popPrefix(boolean afterEol)
Pop a prefix from the stack and set the current prefix
|
@NotNull LineAppendable |
pushOptions() |
@NotNull LineAppendable |
pushPrefix()
Save the current prefix on the stack
|
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 Runnable listener)
Remove runnable, has no effect if EOL was already appended and runnable was run
|
@NotNull LineAppendable |
removeLines(int startLine,
int endLine) |
@NotNull LineAppendable |
repeat(@NotNull CharSequence csq,
int count) |
@NotNull LineAppendable |
repeat(@NotNull CharSequence csq,
int start,
int end,
int count) |
@NotNull LineAppendable |
setIndentPrefix(@Nullable CharSequence prefix)
Set prefix to append after a new line character for every indent level
|
void |
setLine(int lineIndex,
@NotNull CharSequence prefix,
@NotNull CharSequence content)
Set content and prefix for a line
|
@NotNull LineAppendable |
setOptions(int flags)
Set options on processing text
|
@NotNull LineAppendable |
setPrefix(@Nullable CharSequence prefix,
boolean afterEol)
Set prefix appended after a new line character for every line
and after a new line in pre-formatted sections
|
void |
setPrefixLength(int lineIndex,
int prefixLength)
Change prefix length for a given line without changing the line content
|
@NotNull CharSequence |
toSequence(int maxBlankLines,
int maxTrailingBlankLines,
boolean withPrefixes)
get the resulting text for all lines
|
String |
toString() |
@NotNull String |
toString(int maxBlankLines,
int maxTrailingBlankLines,
boolean withPrefixes)
get the resulting text for all lines
|
@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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddOptions, addPrefix, append, append, appendAll, appendTo, appendTo, appendTo, appendTo, appendToSilently, appendToSilently, appendToSilently, appendToSilently, clearLineOnFirstText, combinedPrefix, copyAppendable, copyAppendable, copyAppendable, copyAppendable, copyAppendable, get, getLineContent, getLinePrefix, getLines, getLines, getLines, getLines, getLinesInfo, getLinesInfo, getOptions, getTrailingBlankLines, isEmpty, isNotEmpty, noPreserveSpaces, noTrimLeading, popPrefix, preserveSpaces, removeExtraBlankLines, removeOptions, setLineOnFirstText, setOptions, setOptions, setPrefix, toOptionSet, toOptionSet, toSequence, toSequence, toSequence, toSequence, toString, toString, toString, toString, trimLeadingforEach, spliteratorpublic LineAppendableImpl(int formatOptions)
public LineAppendableImpl(@Nullable
@Nullable Appendable builder,
int formatOptions)
public LineAppendableImpl(@Nullable
@Nullable Appendable appendable,
com.vladsch.flexmark.util.misc.BitFieldSet<LineAppendable.Options> formatOptions)
@NotNull public @NotNull LineAppendable getEmptyAppendable()
getEmptyAppendable in interface LineAppendable@NotNull public @NotNull com.vladsch.flexmark.util.misc.BitFieldSet<LineAppendable.Options> getOptionSet()
LineAppendablegetOptionSet in interface LineAppendable@NotNull public @NotNull LineAppendable setOptions(int flags)
LineAppendablesetOptions in interface LineAppendableflags - option flags@NotNull public @NotNull LineAppendable pushOptions()
pushOptions in interface LineAppendable@NotNull public @NotNull LineAppendable popOptions()
popOptions in interface LineAppendable@NotNull public @NotNull LineAppendable changeOptions(int addFlags, int removeFlags)
changeOptions in interface LineAppendable@NotNull public @NotNull BasedSequence getIndentPrefix()
LineAppendablegetIndentPrefix in interface LineAppendable@NotNull public @NotNull LineAppendable setIndentPrefix(@Nullable @Nullable CharSequence prefix)
LineAppendablesetIndentPrefix in interface LineAppendableprefix - prefix characters for new lines appended after this is set@NotNull public @NotNull BasedSequence getPrefix()
LineAppendablegetPrefix in interface LineAppendable@NotNull public @NotNull BasedSequence getBeforeEolPrefix()
LineAppendablegetBeforeEolPrefix in interface LineAppendable@NotNull public @NotNull LineAppendable addPrefix(@NotNull @NotNull CharSequence prefix, boolean afterEol)
LineAppendableThis appends the sequence to current prefix
addPrefix in interface LineAppendableprefix - prefix characters to add to current prefix for new lines appended after this is setafterEol - if true prefix will take effect after EOLpublic int getAfterEolPrefixDelta()
LineAppendablegetAfterEolPrefixDelta in interface LineAppendable@NotNull public @NotNull LineAppendable setPrefix(@Nullable @Nullable CharSequence prefix, boolean afterEol)
LineAppendableThis appends the sequence to current prefix
setPrefix in interface LineAppendableprefix - prefix characters to add to current prefix for new lines appended after this is setafterEol - if true prefix will take effect after EOL@NotNull public @NotNull LineAppendable indent()
LineAppendable
NOTE: this is equivalent to pushPrefix(), addPrefix(getIndentPrefix()) but adds a flag to
validate that LineAppendable.unIndent() is called only on prefixes added by this method
indent in interface LineAppendable@NotNull public @NotNull LineAppendable unIndent()
LineAppendable
NOTE: this is equivalent to popPrefix() but with validation
that it is called only on prefixes added by LineAppendable.indent()
unIndent in interface LineAppendable@NotNull public @NotNull LineAppendable unIndentNoEol()
LineAppendableWill NOT terminate the current line if there is unterminated text
NOTE: should be used with LineAppendable.addIndentOnFirstEOL(Runnable) if callback is invoked
unIndentNoEol in interface LineAppendable@NotNull public @NotNull LineAppendable pushPrefix()
LineAppendablepushPrefix in interface LineAppendable@NotNull public @NotNull LineAppendable popPrefix(boolean afterEol)
LineAppendablepopPrefix in interface LineAppendableafterEol - if true prefix will take effect after EOLpublic int getTrailingBlankLines(int endLine)
LineAppendablegetTrailingBlankLines in interface LineAppendableendLine - end linepublic boolean endsWithEOL()
endsWithEOL in interface LineAppendable@NotNull public @NotNull LineAppendable append(@NotNull @NotNull CharSequence csq)
append in interface LineAppendableappend in interface Appendable@NotNull public @NotNull ISequenceBuilder<?,?> getBuilder()
LineAppendablegetBuilder in interface LineAppendable@NotNull public @NotNull LineAppendable append(@NotNull @NotNull CharSequence csq, int start, int end)
append in interface LineAppendableappend in interface Appendable@NotNull public @NotNull LineAppendable append(char c)
append in interface LineAppendableappend in interface Appendable@NotNull public @NotNull LineAppendable append(char c, int count)
append in interface LineAppendable@NotNull public @NotNull LineAppendable repeat(@NotNull @NotNull CharSequence csq, int count)
@NotNull public @NotNull LineAppendable repeat(@NotNull @NotNull CharSequence csq, int start, int end, int count)
@NotNull public @NotNull LineAppendable line()
LineAppendableline in interface LineAppendable@NotNull public @NotNull LineAppendable lineWithTrailingSpaces(int count)
LineAppendableNOTE: only applies in preformatted region or if the line is not empty
lineWithTrailingSpaces in interface LineAppendablecount - number of trailing spaces to add@NotNull public @NotNull LineAppendable lineIf(boolean predicate)
LineAppendablelineIf in interface LineAppendablepredicate - call LineAppendable.line() if value is true.@NotNull public @NotNull LineAppendable blankLine()
LineAppendableblankLine in interface LineAppendable@NotNull public @NotNull LineAppendable blankLineIf(boolean predicate)
LineAppendableblankLineIf in interface LineAppendablepredicate - when true append blank line@NotNull public @NotNull LineAppendable blankLine(int count)
LineAppendableblankLine in interface LineAppendablecount - number of blank lines to append@NotNull public @NotNull LineAppendable lineOnFirstText(boolean value)
lineOnFirstText in interface LineAppendable@NotNull public @NotNull LineAppendable removeIndentOnFirstEOL(@NotNull @NotNull Runnable listener)
LineAppendableremoveIndentOnFirstEOL in interface LineAppendablelistener - runnable added with addIndentOnFirstEOL@NotNull public @NotNull LineAppendable addIndentOnFirstEOL(@NotNull @NotNull Runnable listener)
LineAppendableaddIndentOnFirstEOL in interface LineAppendablelistener - runnable to run if adding indent on first EOLpublic int getLineCount()
LineAppendablegetLineCount in interface LineAppendablepublic int getLineCountWithPending()
LineAppendableNOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly
getLineCountWithPending in interface LineAppendablepublic int column()
LineAppendablecolumn in interface LineAppendable@NotNull public @NotNull LineInfo getLineInfo(int lineIndex)
LineAppendableNOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly
getLineInfo in interface LineAppendablelineIndex - line index for the info to get@NotNull public @NotNull BasedSequence getLine(int lineIndex)
LineAppendableNOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly
getLine in interface LineAppendablelineIndex - line indexpublic int offset()
LineAppendableoffset in interface LineAppendablepublic int offsetWithPending()
LineAppendableoffsetWithPending in interface LineAppendableLineAppendable.offset() after line() call less 1 for EOLpublic boolean isPendingSpace()
LineAppendableisPendingSpace in interface LineAppendablepublic int getPendingSpace()
LineAppendablegetPendingSpace in interface LineAppendablepublic int getPendingEOL()
LineAppendablegetPendingEOL in interface LineAppendablepublic boolean isPreFormatted()
isPreFormatted in interface LineAppendable@NotNull public @NotNull LineAppendable openPreFormatted(boolean addPrefixToFirstLine)
LineAppendableopenPreFormatted in interface LineAppendableaddPrefixToFirstLine - if true will add the current prefix to first line@NotNull public @NotNull LineAppendable closePreFormatted()
LineAppendableclosePreFormatted in interface LineAppendable@NotNull public @NotNull String toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes)
LineAppendabletoString in interface LineAppendablemaxBlankLines - maximum blank lines to allow in the textmaxTrailingBlankLines - maximum trailing blank lineswithPrefixes - true if to include prefixes@NotNull public @NotNull CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes)
LineAppendabletoSequence in interface LineAppendablemaxBlankLines - maximum blank lines to allow in the textmaxTrailingBlankLines - maximum trailing blank lineswithPrefixes - true if to include prefixespublic <T extends Appendable> T appendTo(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException
LineAppendableNOTE:
appendTo in interface LineAppendableT - type of outout - 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 outputIOException - if thrown by appendablepublic <T extends Appendable> T appendToNoLine(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException
IOException@NotNull public @NotNull LineAppendable append(@NotNull @NotNull LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes)
LineAppendableNOTE: 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
append in interface LineAppendablelineAppendable - lines to append, any unterminated lines will be terminated by a LineAppendable.line() invocation.startLine - start line to appendendLine - end line to append, endLine is excluded.withPrefixes - true if to include prefixes from the lineAppendable.@NotNull public @NotNull LineAppendable removeLines(int startLine, int endLine)
removeLines in interface LineAppendablepublic LineAppendable removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine)
LineAppendableremoveExtraBlankLines in interface LineAppendablemaxBlankLines - 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 outputpublic void setPrefixLength(int lineIndex,
int prefixLength)
LineAppendablesetPrefixLength in interface LineAppendablelineIndex - index of the lineprefixLength - new prefix lengthpublic void setLine(int lineIndex,
@NotNull
@NotNull CharSequence prefix,
@NotNull
@NotNull CharSequence content)
LineAppendablesetLine in interface LineAppendablelineIndex - index of the lineprefix - prefix of the linecontent - content text of the linepublic void insertLine(int lineIndex,
@NotNull
@NotNull CharSequence prefix,
@NotNull
@NotNull CharSequence content)
LineAppendableinsertLine in interface LineAppendablelineIndex - index of the lineprefix - prefix of the linecontent - content text of the line@NotNull public @NotNull Iterator<LineInfo> iterator()
LineAppendableiterator in interface LineAppendableiterator in interface Iterable<LineInfo>@NotNull public @NotNull Iterable<BasedSequence> getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes)
LineAppendableNOTE: will issue line() to terminate any unterminated lines before iteration
getLines in interface LineAppendablemaxTrailingBlankLines - 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@NotNull public @NotNull Iterable<LineInfo> getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine)
LineAppendableNOTE: will issue line() to terminate any unterminated lines before iteration
getLinesInfo in interface LineAppendablemaxTrailingBlankLines - maximum trailing blank lines, -1 if trailing EOL should be removedstartLine - start line indexendLine - end line index, exclusiveCopyright © 2020. All rights reserved.