Class HtmlAppendableBase<T extends HtmlAppendableBase<T>>
- java.lang.Object
-
- com.vladsch.flexmark.util.html.HtmlAppendableBase<T>
-
- All Implemented Interfaces:
HtmlAppendable,LineAppendable,java.lang.Appendable,java.lang.Iterable<LineInfo>
- Direct Known Subclasses:
HtmlBuilder,HtmlWriter
public class HtmlAppendableBase<T extends HtmlAppendableBase<T>> extends java.lang.Object implements HtmlAppendable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vladsch.flexmark.util.sequence.LineAppendable
LineAppendable.Options
-
-
Field Summary
Fields Modifier and Type Field Description private LineAppendableappendableprivate @Nullable MutableAttributescurrentAttributesprivate booleanindentOnFirstEolprivate booleanlineOnChildTextprivate @NotNull java.util.Stack<java.lang.String>openTagsprivate booleansuppressCloseTagLineprivate booleansuppressOpenTagLineprivate booleanwithAttributes-
Fields inherited from interface com.vladsch.flexmark.util.sequence.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
Constructors Constructor Description HtmlAppendableBase(int indentSize, int formatOptions)HtmlAppendableBase(@Nullable java.lang.Appendable other, int indentSize, int formatOptions)HtmlAppendableBase(LineAppendable other, boolean inheritIndent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TaddIndentOnFirstEOL(@NotNull java.lang.Runnable listener)Add an indent on first EOL appended and run runnableTaddPrefix(@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 sectionsTaddPrefix(@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 sectionsTappend(char c)Tappend(char c, int count)Tappend(@NotNull LineAppendable lines, int startLine, int endLine, boolean withPrefixes)Append lines from another line formatting appendable.Tappend(@NotNull java.lang.CharSequence csq)Tappend(@NotNull java.lang.CharSequence csq, int start, int end)<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 linesTattr(@NotNull Attribute... attribute)Tattr(@NotNull Attributes attributes)Tattr(@NotNull java.lang.CharSequence attrName, @NotNull java.lang.CharSequence value)TblankLine()Add a blank line, if there is not one already appended.TblankLine(int count)Add a blank lines, if there isn't already given number of blank lines appended.TblankLineIf(boolean predicate)Add a blank line, if predicate is true and there isn't already blank lines appended.TchangeOptions(int addFlags, int removeFlags)TclosePre()TclosePreFormatted()Close preformatted section and suspend content modificationTcloseTag(@NotNull java.lang.CharSequence tagName)intcolumn()Get column offset after last appendbooleanendsWithEOL()intgetAfterEolPrefixDelta()Get pending prefix after EOLAttributesgetAttributes()@NotNull BasedSequencegetBeforeEolPrefix()Get prefix used before EOL@NotNull ISequenceBuilder<?,?>getBuilder()Get builder used for accumulation@NotNull HtmlAppendablegetEmptyAppendable()@NotNull BasedSequencegetIndentPrefix()Get prefix appended after a new line character for every indent level@NotNull BasedSequencegetLine(int lineIndex)Get Line at given line indexintgetLineCount()Get the number of lines appended, not including any unterminated onesintgetLineCountWithPending()Get the number of lines appended, including any unterminated ones@NotNull LineInfogetLineInfo(int lineIndex)Get Line information at given line index@NotNull java.lang.Iterable<BasedSequence>getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes)Full line iterator over some lines@NotNull java.lang.Iterable<LineInfo>getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine)Full line iterator with line info@NotNull java.util.Stack<java.lang.String>getOpenTags()@NotNull java.util.List<java.lang.String>getOpenTagsAfterLast(@NotNull java.lang.CharSequence latestTag)protected java.lang.StringgetOpenTagText()intgetOptions()Get current options as bit mask flags@NotNull BitFieldSet<LineAppendable.Options>getOptionSet()Get current options as set which can be used to modify optionsintgetPendingEOL()Get number of EOLs at end of appendable, this is actually number of tail blank linesintgetPendingSpace()Get number of spaces at end of pending text@NotNull BasedSequencegetPrefix()Get prefix being applied to all lines, even in pre-formatted sections This is the prefix that will be set after EOLintgetTrailingBlankLines(int endLine)Get trailing blank line count ending on given lineprivate booleanhaveOptions(int options)Tindent()Increase the indent level, will terminate the current line if there is unterminated textbooleaninPre()voidinsertLine(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 linebooleanisPendingSpace()Test if trailing text ends in space or tabbooleanisPreFormatted()booleanisSuppressCloseTagLine()booleanisSuppressOpenTagLine()@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 iterationTline()Add a new line if there was any unterminated text appended or if this is a preformatted regionTlineIf(boolean predicate)Add a new line, if predicate is true and line() would add an EOL.TlineOnFirstText(boolean value)TlineWithTrailingSpaces(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 accumulatedintoffsetWithPending()Get offset after last append as if EOL was added but without the EOL itselfTopenPre()TopenPreFormatted(boolean keepIndent)Open preformatted section and suspend content modificationTpopOptions()TpopPrefix()Pop a prefix from the stack and set the current prefixTpopPrefix(boolean afterEol)Pop a prefix from the stack and set the current prefixprotected voidpopTag(java.lang.CharSequence tagName)TpushOptions()TpushPrefix()Save the current prefix on the stackprotected voidpushTag(java.lang.CharSequence tagName)Traw(@NotNull java.lang.CharSequence s)Traw(@NotNull java.lang.CharSequence s, int count)TrawIndentedPre(@NotNull java.lang.CharSequence s)TrawPre(@NotNull java.lang.CharSequence s)TremoveExtraBlankLines(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 rangeTremoveIndentOnFirstEOL(@NotNull java.lang.Runnable listener)Remove runnable, has no effect if EOL was already appended and runnable was runTremoveLines(int startLine, int endLine)TsetAttributes(@NotNull Attributes attributes)TsetIndentPrefix(@Nullable java.lang.CharSequence prefix)Set prefix to append after a new line character for every indent levelvoidsetLine(int lineIndex, @NotNull java.lang.CharSequence prefix, @NotNull java.lang.CharSequence text)Set content and prefix for a lineTsetOptions(int flags)Set options on processing textTsetPrefix(@NotNull java.lang.CharSequence prefix)Set prefix appended after a new line character for every line and after a new line in pre-formatted sectionsTsetPrefix(@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 sectionsvoidsetPrefixLength(int lineIndex, int prefixEndIndex)Change prefix length for a given line without changing the line contentTsetSuppressCloseTagLine(boolean suppressCloseTagLine)voidsetSuppressOpenTagLine(boolean suppressOpenTagLine)Ttag(@NotNull java.lang.CharSequence tagName)Ttag(@NotNull java.lang.CharSequence tagName, boolean voidElement)Ttag(@NotNull java.lang.CharSequence tagName, boolean withIndent, boolean withLine, @NotNull java.lang.Runnable runnable)Ttag(@NotNull java.lang.CharSequence tagName, @NotNull java.lang.Runnable runnable)protected voidtagClosed(java.lang.CharSequence tagName)TtagIndent(@NotNull java.lang.CharSequence tagName, @NotNull java.lang.Runnable runnable)TtagLine(@NotNull java.lang.CharSequence tagName)TtagLine(@NotNull java.lang.CharSequence tagName, boolean voidElement)TtagLine(@NotNull java.lang.CharSequence tagName, @NotNull java.lang.Runnable runnable)TtagLineIndent(@NotNull java.lang.CharSequence tagName, @NotNull java.lang.Runnable runnable)protected voidtagOpened(java.lang.CharSequence tagName)TtagVoid(@NotNull java.lang.CharSequence tagName)TtagVoidLine(@NotNull java.lang.CharSequence tagName)Ttext(@NotNull java.lang.CharSequence s)@NotNull java.lang.CharSequencetoSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes)get the resulting text for all lines@NotNull java.lang.StringtoString()@NotNull java.lang.StringtoString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes)get the resulting text for all linesTunIndent()Decrease the indent level, min level is 0, will terminate the current line if there is unterminated textTunIndentNoEol()Decrease the indent level, if there is unterminated text then unindented prefix is to be applied after the next EOL.TwithAttr()TwithCondIndent()TwithCondLineOnChildText()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.vladsch.flexmark.util.sequence.LineAppendable
addOptions, 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, getTrailingBlankLines, isEmpty, isNotEmpty, noPreserveSpaces, noTrimLeading, preserveSpaces, removeExtraBlankLines, removeOptions, setLineOnFirstText, setOptions, setOptions, toSequence, toSequence, toSequence, toSequence, toString, toString, toString, toString, trimLeading
-
-
-
-
Field Detail
-
appendable
private final LineAppendable appendable
-
currentAttributes
@Nullable private @Nullable MutableAttributes currentAttributes
-
indentOnFirstEol
private boolean indentOnFirstEol
-
lineOnChildText
private boolean lineOnChildText
-
withAttributes
private boolean withAttributes
-
suppressOpenTagLine
private boolean suppressOpenTagLine
-
suppressCloseTagLine
private boolean suppressCloseTagLine
-
openTags
@NotNull private final @NotNull java.util.Stack<java.lang.String> openTags
-
-
Constructor Detail
-
HtmlAppendableBase
public HtmlAppendableBase(LineAppendable other, boolean inheritIndent)
-
HtmlAppendableBase
public HtmlAppendableBase(int indentSize, int formatOptions)
-
HtmlAppendableBase
public HtmlAppendableBase(@Nullable @Nullable java.lang.Appendable other, int indentSize, int formatOptions)
-
-
Method Detail
-
getEmptyAppendable
@NotNull public @NotNull HtmlAppendable getEmptyAppendable()
- Specified by:
getEmptyAppendablein interfaceLineAppendable
-
isSuppressOpenTagLine
public boolean isSuppressOpenTagLine()
-
setSuppressOpenTagLine
public void setSuppressOpenTagLine(boolean suppressOpenTagLine)
-
isSuppressCloseTagLine
public boolean isSuppressCloseTagLine()
-
setSuppressCloseTagLine
@NotNull public T setSuppressCloseTagLine(boolean suppressCloseTagLine)
-
toString
@NotNull public @NotNull java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
openPre
@NotNull public T openPre()
- Specified by:
openPrein interfaceHtmlAppendable
-
closePre
@NotNull public T closePre()
- Specified by:
closePrein interfaceHtmlAppendable
-
inPre
public boolean inPre()
- Specified by:
inPrein interfaceHtmlAppendable
-
haveOptions
private boolean haveOptions(int options)
-
raw
@NotNull public T raw(@NotNull @NotNull java.lang.CharSequence s)
- Specified by:
rawin interfaceHtmlAppendable
-
raw
@NotNull public T raw(@NotNull @NotNull java.lang.CharSequence s, int count)
- Specified by:
rawin interfaceHtmlAppendable
-
rawPre
@NotNull public T rawPre(@NotNull @NotNull java.lang.CharSequence s)
- Specified by:
rawPrein interfaceHtmlAppendable
-
rawIndentedPre
@NotNull public T rawIndentedPre(@NotNull @NotNull java.lang.CharSequence s)
- Specified by:
rawIndentedPrein interfaceHtmlAppendable
-
text
@NotNull public T text(@NotNull @NotNull java.lang.CharSequence s)
- Specified by:
textin interfaceHtmlAppendable
-
attr
@NotNull public T attr(@NotNull @NotNull java.lang.CharSequence attrName, @NotNull @NotNull java.lang.CharSequence value)
- Specified by:
attrin interfaceHtmlAppendable
-
attr
@NotNull public T attr(@NotNull @NotNull Attribute... attribute)
- Specified by:
attrin interfaceHtmlAppendable
-
attr
@NotNull public T attr(@NotNull @NotNull Attributes attributes)
- Specified by:
attrin interfaceHtmlAppendable
-
withAttr
@NotNull public T withAttr()
- Specified by:
withAttrin interfaceHtmlAppendable
-
getAttributes
public Attributes getAttributes()
- Specified by:
getAttributesin interfaceHtmlAppendable
-
setAttributes
@NotNull public T setAttributes(@NotNull @NotNull Attributes attributes)
- Specified by:
setAttributesin interfaceHtmlAppendable
-
withCondLineOnChildText
@NotNull public T withCondLineOnChildText()
- Specified by:
withCondLineOnChildTextin interfaceHtmlAppendable
-
withCondIndent
@NotNull public T withCondIndent()
- Specified by:
withCondIndentin interfaceHtmlAppendable
-
tag
@NotNull public T tag(@NotNull @NotNull java.lang.CharSequence tagName)
- Specified by:
tagin interfaceHtmlAppendable
-
tag
@NotNull public T tag(@NotNull @NotNull java.lang.CharSequence tagName, @NotNull @NotNull java.lang.Runnable runnable)
- Specified by:
tagin interfaceHtmlAppendable
-
tagVoid
@NotNull public T tagVoid(@NotNull @NotNull java.lang.CharSequence tagName)
- Specified by:
tagVoidin interfaceHtmlAppendable
-
getOpenTagText
protected java.lang.String getOpenTagText()
-
pushTag
protected void pushTag(java.lang.CharSequence tagName)
-
popTag
protected void popTag(java.lang.CharSequence tagName)
-
tagOpened
protected void tagOpened(java.lang.CharSequence tagName)
-
tagClosed
protected void tagClosed(java.lang.CharSequence tagName)
-
getOpenTags
@NotNull public @NotNull java.util.Stack<java.lang.String> getOpenTags()
- Specified by:
getOpenTagsin interfaceHtmlAppendable
-
getOpenTagsAfterLast
@NotNull public @NotNull java.util.List<java.lang.String> getOpenTagsAfterLast(@NotNull @NotNull java.lang.CharSequence latestTag)- Specified by:
getOpenTagsAfterLastin interfaceHtmlAppendable
-
tag
@NotNull public T tag(@NotNull @NotNull java.lang.CharSequence tagName, boolean voidElement)
- Specified by:
tagin interfaceHtmlAppendable
-
closeTag
@NotNull public T closeTag(@NotNull @NotNull java.lang.CharSequence tagName)
- Specified by:
closeTagin interfaceHtmlAppendable
-
tag
@NotNull public T tag(@NotNull @NotNull java.lang.CharSequence tagName, boolean withIndent, boolean withLine, @NotNull @NotNull java.lang.Runnable runnable)
- Specified by:
tagin interfaceHtmlAppendable
-
tagVoidLine
@NotNull public T tagVoidLine(@NotNull @NotNull java.lang.CharSequence tagName)
- Specified by:
tagVoidLinein interfaceHtmlAppendable
-
tagLine
@NotNull public T tagLine(@NotNull @NotNull java.lang.CharSequence tagName)
- Specified by:
tagLinein interfaceHtmlAppendable
-
tagLine
@NotNull public T tagLine(@NotNull @NotNull java.lang.CharSequence tagName, boolean voidElement)
- Specified by:
tagLinein interfaceHtmlAppendable
-
tagLine
@NotNull public T tagLine(@NotNull @NotNull java.lang.CharSequence tagName, @NotNull @NotNull java.lang.Runnable runnable)
- Specified by:
tagLinein interfaceHtmlAppendable
-
tagIndent
@NotNull public T tagIndent(@NotNull @NotNull java.lang.CharSequence tagName, @NotNull @NotNull java.lang.Runnable runnable)
- Specified by:
tagIndentin interfaceHtmlAppendable
-
tagLineIndent
@NotNull public T tagLineIndent(@NotNull @NotNull java.lang.CharSequence tagName, @NotNull @NotNull java.lang.Runnable runnable)
- Specified by:
tagLineIndentin interfaceHtmlAppendable
-
iterator
@NotNull public @NotNull java.util.Iterator<LineInfo> 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 interfacejava.lang.Iterable<T extends HtmlAppendableBase<T>>- Specified by:
iteratorin interfaceLineAppendable- Returns:
- iterator over lines
-
getLines
@NotNull public @NotNull java.lang.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 java.lang.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
-
setPrefixLength
public void setPrefixLength(int lineIndex, int prefixEndIndex)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 lineprefixEndIndex- new prefix length
-
insertLine
public void insertLine(int lineIndex, @NotNull @NotNull java.lang.CharSequence prefix, @NotNull @NotNull java.lang.CharSequence text)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 linetext- content text of the line
-
setLine
public void setLine(int lineIndex, @NotNull @NotNull java.lang.CharSequence prefix, @NotNull @NotNull java.lang.CharSequence text)Description copied from interface:LineAppendableSet content and prefix for a line- Specified by:
setLinein interfaceLineAppendable- Parameters:
lineIndex- index of the lineprefix- prefix of the linetext- content text of the line
-
appendTo
public <T extends java.lang.Appendable> T appendTo(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws java.io.IOExceptionDescription 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:
java.io.IOException- if thrown by appendable
-
endsWithEOL
public boolean endsWithEOL()
- Specified by:
endsWithEOLin interfaceLineAppendable- Returns:
- true if not empty and have no unterminated lines
-
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
-
isPreFormatted
public boolean isPreFormatted()
- Specified by:
isPreFormattedin interfaceLineAppendable- Returns:
- true if in pre-formatted region
-
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
-
column
public int column()
Description copied from interface:LineAppendableGet column offset after last append- Specified by:
columnin interfaceLineAppendable- Returns:
- column offset after last append
-
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
-
getOptions
public int getOptions()
Description copied from interface:LineAppendableGet current options as bit mask flags- Specified by:
getOptionsin interfaceLineAppendable- Returns:
- option flags
-
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
-
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
-
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
-
getBuilder
@NotNull public @NotNull ISequenceBuilder<?,?> getBuilder()
Description copied from interface:LineAppendableGet builder used for accumulation- Specified by:
getBuilderin interfaceLineAppendable- Returns:
- builder used for accumulation
-
getPrefix
@NotNull public @NotNull BasedSequence 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
@NotNull public @NotNull BasedSequence getBeforeEolPrefix()
Description copied from interface:LineAppendableGet prefix used before EOL- Specified by:
getBeforeEolPrefixin interfaceLineAppendable- Returns:
- char sequence of the current prefix
-
getLineInfo
@NotNull public @NotNull LineInfo getLineInfo(int lineIndex)
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
@NotNull public @NotNull BasedSequence getLine(int lineIndex)
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
-
getIndentPrefix
@NotNull public @NotNull BasedSequence 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
-
toSequence
@NotNull public @NotNull java.lang.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
-
toString
@NotNull public @NotNull java.lang.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
-
getOptionSet
@NotNull public @NotNull BitFieldSet<LineAppendable.Options> 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
-
removeExtraBlankLines
@NotNull public T 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
-
removeLines
@NotNull public T removeLines(int startLine, int endLine)
- Specified by:
removeLinesin interfaceLineAppendable
-
pushOptions
@NotNull public T pushOptions()
- Specified by:
pushOptionsin interfaceLineAppendable
-
popOptions
@NotNull public T popOptions()
- Specified by:
popOptionsin interfaceLineAppendable
-
changeOptions
@NotNull public T changeOptions(int addFlags, int removeFlags)
- Specified by:
changeOptionsin interfaceLineAppendable
-
addIndentOnFirstEOL
@NotNull public T addIndentOnFirstEOL(@NotNull @NotNull java.lang.Runnable listener)
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
-
addPrefix
@NotNull public T addPrefix(@NotNull @NotNull java.lang.CharSequence prefix)
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 set- Returns:
- this
-
addPrefix
@NotNull public T addPrefix(@NotNull @NotNull java.lang.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
-
append
@NotNull public T append(char c)
- Specified by:
appendin interfacejava.lang.Appendable- Specified by:
appendin interfaceLineAppendable
-
append
@NotNull public T append(@NotNull @NotNull java.lang.CharSequence csq)
- Specified by:
appendin interfacejava.lang.Appendable- Specified by:
appendin interfaceLineAppendable
-
append
@NotNull public T append(@NotNull @NotNull java.lang.CharSequence csq, int start, int end)
- Specified by:
appendin interfacejava.lang.Appendable- Specified by:
appendin interfaceLineAppendable
-
append
@NotNull public T append(@NotNull @NotNull LineAppendable lines, 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:
lines- 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
-
blankLine
@NotNull public T blankLine()
Description copied from interface:LineAppendableAdd a blank line, if there is not one already appended.- Specified by:
blankLinein interfaceLineAppendable- Returns:
- this
-
blankLine
@NotNull public T blankLine(int count)
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
-
blankLineIf
@NotNull public T blankLineIf(boolean predicate)
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
-
closePreFormatted
@NotNull public T closePreFormatted()
Description copied from interface:LineAppendableClose preformatted section and suspend content modification- Specified by:
closePreFormattedin interfaceLineAppendable- Returns:
- this
-
indent
@NotNull public T 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
-
line
@NotNull public T 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
-
lineIf
@NotNull public T lineIf(boolean predicate)
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
-
lineOnFirstText
@NotNull public T lineOnFirstText(boolean value)
- Specified by:
lineOnFirstTextin interfaceLineAppendable
-
lineWithTrailingSpaces
@NotNull public T lineWithTrailingSpaces(int count)
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
-
openPreFormatted
@NotNull public T openPreFormatted(boolean keepIndent)
Description copied from interface:LineAppendableOpen preformatted section and suspend content modification- Specified by:
openPreFormattedin interfaceLineAppendable- Parameters:
keepIndent- if true will add the current prefix to first line- Returns:
- this
-
popPrefix
@NotNull public T popPrefix()
Description copied from interface:LineAppendablePop a prefix from the stack and set the current prefix- Specified by:
popPrefixin interfaceLineAppendable- Returns:
- this
-
popPrefix
@NotNull public T popPrefix(boolean afterEol)
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
-
pushPrefix
@NotNull public T pushPrefix()
Description copied from interface:LineAppendableSave the current prefix on the stack- Specified by:
pushPrefixin interfaceLineAppendable- Returns:
- this
-
removeIndentOnFirstEOL
@NotNull public T removeIndentOnFirstEOL(@NotNull @NotNull java.lang.Runnable listener)
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
-
append
@NotNull public T append(char c, int count)
- Specified by:
appendin interfaceLineAppendable
-
setIndentPrefix
@NotNull public T setIndentPrefix(@Nullable @Nullable java.lang.CharSequence prefix)
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
-
setOptions
@NotNull public T setOptions(int flags)
Description copied from interface:LineAppendableSet options on processing text- Specified by:
setOptionsin interfaceLineAppendable- Parameters:
flags- option flags- Returns:
- this
-
setPrefix
@NotNull public T setPrefix(@NotNull @NotNull java.lang.CharSequence prefix)
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 set- Returns:
- this
-
setPrefix
@NotNull public T setPrefix(@Nullable @Nullable java.lang.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
-
unIndent
@NotNull public T 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
@NotNull public T 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
-
-