Class LineAppendableImpl
- All Implemented Interfaces:
LineAppendable, Appendable, Iterable<LineInfo>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static classNested classes/interfaces inherited from interface LineAppendable
LineAppendable.Options -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate ISequenceBuilder<?, ?> private static final charprivate intprivate CharSequenceprivate boolean(package private) intprivate final BitFieldSet<LineAppendable.Options> private final booleanprivate CharSequenceprivate CharSequenceprivate final Stack<CharSequence> private intprivate intprivate intprivate intprivate intFields inherited from interface LineAppendable
ALLOW_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 Summary
ConstructorsConstructorDescriptionLineAppendableImpl(int formatOptions) LineAppendableImpl(@Nullable Appendable builder, int formatOptions) LineAppendableImpl(@Nullable Appendable appendable, BitFieldSet<LineAppendable.Options> formatOptions) -
Method Summary
Modifier and TypeMethodDescription@NotNull LineAppendableaddIndentOnFirstEOL(@NotNull Runnable listener) Add an indent on first EOL appended and run runnableprivate voidaddLineRange(int start, int end, CharSequence prefix) @NotNull LineAppendableaddPrefix(@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 sectionsprivate booleanany(int flags) @NotNull LineAppendableappend(char c) @NotNull LineAppendableappend(char c, int count) @NotNull LineAppendableappend(@NotNull LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes) Append lines from another line formatting appendable.@NotNull LineAppendableappend(@NotNull CharSequence csq) @NotNull LineAppendableappend(@NotNull CharSequence csq, int start, int end) private voidappendEol(int count) private voidappendEol(@NotNull CharSequence eol) private voidappendImpl(CharSequence s, int index) private voidappendImpl(CharSequence csq, int start, int end) <T extends 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 lines<T extends Appendable>
TappendToNoLine(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) @NotNull LineAppendableAdd a blank line, if there is not one already appended.@NotNull LineAppendableblankLine(int count) Add a blank lines, if there isn't already given number of blank lines appended.@NotNull LineAppendableblankLineIf(boolean predicate) Add a blank line, if predicate is true and there isn't already blank lines appended.@NotNull LineAppendablechangeOptions(int addFlags, int removeFlags) @NotNull LineAppendableClose preformatted section and suspend content modificationintcolumn()Get column offset after last appendprivate LineInfocreateLineInfo(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence content) private voidbooleanintGet pending prefix after EOL@NotNull BasedSequenceGet prefix used before EOL@NotNull ISequenceBuilder<?, ?> Get builder used for accumulation@NotNull LineAppendable@NotNull BasedSequenceGet prefix appended after a new line character for every indent level(package private) @NotNull LineAppendableImpl.IndexedLineInfoProxygetIndexedLineInfoProxy(int maxTrailingBlankLines, int startLine, int endLine) (package private) @NotNull LineAppendableImpl.IndexedLineProxygetIndexedLineProxy(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) (package private) @NotNull LineInfo@NotNull BasedSequencegetLine(int lineIndex) Get Line at given line indexintGet the number of lines appended, not including any unterminated onesintGet the number of lines appended, including any unterminated ones@NotNull LineInfogetLineInfo(int lineIndex) Get Line information at given line indexprivate LineInfogetLineRange(int start, int end, CharSequence prefix) @NotNull Iterable<BasedSequence> getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) Full line iterator over some linesgetLinesInfo(int maxTrailingBlankLines, int startLine, int endLine) Full line iterator with line info@NotNull BitFieldSet<LineAppendable.Options> Get current options as set which can be used to modify optionsintGet number of EOLs at end of appendable, this is actually number of tail blank linesintGet number of spaces at end of pending text@NotNull BasedSequenceGet prefix being applied to all lines, even in pre-formatted sections This is the prefix that will be set after EOLprivate Pair<Range, CharSequence> Returns text range if EOL was appendedintgetTrailingBlankLines(int endLine) Get trailing blank line count ending on given line@NotNull LineAppendableindent()Increase the indent level, will terminate the current line if there is unterminated textvoidinsertLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence content) Insert a line at the index with given content and prefix for a lineprivate booleanprivate booleanbooleanTest if trailing text ends in space or tabprivate booleanisPrefixed(int currentLine) booleanprivate booleanprivate booleanprivate booleaniterator()Full line iterator NOTE: will not issue line() to terminate any unterminated lines before iteration and will not include unterminated lines in iteration(package private) intlastNonBlankLine(int endLine) @NotNull LineAppendableline()Add a new line if there was any unterminated text appended or if this is a preformatted region@NotNull LineAppendablelineIf(boolean predicate) Add a new line, if predicate is true and line() would add an EOL.@NotNull LineAppendablelineOnFirstText(boolean value) @NotNull LineAppendablelineWithTrailingSpaces(int count) Add a new line, keep trailing spaces if there was any unterminated text appendedintoffset()Get text offset of all output lines, excluding any text for the last line being accumulatedprivate intReturns text offset before EOL if EOL was issuedintGet offset after last append as if EOL was added but without the EOL itself@NotNull LineAppendableopenPreFormatted(boolean addPrefixToFirstLine) Open preformatted section and suspend content modification@NotNull LineAppendable@NotNull LineAppendablepopPrefix(boolean afterEol) Pop a prefix from the stack and set the current prefix@NotNull LineAppendable@NotNull LineAppendableSave the current prefix on the stackprivate voidprivate voidprivate void(package private) voidrecomputeLineInfo(int startLine) 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 LineAppendableremoveIndentOnFirstEOL(@NotNull Runnable listener) Remove runnable, has no effect if EOL was already appended and runnable was run@NotNull LineAppendableremoveLines(int startLine, int endLine) private intremoveLinesRaw(int startLine, int endLine) Remove lines and return index from which line info must be recomputed@NotNull LineAppendablerepeat(@NotNull CharSequence csq, int count) @NotNull LineAppendablerepeat(@NotNull CharSequence csq, int start, int end, int count) private void@NotNull LineAppendablesetIndentPrefix(@Nullable CharSequence prefix) Set prefix to append after a new line character for every indent levelvoidsetLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence content) Set content and prefix for a line@NotNull LineAppendablesetOptions(int flags) Set options on processing text@NotNull LineAppendablesetPrefix(@Nullable CharSequence prefix, boolean afterEol) Set prefix appended after a new line character for every line and after a new line in pre-formatted sectionsvoidsetPrefixLength(int lineIndex, int prefixLength) Change prefix length for a given line without changing the line content(package private) inttailBlankLinesToRemove(int endLine, int maxTrailingBlankLines) @NotNull CharSequencetoSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) get the resulting text for all linestoString()@NotNull StringtoString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) get the resulting text for all lines@NotNull LineAppendableunIndent()Decrease the indent level, min level is 0, will terminate the current line if there is unterminated text@NotNull LineAppendableDecrease the indent level, if there is unterminated text then unindented prefix is to be applied after the next EOL.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface LineAppendable
addOptions, addPrefix, append, append, appendAll, appendTo, appendTo, appendTo, appendTo, appendToSilently, appendToSilently, appendToSilently, appendToSilently, clearLineOnFirstText, 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, toSequence, toSequence, toSequence, toSequence, toString, toString, toString, toString, trimLeading
-
Field Details
-
EOL
private static final char EOL- See Also:
-
passThrough
private final boolean passThrough -
options
-
preFormattedNesting
private int preFormattedNesting -
preFormattedFirstLine
private int preFormattedFirstLine -
preFormattedFirstLineOffset
private int preFormattedFirstLineOffset -
preFormattedLastLine
private int preFormattedLastLine -
preFormattedLastLineOffset
private int preFormattedLastLineOffset -
appendable
-
lines
-
prefix
-
prefixAfterEol
-
indentPrefix
-
prefixStack
-
indentPrefixStack
-
allWhitespace
private boolean allWhitespace -
lastWasWhitespace
private boolean lastWasWhitespace -
eolOnFirstText
private int eolOnFirstText -
indentsOnFirstEol
-
optionStack
-
modificationCount
int modificationCount
-
-
Constructor Details
-
LineAppendableImpl
public LineAppendableImpl(int formatOptions) -
LineAppendableImpl
-
LineAppendableImpl
public LineAppendableImpl(@Nullable @Nullable Appendable appendable, BitFieldSet<LineAppendable.Options> formatOptions)
-
-
Method Details
-
getEmptyAppendable
- Specified by:
getEmptyAppendablein interfaceLineAppendable
-
getOptionSet
Description copied from interface:LineAppendableGet current options as set which can be used to modify options- Specified by:
getOptionSetin interfaceLineAppendable- Returns:
- mutable option set
-
setOptions
Description copied from interface:LineAppendableSet options on processing text- Specified by:
setOptionsin interfaceLineAppendable- Parameters:
flags- option flags- Returns:
- this
-
pushOptions
- Specified by:
pushOptionsin interfaceLineAppendable
-
popOptions
- Specified by:
popOptionsin interfaceLineAppendable
-
changeOptions
- Specified by:
changeOptionsin interfaceLineAppendable
-
any
private boolean any(int flags) -
isConvertingTabs
private boolean isConvertingTabs() -
isTrimTrailingWhitespace
private boolean isTrimTrailingWhitespace() -
isTrimLeadingWhitespace
private boolean isTrimLeadingWhitespace() -
isCollapseWhitespace
private boolean isCollapseWhitespace() -
getIndentPrefix
Description copied from interface:LineAppendableGet prefix appended after a new line character for every indent level- Specified by:
getIndentPrefixin interfaceLineAppendable- Returns:
- char sequence of the current indent prefix used for each indent level
-
setIndentPrefix
Description copied from interface:LineAppendableSet prefix to append after a new line character for every indent level- Specified by:
setIndentPrefixin interfaceLineAppendable- Parameters:
prefix- prefix characters for new lines appended after this is set- Returns:
- this
-
getPrefix
Description copied from interface:LineAppendableGet prefix being applied to all lines, even in pre-formatted sections This is the prefix that will be set after EOL- Specified by:
getPrefixin interfaceLineAppendable- Returns:
- char sequence of the current prefix
-
getBeforeEolPrefix
Description copied from interface:LineAppendableGet prefix used before EOL- Specified by:
getBeforeEolPrefixin interfaceLineAppendable- Returns:
- char sequence of the current prefix
-
addPrefix
@NotNull public @NotNull LineAppendable addPrefix(@NotNull @NotNull CharSequence prefix, boolean afterEol) Description copied from interface:LineAppendableAdd 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
- Specified by:
addPrefixin interfaceLineAppendable- 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
-
getAfterEolPrefixDelta
public int getAfterEolPrefixDelta()Description copied from interface:LineAppendableGet pending prefix after EOL- Specified by:
getAfterEolPrefixDeltain interfaceLineAppendable- Returns:
- change in prefix length after next eol
-
setPrefix
@NotNull public @NotNull LineAppendable setPrefix(@Nullable @Nullable CharSequence prefix, boolean afterEol) Description copied from interface:LineAppendableSet 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
- Specified by:
setPrefixin interfaceLineAppendable- 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
-
indent
Description copied from interface:LineAppendableIncrease 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
LineAppendable.unIndent()is called only on prefixes added by this method- Specified by:
indentin interfaceLineAppendable- Returns:
- this
-
rawIndent
private void rawIndent() -
rawUnIndent
private void rawUnIndent() -
unIndent
Description copied from interface:LineAppendableDecrease 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
LineAppendable.indent()- Specified by:
unIndentin interfaceLineAppendable- Returns:
- this
-
unIndentNoEol
Description copied from interface:LineAppendableDecrease 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
LineAppendable.addIndentOnFirstEOL(Runnable)if callback is invoked- Specified by:
unIndentNoEolin interfaceLineAppendable- Returns:
- this
-
pushPrefix
Description copied from interface:LineAppendableSave the current prefix on the stack- Specified by:
pushPrefixin interfaceLineAppendable- Returns:
- this
-
popPrefix
Description copied from interface:LineAppendablePop a prefix from the stack and set the current prefix- Specified by:
popPrefixin interfaceLineAppendable- Parameters:
afterEol- if true prefix will take effect after EOL- Returns:
- this
-
getLastLineInfo
-
isTrailingBlankLine
private boolean isTrailingBlankLine() -
lastNonBlankLine
int lastNonBlankLine(int endLine) -
getTrailingBlankLines
public int getTrailingBlankLines(int endLine) Description copied from interface:LineAppendableGet trailing blank line count ending on given line- Specified by:
getTrailingBlankLinesin interfaceLineAppendable- Parameters:
endLine- end line- Returns:
- number of trailing blank lines
-
endsWithEOL
public boolean endsWithEOL()- Specified by:
endsWithEOLin interfaceLineAppendable- Returns:
- true if not empty and have no unterminated lines
-
getLineRange
-
resetBuilder
private void resetBuilder() -
addLineRange
-
appendEol
-
rawIndentsOnFirstEol
private void rawIndentsOnFirstEol() -
appendEol
private void appendEol(int count) -
isPrefixed
private boolean isPrefixed(int currentLine) -
getRangePrefixAfterEol
Returns text range if EOL was appendedNOTE: if range == Range.NULL then no line would be added
- Returns:
- pair of line text range if EOL was added and prefix
-
offsetAfterEol
private int offsetAfterEol()Returns text offset before EOL if EOL was issued- Returns:
- would be offset after adding EOL - 1
-
doEolOnFirstTest
private void doEolOnFirstTest() -
appendImpl
-
appendImpl
-
append
- Specified by:
appendin interfaceAppendable- Specified by:
appendin interfaceLineAppendable
-
getBuilder
Description copied from interface:LineAppendableGet builder used for accumulation- Specified by:
getBuilderin interfaceLineAppendable- Returns:
- builder used for accumulation
-
append
@NotNull public @NotNull LineAppendable append(@NotNull @NotNull CharSequence csq, int start, int end) - Specified by:
appendin interfaceAppendable- Specified by:
appendin interfaceLineAppendable
-
append
- Specified by:
appendin interfaceAppendable- Specified by:
appendin interfaceLineAppendable
-
append
- Specified by:
appendin interfaceLineAppendable
-
repeat
-
repeat
@NotNull public @NotNull LineAppendable repeat(@NotNull @NotNull CharSequence csq, int start, int end, int count) -
line
Description copied from interface:LineAppendableAdd a new line if there was any unterminated text appended or if this is a preformatted region- Specified by:
linein interfaceLineAppendable- Returns:
- this
-
lineWithTrailingSpaces
Description copied from interface:LineAppendableAdd 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
- Specified by:
lineWithTrailingSpacesin interfaceLineAppendable- Parameters:
count- number of trailing spaces to add- Returns:
- this
-
lineIf
Description copied from interface:LineAppendableAdd a new line, if predicate is true and line() would add an EOL.- Specified by:
lineIfin interfaceLineAppendable- Parameters:
predicate- callLineAppendable.line()if value is true.- Returns:
- this
-
blankLine
Description copied from interface:LineAppendableAdd a blank line, if there is not one already appended.- Specified by:
blankLinein interfaceLineAppendable- Returns:
- this
-
blankLineIf
Description copied from interface:LineAppendableAdd a blank line, if predicate is true and there isn't already blank lines appended.- Specified by:
blankLineIfin interfaceLineAppendable- Parameters:
predicate- when true append blank line- Returns:
- this
-
blankLine
Description copied from interface:LineAppendableAdd 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.- Specified by:
blankLinein interfaceLineAppendable- Parameters:
count- number of blank lines to append- Returns:
- this
-
lineOnFirstText
- Specified by:
lineOnFirstTextin interfaceLineAppendable
-
removeIndentOnFirstEOL
Description copied from interface:LineAppendableRemove runnable, has no effect if EOL was already appended and runnable was run- Specified by:
removeIndentOnFirstEOLin interfaceLineAppendable- Parameters:
listener- runnable added with addIndentOnFirstEOL- Returns:
- this
-
addIndentOnFirstEOL
Description copied from interface:LineAppendableAdd an indent on first EOL appended and run runnable- Specified by:
addIndentOnFirstEOLin interfaceLineAppendable- Parameters:
listener- runnable to run if adding indent on first EOL- Returns:
- this
-
getLineCount
public int getLineCount()Description copied from interface:LineAppendableGet the number of lines appended, not including any unterminated ones- Specified by:
getLineCountin interfaceLineAppendable- Returns:
- number of full lines appended
-
getLineCountWithPending
public int getLineCountWithPending()Description copied from interface:LineAppendableGet 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
- Specified by:
getLineCountWithPendingin interfaceLineAppendable- Returns:
- number of lines appended
-
column
public int column()Description copied from interface:LineAppendableGet column offset after last append- Specified by:
columnin interfaceLineAppendable- Returns:
- column offset after last append
-
getLineInfo
Description copied from interface:LineAppendableGet Line information at given line indexNOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly
- Specified by:
getLineInfoin interfaceLineAppendable- Parameters:
lineIndex- line index for the info to get- Returns:
- line info
-
getLine
Description copied from interface:LineAppendableGet Line at given line indexNOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly
- Specified by:
getLinein interfaceLineAppendable- Parameters:
lineIndex- line index- Returns:
- line char sequence
-
offset
public int offset()Description copied from interface:LineAppendableGet text offset of all output lines, excluding any text for the last line being accumulated- Specified by:
offsetin interfaceLineAppendable- Returns:
- offset of text as would be returned for all
-
offsetWithPending
public int offsetWithPending()Description copied from interface:LineAppendableGet offset after last append as if EOL was added but without the EOL itself- Specified by:
offsetWithPendingin interfaceLineAppendable- Returns:
- offset as would be returned by
LineAppendable.offset()after line() call less 1 for EOL
-
isPendingSpace
public boolean isPendingSpace()Description copied from interface:LineAppendableTest if trailing text ends in space or tab- Specified by:
isPendingSpacein interfaceLineAppendable- Returns:
- true if ending in space or tab
-
getPendingSpace
public int getPendingSpace()Description copied from interface:LineAppendableGet number of spaces at end of pending text- Specified by:
getPendingSpacein interfaceLineAppendable- Returns:
- number of eols at end of text
-
getPendingEOL
public int getPendingEOL()Description copied from interface:LineAppendableGet number of EOLs at end of appendable, this is actually number of tail blank lines- Specified by:
getPendingEOLin interfaceLineAppendable- Returns:
- number of eols at end of text
-
isPreFormatted
public boolean isPreFormatted()- Specified by:
isPreFormattedin interfaceLineAppendable- Returns:
- true if in pre-formatted region
-
openPreFormatted
Description copied from interface:LineAppendableOpen preformatted section and suspend content modification- Specified by:
openPreFormattedin interfaceLineAppendable- Parameters:
addPrefixToFirstLine- if true will add the current prefix to first line- Returns:
- this
-
closePreFormatted
Description copied from interface:LineAppendableClose preformatted section and suspend content modification- Specified by:
closePreFormattedin interfaceLineAppendable- Returns:
- this
-
toString
-
toString
@NotNull public @NotNull String toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) Description copied from interface:LineAppendableget the resulting text for all lines- Specified by:
toStringin interfaceLineAppendable- Parameters:
maxBlankLines- maximum blank lines to allow in the textmaxTrailingBlankLines- maximum trailing blank lineswithPrefixes- true if to include prefixes- Returns:
- resulting text
-
toSequence
@NotNull public @NotNull CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) Description copied from interface:LineAppendableget the resulting text for all lines- Specified by:
toSequencein interfaceLineAppendable- Parameters:
maxBlankLines- maximum blank lines to allow in the textmaxTrailingBlankLines- maximum trailing blank lineswithPrefixes- true if to include prefixes- Returns:
- resulting text
-
appendTo
public <T extends Appendable> T appendTo(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException Description copied from interface:LineAppendableappend lines to appendable with given maximum trailing blank lines and given prefix to add to all linesNOTE:
- Specified by:
appendToin interfaceLineAppendable- 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:
IOException- if thrown by appendable
-
appendToNoLine
public <T extends Appendable> T appendToNoLine(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException - Throws:
IOException
-
append
@NotNull public @NotNull LineAppendable append(@NotNull @NotNull LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes) Description copied from interface:LineAppendableAppend 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
- Specified by:
appendin interfaceLineAppendable- Parameters:
lineAppendable- lines to append, any unterminated lines will be terminated by aLineAppendable.line()invocation.startLine- start line to appendendLine- end line to append, endLine is excluded.withPrefixes- true if to include prefixes from the lineAppendable.- Returns:
- this
-
removeLinesRaw
private int removeLinesRaw(int startLine, int endLine) Remove lines and return index from which line info must be recomputed- Parameters:
startLine- start line index to removeendLine- end line index to remove- Returns:
- index from which line info must be recomputed
-
recomputeLineInfo
void recomputeLineInfo(int startLine) -
removeLines
- Specified by:
removeLinesin interfaceLineAppendable
-
removeExtraBlankLines
public LineAppendable removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) Description copied from interface:LineAppendableNormalize the appendable by removing extra blank lines in the body or at the end of given line range- Specified by:
removeExtraBlankLinesin interfaceLineAppendable- 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
-
setPrefixLength
public void setPrefixLength(int lineIndex, int prefixLength) Description copied from interface:LineAppendableChange prefix length for a given line without changing the line content- Specified by:
setPrefixLengthin interfaceLineAppendable- Parameters:
lineIndex- index of the lineprefixLength- new prefix length
-
createLineInfo
private LineInfo createLineInfo(int lineIndex, @NotNull @NotNull CharSequence prefix, @NotNull @NotNull CharSequence content) -
setLine
public void setLine(int lineIndex, @NotNull @NotNull CharSequence prefix, @NotNull @NotNull CharSequence content) Description copied from interface:LineAppendableSet content and prefix for a line- Specified by:
setLinein interfaceLineAppendable- Parameters:
lineIndex- index of the lineprefix- prefix of the linecontent- content text of the line
-
insertLine
public void insertLine(int lineIndex, @NotNull @NotNull CharSequence prefix, @NotNull @NotNull CharSequence content) Description copied from interface:LineAppendableInsert a line at the index with given content and prefix for a line- Specified by:
insertLinein interfaceLineAppendable- Parameters:
lineIndex- index of the lineprefix- prefix of the linecontent- content text of the line
-
tailBlankLinesToRemove
int tailBlankLinesToRemove(int endLine, int maxTrailingBlankLines) -
getIndexedLineInfoProxy
@NotNull @NotNull LineAppendableImpl.IndexedLineInfoProxy getIndexedLineInfoProxy(int maxTrailingBlankLines, int startLine, int endLine) -
getIndexedLineProxy
@NotNull @NotNull LineAppendableImpl.IndexedLineProxy getIndexedLineProxy(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) -
iterator
Description copied from interface:LineAppendableFull line iterator NOTE: will not issue line() to terminate any unterminated lines before iteration and will not include unterminated lines in iteration- Specified by:
iteratorin interfaceIterable<LineInfo>- Specified by:
iteratorin interfaceLineAppendable- Returns:
- iterator over lines
-
getLines
@NotNull public @NotNull Iterable<BasedSequence> getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) Description copied from interface:LineAppendableFull line iterator over some linesNOTE: will issue line() to terminate any unterminated lines before iteration
- Specified by:
getLinesin interfaceLineAppendable- 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
-
getLinesInfo
@NotNull public @NotNull Iterable<LineInfo> getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine) Description copied from interface:LineAppendableFull line iterator with line infoNOTE: will issue line() to terminate any unterminated lines before iteration
- Specified by:
getLinesInfoin interfaceLineAppendable- Parameters:
maxTrailingBlankLines- maximum trailing blank lines, -1 if trailing EOL should be removedstartLine- start line indexendLine- end line index, exclusive- Returns:
- iterator over lines
-