public class HtmlFormattingAppendableBase<T extends HtmlFormattingAppendableBase> extends Object implements HtmlFormattingAppendable
COLLAPSE_WHITESPACE, CONVERT_TABS, FORMAT_ALL, PASS_THROUGH, PREFIX_AFTER_PENDING_EOL, SUPPRESS_TRAILING_WHITESPACE| Constructor and Description |
|---|
HtmlFormattingAppendableBase(Appendable out) |
HtmlFormattingAppendableBase(Appendable out,
int indentSize,
boolean allFormatOptions) |
HtmlFormattingAppendableBase(Appendable out,
int indentSize,
int formatOptions) |
HtmlFormattingAppendableBase(FormattingAppendable other,
Appendable out,
boolean inheritIndent) |
| Modifier and Type | Method and Description |
|---|---|
T |
addAfterEolRunnable(int atPendingEOL,
Runnable runnable)
Add runnable to run after the given pending EOL is output to the stream.
|
T |
addLine()
Add a new line or blank lines as needed.
|
T |
addPrefix(CharSequence prefix)
Set prefix to append after a new line character for every line before the indent prefix in normal
and after a new line in pre-formatted sections
This appends the sequence to current prefix
|
T |
append(char c) |
T |
append(CharSequence csq) |
T |
append(CharSequence csq,
int start,
int end) |
T |
attr(Attribute... attribute) |
T |
attr(Attributes attributes) |
T |
attr(CharSequence attrName,
CharSequence value) |
T |
blankLine()
Add a blank line, if there is not one already appended.
|
T |
blankLine(int count)
Add a blank lines, if there isn't already given number of blank lines appended.
|
T |
blankLineIf(boolean predicate)
Add a blank line, if predicate is true and there isn't already blank lines appended.
|
T |
closeConditional(ConditionalFormatter closeFormatter)
Close a conditional formatting region.
|
T |
closePre() |
T |
closePreFormatted()
Close a pre-formatted section.
|
T |
closeTag(CharSequence tagName) |
T |
flush()
Flush all pending new lines, no blank lines will be output, if these are desired at the end of the output.
|
T |
flush(int maxBlankLines)
Flush all pending new lines and blank lines, if these are desired at the end of the output.
|
T |
flushWhitespaces()
Flush all pending whitespaces
|
Appendable |
getAppendable()
Get the underlying appendable
|
Attributes |
getAttributes() |
int |
getIndent()
Get the current indent level + indent offset
|
CharSequence |
getIndentPrefix()
Get prefix appended after a new line character for every indent level
|
IOException |
getIOException() |
int |
getLineCount()
Get the number of lines appended, does not include pending: EOLs
|
int |
getModCount()
Get the modification count.
|
Stack<String> |
getOpenTags() |
List<String> |
getOpenTagsAfterLast(CharSequence latestTag) |
protected String |
getOpenTagText() |
int |
getOptions()
Get current options
|
int |
getPendingEOL()
see if there is a pending space
|
CharSequence |
getPrefix()
Get prefix being applied to all lines, even in pre-formatted sections
|
int |
getPushedPrefixCount()
Pop a prefix from the stack and set the current prefix
|
String |
getText()
get the resulting text from appendable
|
String |
getText(int maxBlankLines)
get the resulting text from appendable
|
CharSequence |
getTotalIndentPrefix()
Get the total indent prefix appended after a new line character,
FormattingAppendable.getIndentPrefix() repeated FormattingAppendable.getIndent() times. |
T |
indent()
Increase the indent level, will terminate the current line if there is unterminated text
|
boolean |
inPre() |
boolean |
isPendingEOL()
see if there is a pending space
|
boolean |
isPendingSpace()
see if there is a pending space
|
boolean |
isPreFormatted() |
boolean |
isSuppressCloseTagLine() |
boolean |
isSuppressOpenTagLine() |
int |
lastOffset()
Get offset before the last append, but right after pending: EOLs, spaces or indents were added
|
T |
lastOffset(Ref<Integer> refOffset)
Get offset before the next append, but right after pending: EOLs, spaces or indents were added
Next append of text (non EOL/spaces) will set the reference, following appends will have not effect
Unlike
FormattingAppendable.lastOffset() flush() does not change the value of the reference, only actual character appending. |
T |
line()
Add a new line, if there was any unterminated text appended
|
T |
line(Ref<Boolean> lineRef)
Add a new line, if there was any unterminated text appended
|
T |
lineIf(boolean predicate)
Add a new line, if predicate is true and there was any unterminated text appended
|
T |
lineIf(Ref<Boolean> lineRef)
Add a new line, if lineRef is true, if false means that the new line in
FormattingAppendable.line(Ref) was suppressed
by conditionalFormatter and this new line will be suppressed too. |
int |
offset()
Get offset after last append, does not include any pending: EOLs, spaces nor indents
|
T |
openConditional(ConditionalFormatter openFormatter)
Open a conditional formatting region.
|
T |
openPre() |
T |
openPreFormatted(boolean keepIndent)
Open a pre-formatted section.
|
T |
popPrefix()
Pop a prefix from the stack and set the current prefix
|
protected void |
popTag(CharSequence tagName) |
T |
pushPrefix()
Save the current prefix on the stack
|
protected void |
pushTag(CharSequence tagName) |
T |
raw(CharSequence s) |
T |
raw(CharSequence s,
int count) |
T |
rawIndentedPre(CharSequence s) |
T |
rawPre(CharSequence s) |
T |
repeat(char c,
int count) |
T |
repeat(CharSequence csq,
int count) |
T |
repeat(CharSequence csq,
int start,
int end,
int count) |
T |
setAttributes(Attributes attributes) |
T |
setIndentOffset(int indentOffset)
Set the current indent level.
|
T |
setIndentPrefix(CharSequence prefix)
Set prefix to append after a new line character for every indent level
|
T |
setOptions(int options)
Set options on processing text
|
T |
setPrefix(CharSequence prefix)
Set prefix to append after a new line character for every line before the indent prefix in normal
and after a new line in pre-formatted sections
if PREFIX_AFTER_PENDING_EOL is enabled then prefix will take effect after pending EOLs are output
|
T |
setSuppressCloseTagLine(boolean suppressCloseTagLine) |
void |
setSuppressOpenTagLine(boolean suppressOpenTagLine) |
T |
tag(CharSequence tagName) |
T |
tag(CharSequence tagName,
boolean voidElement) |
T |
tag(CharSequence tagName,
boolean withIndent,
boolean withLine,
Runnable runnable) |
protected void |
tagClosed(CharSequence tagName) |
T |
tagIndent(CharSequence tagName,
Runnable runnable) |
T |
tagLine(CharSequence tagName) |
T |
tagLine(CharSequence tagName,
boolean voidElement) |
T |
tagLine(CharSequence tagName,
Runnable runnable) |
T |
tagLineIndent(CharSequence tagName,
Runnable runnable) |
protected void |
tagOpened(CharSequence tagName) |
T |
tagVoid(CharSequence tagName) |
T |
tagVoidLine(CharSequence tagName) |
T |
text(CharSequence s) |
T |
unIndent()
Decrease the indent level, min level is 0, will terminate the current line if there is unterminated text
|
T |
willIndent()
Notify of the fact that after some appending some text, there will be an indent() call so that
conditional formatting can kick in before the text is appended
|
T |
withAttr() |
T |
withCondIndent() |
T |
withCondLine() |
public HtmlFormattingAppendableBase(Appendable out)
public HtmlFormattingAppendableBase(FormattingAppendable other, Appendable out, boolean inheritIndent)
public HtmlFormattingAppendableBase(Appendable out, int indentSize, boolean allFormatOptions)
public HtmlFormattingAppendableBase(Appendable out, int indentSize, int formatOptions)
public boolean isSuppressOpenTagLine()
public void setSuppressOpenTagLine(boolean suppressOpenTagLine)
public boolean isSuppressCloseTagLine()
public T setSuppressCloseTagLine(boolean suppressCloseTagLine)
public T openPre()
openPre in interface HtmlFormattingAppendablepublic T closePre()
closePre in interface HtmlFormattingAppendablepublic boolean inPre()
inPre in interface HtmlFormattingAppendablepublic T raw(CharSequence s)
raw in interface HtmlFormattingAppendablepublic T raw(CharSequence s, int count)
raw in interface HtmlFormattingAppendablepublic T rawPre(CharSequence s)
rawPre in interface HtmlFormattingAppendablepublic T rawIndentedPre(CharSequence s)
rawIndentedPre in interface HtmlFormattingAppendablepublic T text(CharSequence s)
text in interface HtmlFormattingAppendablepublic T attr(CharSequence attrName, CharSequence value)
attr in interface HtmlFormattingAppendablepublic T attr(Attribute... attribute)
attr in interface HtmlFormattingAppendablepublic T attr(Attributes attributes)
attr in interface HtmlFormattingAppendablepublic T withAttr()
withAttr in interface HtmlFormattingAppendablepublic Attributes getAttributes()
getAttributes in interface HtmlFormattingAppendablepublic T setAttributes(Attributes attributes)
setAttributes in interface HtmlFormattingAppendablepublic T withCondLine()
withCondLine in interface HtmlFormattingAppendablepublic T withCondIndent()
withCondIndent in interface HtmlFormattingAppendablepublic T tag(CharSequence tagName)
tag in interface HtmlFormattingAppendablepublic T tagVoid(CharSequence tagName)
tagVoid in interface HtmlFormattingAppendableprotected String getOpenTagText()
protected void pushTag(CharSequence tagName)
protected void popTag(CharSequence tagName)
protected void tagOpened(CharSequence tagName)
protected void tagClosed(CharSequence tagName)
public Stack<String> getOpenTags()
getOpenTags in interface HtmlFormattingAppendablepublic List<String> getOpenTagsAfterLast(CharSequence latestTag)
getOpenTagsAfterLast in interface HtmlFormattingAppendablepublic T tag(CharSequence tagName, boolean voidElement)
tag in interface HtmlFormattingAppendablepublic T closeTag(CharSequence tagName)
closeTag in interface HtmlFormattingAppendablepublic T tag(CharSequence tagName, boolean withIndent, boolean withLine, Runnable runnable)
tag in interface HtmlFormattingAppendablepublic T tagVoidLine(CharSequence tagName)
tagVoidLine in interface HtmlFormattingAppendablepublic T tagLine(CharSequence tagName)
tagLine in interface HtmlFormattingAppendablepublic T tagLine(CharSequence tagName, boolean voidElement)
tagLine in interface HtmlFormattingAppendablepublic T tagLine(CharSequence tagName, Runnable runnable)
tagLine in interface HtmlFormattingAppendablepublic T tagIndent(CharSequence tagName, Runnable runnable)
tagIndent in interface HtmlFormattingAppendablepublic T tagLineIndent(CharSequence tagName, Runnable runnable)
tagLineIndent in interface HtmlFormattingAppendablepublic Appendable getAppendable()
FormattingAppendablegetAppendable in interface FormattingAppendablepublic int getOptions()
FormattingAppendablegetOptions in interface FormattingAppendablepublic T setOptions(int options)
FormattingAppendablesetOptions in interface FormattingAppendableoptions - option flagspublic int getModCount()
FormattingAppendablegetModCount in interface FormattingAppendablepublic boolean isPreFormatted()
isPreFormatted in interface FormattingAppendablepublic T line()
FormattingAppendableActual new line character is only appended if there is real data appended and it did not contain a new line as the last character
line in interface FormattingAppendablepublic T addLine()
FormattingAppendableActual new line character is only appended if there is real data appended and it did not contain a new line as the last character
addLine in interface FormattingAppendablepublic int getPushedPrefixCount()
FormattingAppendablegetPushedPrefixCount in interface FormattingAppendablepublic T blankLine()
FormattingAppendableActual blank line characters are only appended if there is real data appended and it did not contain a blank line as the last part of its text
blankLine in interface FormattingAppendablepublic T blankLine(int count)
FormattingAppendableOn real data being appended, will append enough new lines to ensure that there are given number of blank lines between previous append and the next one.
Actual blank line characters are only appended if there is real data appended and it did not contain a blank line as the last part of its text
blankLine in interface FormattingAppendablecount - number of blank lines to appendpublic T blankLineIf(boolean predicate)
FormattingAppendableActual blank line characters are only appended if and when there text is appended appended and it did not contain a blank line as the last part of its text
blankLineIf in interface FormattingAppendablepredicate - when true append blank linepublic T lineIf(boolean predicate)
FormattingAppendableActual new line character is only appended if and when text is appended appended and it did not contain a new line as the last character
lineIf in interface FormattingAppendablepredicate - if true then new line will be startedpublic T indent()
FormattingAppendableindent in interface FormattingAppendablepublic T willIndent()
FormattingAppendablewillIndent in interface FormattingAppendablepublic T unIndent()
FormattingAppendableunIndent in interface FormattingAppendablepublic IOException getIOException()
getIOException in interface FormattingAppendablepublic T append(CharSequence csq)
append in interface FormattingAppendableappend in interface Appendablepublic T append(CharSequence csq, int start, int end)
append in interface FormattingAppendableappend in interface Appendablepublic T append(char c)
append in interface FormattingAppendableappend in interface Appendablepublic String getText()
FormattingAppendablegetText in interface FormattingAppendablepublic String getText(int maxBlankLines)
FormattingAppendablegetText in interface FormattingAppendablemaxBlankLines - maximum blank lines to allow at end, -1 will suppress the last EOLpublic T flush()
FormattingAppendableAll preFormatted and conditional regions should be exited prior to this call
flush in interface FormattingAppendablepublic T flushWhitespaces()
FormattingAppendableAll preFormatted and conditional regions should be exited prior to this call
flushWhitespaces in interface FormattingAppendablepublic T flush(int maxBlankLines)
FormattingAppendableAll preFormatted and conditional regions should be exited prior to this call
flush in interface FormattingAppendablemaxBlankLines - maximum blank lines to allow at end, -1 will suppress the last EOLpublic CharSequence getIndentPrefix()
FormattingAppendablegetIndentPrefix in interface FormattingAppendablepublic T setIndentPrefix(CharSequence prefix)
FormattingAppendablesetIndentPrefix in interface FormattingAppendableprefix - prefix characters for new lines appended after this is setpublic CharSequence getPrefix()
FormattingAppendablegetPrefix in interface FormattingAppendablepublic T setPrefix(CharSequence prefix)
FormattingAppendablesetPrefix in interface FormattingAppendableprefix - prefix characters for new lines appended after this is setpublic T addPrefix(CharSequence prefix)
FormattingAppendableaddPrefix in interface FormattingAppendableprefix - prefix characters to add to current prefix for new lines appended after this is setpublic T pushPrefix()
FormattingAppendablepushPrefix in interface FormattingAppendablepublic T popPrefix()
FormattingAppendablepopPrefix in interface FormattingAppendablepublic T addAfterEolRunnable(int atPendingEOL, Runnable runnable)
FormattingAppendableaddAfterEolRunnable in interface FormattingAppendableatPendingEOL - pending EOL levelrunnable - runnable to run once this EOL is outputpublic CharSequence getTotalIndentPrefix()
FormattingAppendableFormattingAppendable.getIndentPrefix() repeated FormattingAppendable.getIndent() times.getTotalIndentPrefix in interface FormattingAppendablepublic T line(Ref<Boolean> lineRef)
FormattingAppendableActual new line character is only appended if there is real data appended and it did not contain a new line as the last character
line in interface FormattingAppendablelineRef - predicate storage will be set to false if conditionalFormatter suppressed a new linepublic T lineIf(Ref<Boolean> lineRef)
FormattingAppendableFormattingAppendable.line(Ref) was suppressed
by conditionalFormatter and this new line will be suppressed too.
Actual new line character is only appended if and when text is appended appended and it did not contain a new line as the last character
lineIf in interface FormattingAppendablelineRef - predicate storage for conditionalFormatter suppressed new line conditionpublic T repeat(char c, int count)
repeat in interface FormattingAppendablepublic T repeat(CharSequence csq, int count)
repeat in interface FormattingAppendablepublic T repeat(CharSequence csq, int start, int end, int count)
repeat in interface FormattingAppendablepublic boolean isPendingSpace()
FormattingAppendableisPendingSpace in interface FormattingAppendablepublic boolean isPendingEOL()
FormattingAppendableisPendingEOL in interface FormattingAppendablepublic int getPendingEOL()
FormattingAppendablegetPendingEOL in interface FormattingAppendablepublic int getIndent()
FormattingAppendablegetIndent in interface FormattingAppendablepublic T setIndentOffset(int indentOffset)
FormattingAppendablesetIndentOffset in interface FormattingAppendableindentOffset - minimum indent that will be usedpublic int getLineCount()
FormattingAppendablegetLineCount in interface FormattingAppendablepublic T lastOffset(Ref<Integer> refOffset)
FormattingAppendableFormattingAppendable.lastOffset() flush() does not change the value of the reference, only actual character appending.lastOffset in interface FormattingAppendablerefOffset - reference where to store offset, if no appending was done then value is not changedpublic int lastOffset()
FormattingAppendablelastOffset in interface FormattingAppendablepublic int offset()
FormattingAppendableoffset in interface FormattingAppendablepublic T openPreFormatted(boolean keepIndent)
FormattingAppendableopenPreFormatted in interface FormattingAppendablekeepIndent - if true, if there is pending indent it will be appended before entering pre-format modepublic T closePreFormatted()
FormattingAppendableclosePreFormatted in interface FormattingAppendablepublic T openConditional(ConditionalFormatter openFormatter)
FormattingAppendable
After opening if and when text is appended the ConditionalFormatter.apply(boolean, boolean, boolean, boolean)
will be invoked before appending the text with parameters specifying whether indent or line were
invoked before appending text. The onText is always true for opening conditional formatter or the apply() method
would not be called
the firstAppend will be set if this is the first call, if onIndent is false on first call then the apply() method will be invoked again if any indent() is performed before the conditional is closed.
openConditional in interface FormattingAppendableopenFormatter - to invoke before text is appendedpublic T closeConditional(ConditionalFormatter closeFormatter)
FormattingAppendable
ConditionalFormatter.apply(boolean, boolean, boolean, boolean)
will be invoked with parameters specifying whether indent, line or text was appended when FormattingAppendable.openConditional(ConditionalFormatter)
invoked before appending text. If onText is false then openFormatter passed to FormattingAppendable.openConditional(ConditionalFormatter) was
not invoked.
closeConditional in interface FormattingAppendablecloseFormatter - to invoke with parameters informing with what parameters the openFormatter was invoked, if at allCopyright © 2018. All rights reserved.