public abstract class MarkdownWriterBase<M extends MarkdownWriterBase<M,N,C>,N,C extends NodeContext<N,C>> extends Object implements LineFormattingAppendable
| Modifier and Type | Field and Description |
|---|---|
protected C |
context |
protected LineFormattingAppendable |
myAppendable |
ALLOW_LEADING_EOL, ALLOW_LEADING_WHITESPACE, COLLAPSE_WHITESPACE, CONVERT_TABS, FORMAT_ALL, PASS_THROUGH, PREFIX_AFTER_PENDING_EOL, PREFIX_PRE_FORMATTED, SUPPRESS_TRAILING_WHITESPACE| Constructor and Description |
|---|
MarkdownWriterBase() |
MarkdownWriterBase(int formatOptions) |
| Modifier and Type | Method and Description |
|---|---|
M |
addIndentOnFirstEOL(Runnable runnable) |
M |
addLine()
Add a new line or blank lines as needed.
|
M |
addPrefix(CharSequence prefix)
Add to prefix appended after a new line character for every line
and after a new line in pre-formatted sections
|
M |
addPrefix(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
|
M |
append(char c) |
M |
append(CharSequence csq) |
M |
append(CharSequence csq,
int start,
int end) |
M |
append(LineFormattingAppendable lineAppendable,
int startLine,
int endLine)
Append lines with given prefix
|
M |
appendTo(Appendable out,
int maxBlankLines,
CharSequence prefix,
int startLine,
int endLine)
append lines to appendable with given maximum trailing blank lines and given prefix to add to all lines
|
M |
blankLine()
Add a blank line, if there is not one already appended.
|
M |
blankLine(int count)
Add a blank lines, if there isn't already given number of blank lines appended.
|
M |
blankLineIf(boolean predicate)
Add a blank line, if predicate is true and there isn't already blank lines appended.
|
M |
closePreFormatted()
Close preformatted section and suspend content modification
|
int |
column()
Get column offset after last append
|
C |
getContext() |
CharSequence |
getIndentPrefix()
Get prefix appended after a new line character for every indent level
|
List<CharSequence> |
getLineContents(int startLine,
int endLine)
Get Lines without prefixes or EOL
|
int |
getLineCount()
Get the number of lines appended, does not include pending: EOLs
|
List<BasedSequence> |
getLinePrefixes(int startLine,
int endLine)
Get Line prefixes
|
List<CharSequence> |
getLines(int startLine,
int endLine)
Get Lines without EOL
|
int |
getOptions()
Get current options
|
int |
getPendingEOL()
Get number of EOLs at end of text (including pending text)
|
int |
getPendingSpace()
Get trailing spaces or tabs of trailing text
|
CharSequence |
getPrefix()
Get prefix being applied to all lines, even in pre-formatted sections
|
M |
indent()
Increase the indent level, will terminate the current line if there is unterminated text
|
abstract boolean |
isLastBlockQuoteChild() |
boolean |
isPendingSpace()
Test if trailing text ends in space or tab
|
boolean |
isPreFormatted() |
boolean |
isPreFormattedLine(int line)
Test if given line is part of pre-formatted text
|
M |
line()
Add a new line, if there was any unterminated text appended
|
M |
lineIf(boolean predicate)
Add a new line, if predicate is true and there was any unterminated text appended
|
M |
lineOnFirstText(boolean value) |
M |
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 (not including any text not included because it is not yet terminated by line() call)
NOTE: this includes prefixes
|
int |
offsetWithPending()
Get column offset after last append
NOTE: this includes prefixes
|
M |
openPreFormatted(boolean keepIndent)
Open preformatted section and suspend content modification
|
M |
popPrefix()
Pop a prefix from the stack and set the current prefix
|
M |
popPrefix(boolean afterEol)
Pop a prefix from the stack and set the current prefix
|
M |
prefixLines(CharSequence prefix,
boolean addAfterLinePrefix,
int startLine,
int endLine)
Add prefix to selected lines either before the line prefix or after it
|
M |
pushPrefix()
Save the current prefix on the stack
|
M |
removeIndentOnFirstEOL(Runnable runnable) |
M |
removeLines(int startLine,
int endLine)
Remove line range from result set
|
M |
repeat(char c,
int count) |
M |
repeat(CharSequence csq,
int count) |
M |
repeat(CharSequence csq,
int start,
int end,
int count) |
void |
setContext(C context) |
M |
setIndentPrefix(CharSequence prefix)
Set prefix to append after a new line character for every indent level
|
M |
setOptions(int options)
Set options on processing text
|
M |
setPrefix(CharSequence prefix)
Set prefix appended after a new line character for every line
and after a new line in pre-formatted sections
|
M |
setPrefix(CharSequence prefix,
boolean afterEol)
Set prefix appended after a new line character for every line
and after a new line in pre-formatted sections
|
M |
tailBlankLine() |
abstract M |
tailBlankLine(int count) |
int |
textOnlyOffset()
Get text offset of all output lines (not including any text not included because it is not yet terminated by line() call)
NOTE: this does not include prefixes
|
int |
textOnlyOffsetWithPending()
Get column offset after last append
NOTE: this does not include prefixes
|
String |
toString() |
String |
toString(int maxBlankLines)
get the resulting text for all lines
|
M |
unIndent()
Decrease the indent level, min level is 0, will terminate the current line if there is unterminated text
|
M |
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, waitappend, append, appendTo, appendTo, appendTo, appendTo, clearLineOnFirstText, getLineContent, getLineContents, getLineContents, getLinePrefix, getLinePrefixes, getLinePrefixes, getLines, getLines, lineWithTrailingSpaces, openPreFormatted, prefixLines, prefixLines, prefixLines, setLineOnFirstTextprotected final LineFormattingAppendable myAppendable
protected C extends NodeContext<N,C> context
public MarkdownWriterBase()
public MarkdownWriterBase(int formatOptions)
public void setContext(C context)
public C getContext()
public M tailBlankLine()
public abstract boolean isLastBlockQuoteChild()
public abstract M tailBlankLine(int count)
public boolean isPendingSpace()
LineFormattingAppendableisPendingSpace in interface LineFormattingAppendablepublic boolean isPreFormatted()
isPreFormatted in interface LineFormattingAppendablepublic boolean isPreFormattedLine(int line)
LineFormattingAppendableisPreFormattedLine in interface LineFormattingAppendableline - linepublic CharSequence getIndentPrefix()
LineFormattingAppendablegetIndentPrefix in interface LineFormattingAppendablepublic CharSequence getPrefix()
LineFormattingAppendablegetPrefix in interface LineFormattingAppendablepublic int column()
LineFormattingAppendablecolumn in interface LineFormattingAppendablepublic int getLineCount()
LineFormattingAppendablegetLineCount in interface LineFormattingAppendablepublic int getOptions()
LineFormattingAppendablegetOptions in interface LineFormattingAppendablepublic int getPendingEOL()
LineFormattingAppendablegetPendingEOL in interface LineFormattingAppendablepublic int getPendingSpace()
LineFormattingAppendablegetPendingSpace in interface LineFormattingAppendablepublic int offset()
LineFormattingAppendableoffset in interface LineFormattingAppendablepublic int offsetWithPending()
LineFormattingAppendableoffsetWithPending in interface LineFormattingAppendableLineFormattingAppendable.offset() after line() call less 1 for EOLpublic int textOnlyOffset()
LineFormattingAppendabletextOnlyOffset in interface LineFormattingAppendablepublic int textOnlyOffsetWithPending()
LineFormattingAppendabletextOnlyOffsetWithPending in interface LineFormattingAppendableLineFormattingAppendable.offset() after line() call less 1 for EOLpublic List<BasedSequence> getLinePrefixes(int startLine, int endLine)
LineFormattingAppendablegetLinePrefixes in interface LineFormattingAppendablestartLine - starting line offsetendLine - end line offsetpublic List<CharSequence> getLineContents(int startLine, int endLine)
LineFormattingAppendablegetLineContents in interface LineFormattingAppendablestartLine - starting line offsetendLine - end line offsetpublic List<CharSequence> getLines(int startLine, int endLine)
LineFormattingAppendablegetLines in interface LineFormattingAppendablestartLine - starting line offsetendLine - end line offsetpublic M addIndentOnFirstEOL(Runnable runnable)
addIndentOnFirstEOL in interface LineFormattingAppendablepublic M addLine()
LineFormattingAppendableaddLine in interface LineFormattingAppendablepublic M addPrefix(CharSequence prefix)
LineFormattingAppendableThis appends the sequence to current prefix
addPrefix in interface LineFormattingAppendableprefix - prefix characters to add to current prefix for new lines appended after this is setpublic M addPrefix(CharSequence prefix, boolean afterEol)
LineFormattingAppendableThis appends the sequence to current prefix
addPrefix in interface LineFormattingAppendableprefix - prefix characters to add to current prefix for new lines appended after this is setafterEol - if true prefix will take effect after EOLpublic M append(char c)
append in interface LineFormattingAppendableappend in interface Appendablepublic M append(CharSequence csq)
append in interface LineFormattingAppendableappend in interface Appendablepublic M append(CharSequence csq, int start, int end)
append in interface LineFormattingAppendableappend in interface Appendablepublic M append(LineFormattingAppendable lineAppendable, int startLine, int endLine)
LineFormattingAppendableappend in interface LineFormattingAppendablelineAppendable - lines to appendstartLine - start line to appendendLine - end line to appendpublic M appendTo(Appendable out, int maxBlankLines, CharSequence prefix, int startLine, int endLine) throws IOException
LineFormattingAppendableappendTo in interface LineFormattingAppendableout - appendable to output the resulting linesmaxBlankLines - maximum blank lines to allow at end, if -1 then no trailing EOL will be generatedprefix - prefix to add before each linestartLine - line from which to start outputIOException - if thrown by appendablepublic M blankLine()
LineFormattingAppendableblankLine in interface LineFormattingAppendablepublic M blankLine(int count)
LineFormattingAppendableblankLine in interface LineFormattingAppendablecount - number of blank lines to appendpublic M blankLineIf(boolean predicate)
LineFormattingAppendableblankLineIf in interface LineFormattingAppendablepredicate - when true append blank linepublic M closePreFormatted()
LineFormattingAppendableclosePreFormatted in interface LineFormattingAppendablepublic M indent()
LineFormattingAppendable
NOTE: this is equivalent to pushPrefix(), addPrefix(getIndentPrefix()) but adds flag to
validate that LineFormattingAppendable.unIndent() is called only on prefixes added by indent()
indent in interface LineFormattingAppendablepublic M line()
LineFormattingAppendableline in interface LineFormattingAppendablepublic M lineIf(boolean predicate)
LineFormattingAppendablelineIf in interface LineFormattingAppendablepredicate - if true then new line will be startedpublic M lineOnFirstText(boolean value)
lineOnFirstText in interface LineFormattingAppendablepublic M lineWithTrailingSpaces(int count)
LineFormattingAppendablelineWithTrailingSpaces in interface LineFormattingAppendablecount - number of trailing spaces to addpublic M openPreFormatted(boolean keepIndent)
LineFormattingAppendableopenPreFormatted in interface LineFormattingAppendablekeepIndent - if true will add current prefix to first linepublic M popPrefix()
LineFormattingAppendablepopPrefix in interface LineFormattingAppendablepublic M popPrefix(boolean afterEol)
LineFormattingAppendablepopPrefix in interface LineFormattingAppendableafterEol - if true prefix will take effect after EOLpublic M prefixLines(CharSequence prefix, boolean addAfterLinePrefix, int startLine, int endLine)
LineFormattingAppendableprefixLines in interface LineFormattingAppendableprefix - prefix to addaddAfterLinePrefix - if true add given prefix after the line prefixstartLine - starting line offsetendLine - end line offsetpublic M pushPrefix()
LineFormattingAppendablepushPrefix in interface LineFormattingAppendablepublic M removeIndentOnFirstEOL(Runnable runnable)
removeIndentOnFirstEOL in interface LineFormattingAppendablepublic M removeLines(int startLine, int endLine)
LineFormattingAppendableremoveLines in interface LineFormattingAppendablestartLine - starting line offsetendLine - end line offsetpublic M repeat(char c, int count)
repeat in interface LineFormattingAppendablepublic M repeat(CharSequence csq, int count)
repeat in interface LineFormattingAppendablepublic M repeat(CharSequence csq, int start, int end, int count)
repeat in interface LineFormattingAppendablepublic M setIndentPrefix(CharSequence prefix)
LineFormattingAppendablesetIndentPrefix in interface LineFormattingAppendableprefix - prefix characters for new lines appended after this is setpublic M setOptions(int options)
LineFormattingAppendablesetOptions in interface LineFormattingAppendableoptions - option flagspublic M setPrefix(CharSequence prefix)
LineFormattingAppendableThis appends the sequence to current prefix
setPrefix in interface LineFormattingAppendableprefix - prefix characters to add to current prefix for new lines appended after this is setpublic M setPrefix(CharSequence prefix, boolean afterEol)
LineFormattingAppendableThis appends the sequence to current prefix
setPrefix in interface LineFormattingAppendableprefix - prefix characters to add to current prefix for new lines appended after this is setafterEol - if true prefix will take effect after EOLpublic M unIndent()
LineFormattingAppendable
NOTE: this is equivalent to popPrefix() but with validation
that it is called only on prefixes added by LineFormattingAppendable.indent()
unIndent in interface LineFormattingAppendablepublic M unIndentNoEol()
LineFormattingAppendableWill NOT terminate the current line if there is unterminated text
NOTE: should be used with LineFormattingAppendable.addIndentOnFirstEOL(Runnable) if callback is invoked
unIndentNoEol in interface LineFormattingAppendablepublic String toString(int maxBlankLines)
LineFormattingAppendabletoString in interface LineFormattingAppendablemaxBlankLines - maximum blank lines to allow at end, if -1 then no trailing EOL will be generatedCopyright © 2019. All rights reserved.