public class FormattingAppendableImpl extends Object implements FormattingAppendable
ALLOW_LEADING_WHITESPACE, COLLAPSE_WHITESPACE, CONVERT_TABS, FORMAT_ALL, PASS_THROUGH, PREFIX_AFTER_PENDING_EOL, SUPPRESS_TRAILING_WHITESPACE| Constructor and Description |
|---|
FormattingAppendableImpl(Appendable appendable,
int formatOptions) |
FormattingAppendableImpl(int formatOptions) |
| Modifier and Type | Method and Description |
|---|---|
FormattingAppendableImpl |
addAfterEolRunnable(int atPendingEOL,
Runnable runnable)
Add runnable to run after the given pending EOL is output to the stream.
|
FormattingAppendable |
addLine()
Add a new line or blank lines as needed.
|
FormattingAppendable |
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
|
FormattingAppendable |
append(char c) |
FormattingAppendable |
append(CharSequence csq) |
FormattingAppendable |
append(CharSequence csq,
int start,
int end) |
FormattingAppendable |
blankLine()
Add a blank line, if there is not one already appended.
|
FormattingAppendable |
blankLine(int count)
Add a blank lines, if there isn't already given number of blank lines appended.
|
FormattingAppendable |
blankLineIf(boolean predicate)
Add a blank line, if predicate is true and there isn't already blank lines appended.
|
FormattingAppendable |
closeConditional(ConditionalFormatter closeFormatter)
Close a conditional formatting region.
|
FormattingAppendable |
closePreFormatted()
Close a pre-formatted section.
|
int |
column()
Get column offset after last append, does not include any pending: EOLs, spaces nor indents
|
int |
columnWith(CharSequence csq,
int start,
int end)
Get column offset after last append, does not include any pending: EOLs, spaces nor indents
|
FormattingAppendable |
flush()
Flush all pending new lines, no blank lines will be output, if these are desired at the end of the output.
|
FormattingAppendable |
flush(int maxBlankLines)
Flush all pending new lines and blank lines, if these are desired at the end of the output.
|
FormattingAppendable |
flushWhitespaces()
Flush all pending whitespaces
|
Appendable |
getAppendable()
Get the underlying appendable
|
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.
|
int |
getOptions()
Get current options
|
int |
getPendingEOL()
see if there is a pending space
|
int |
getPendingSpace() |
BasedSequence |
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. |
FormattingAppendable |
indent()
Increase the indent level, will terminate the current line if there is unterminated text
|
boolean |
isPendingEOL()
see if there is a pending space
|
boolean |
isPendingSpace()
see if there is a pending space
|
boolean |
isPreFormatted() |
int |
lastOffset()
Get offset before the last append, but right after pending: EOLs, spaces or indents were added
|
FormattingAppendable |
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. |
FormattingAppendable |
line()
Add a new line, if there was any unterminated text appended
|
FormattingAppendable |
line(Ref<Boolean> lineRef)
Add a new line, if there was any unterminated text appended
|
FormattingAppendable |
lineIf(boolean predicate)
Add a new line, if predicate is true and there was any unterminated text appended
|
FormattingAppendable |
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
|
int |
offsetWithPending()
Get offset after last append, include any pending: EOLs, and indents
|
FormattingAppendable |
openConditional(ConditionalFormatter openFormatter)
Open a conditional formatting region.
|
FormattingAppendable |
openPreFormatted(boolean keepIndent)
Open a pre-formatted section.
|
FormattingAppendable |
popPrefix()
Pop a prefix from the stack and set the current prefix
|
FormattingAppendable |
pushPrefix()
Save the current prefix on the stack
|
FormattingAppendable |
repeat(char c,
int count) |
FormattingAppendable |
repeat(CharSequence csq,
int count) |
FormattingAppendable |
repeat(CharSequence csq,
int start,
int end,
int count) |
FormattingAppendable |
setIndentOffset(int indentOffset)
Set the current indent level.
|
FormattingAppendable |
setIndentPrefix(CharSequence prefix)
Set prefix to append after a new line character for every indent level
|
FormattingAppendable |
setOptions(int options)
Set options on processing text
|
void |
setPendingEOL(int pendingEOL)
Kludge to allow inserting spaces before the already pending EOL in HTML parser
|
void |
setPendingEOLRaw(int pendingEOL) |
FormattingAppendable |
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
|
FormattingAppendable |
unIndent()
Decrease the indent level, min level is 0, will terminate the current line if there is unterminated text
|
FormattingAppendable |
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
|
public FormattingAppendableImpl(int formatOptions)
public FormattingAppendableImpl(Appendable appendable, int formatOptions)
public int getOptions()
FormattingAppendablegetOptions in interface FormattingAppendablepublic FormattingAppendable setOptions(int options)
FormattingAppendablesetOptions in interface FormattingAppendableoptions - option flagspublic void setPendingEOLRaw(int pendingEOL)
public void setPendingEOL(int pendingEOL)
FormattingAppendablesetPendingEOL in interface FormattingAppendablependingEOL - how many pending EOLs to setpublic FormattingAppendableImpl addAfterEolRunnable(int atPendingEOL, Runnable runnable)
FormattingAppendableaddAfterEolRunnable in interface FormattingAppendableatPendingEOL - pending EOL levelrunnable - runnable to run once this EOL is outputpublic IOException getIOException()
getIOException in interface FormattingAppendablepublic FormattingAppendable append(CharSequence csq)
append in interface FormattingAppendableappend in interface Appendablepublic FormattingAppendable append(CharSequence csq, int start, int end)
append in interface FormattingAppendableappend in interface Appendablepublic FormattingAppendable append(char c)
append in interface FormattingAppendableappend in interface Appendablepublic FormattingAppendable repeat(char c, int count)
repeat in interface FormattingAppendablepublic FormattingAppendable repeat(CharSequence csq, int count)
repeat in interface FormattingAppendablepublic FormattingAppendable repeat(CharSequence csq, int start, int end, int count)
repeat in interface FormattingAppendablepublic Appendable getAppendable()
FormattingAppendablegetAppendable in interface FormattingAppendablepublic 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 FormattingAppendable flush()
FormattingAppendableAll preFormatted and conditional regions should be exited prior to this call
flush in interface FormattingAppendablepublic FormattingAppendable flushWhitespaces()
FormattingAppendableAll preFormatted and conditional regions should be exited prior to this call
flushWhitespaces in interface FormattingAppendablepublic FormattingAppendable 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 FormattingAppendable setIndentPrefix(CharSequence prefix)
FormattingAppendablesetIndentPrefix in interface FormattingAppendableprefix - prefix characters for new lines appended after this is setpublic BasedSequence getPrefix()
FormattingAppendablegetPrefix in interface FormattingAppendablepublic CharSequence getTotalIndentPrefix()
FormattingAppendableFormattingAppendable.getIndentPrefix() repeated FormattingAppendable.getIndent() times.getTotalIndentPrefix in interface FormattingAppendablepublic FormattingAppendable setPrefix(CharSequence prefix)
FormattingAppendablesetPrefix in interface FormattingAppendableprefix - prefix characters for new lines appended after this is setpublic FormattingAppendable addPrefix(CharSequence prefix)
FormattingAppendableaddPrefix in interface FormattingAppendableprefix - prefix characters to add to current prefix for new lines appended after this is setpublic FormattingAppendable pushPrefix()
FormattingAppendablepushPrefix in interface FormattingAppendablepublic FormattingAppendable popPrefix()
FormattingAppendablepopPrefix in interface FormattingAppendablepublic int getPushedPrefixCount()
FormattingAppendablegetPushedPrefixCount in interface FormattingAppendablepublic FormattingAppendable 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 FormattingAppendable 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 FormattingAppendable 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 FormattingAppendable 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 FormattingAppendable 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 FormattingAppendable 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 FormattingAppendable 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 FormattingAppendable 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 int getIndent()
FormattingAppendablegetIndent in interface FormattingAppendablepublic FormattingAppendable setIndentOffset(int indentOffset)
FormattingAppendablesetIndentOffset in interface FormattingAppendableindentOffset - minimum indent that will be usedpublic FormattingAppendable indent()
FormattingAppendableindent in interface FormattingAppendablepublic FormattingAppendable willIndent()
FormattingAppendablewillIndent in interface FormattingAppendablepublic FormattingAppendable unIndent()
FormattingAppendableunIndent in interface FormattingAppendablepublic int getModCount()
FormattingAppendablegetModCount in interface FormattingAppendablepublic int getLineCount()
FormattingAppendablegetLineCount in interface FormattingAppendablepublic FormattingAppendable 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 int offsetWithPending()
FormattingAppendableoffsetWithPending in interface FormattingAppendablepublic int column()
FormattingAppendablecolumn in interface FormattingAppendablepublic int columnWith(CharSequence csq, int start, int end)
FormattingAppendablecolumnWith in interface FormattingAppendablecsq - sequence to use for computationstart - start offset in csqend - end offset in csqpublic FormattingAppendable openPreFormatted(boolean keepIndent)
FormattingAppendableopenPreFormatted in interface FormattingAppendablekeepIndent - if true, if there is pending indent it will be appended before entering pre-format modepublic FormattingAppendable closePreFormatted()
FormattingAppendableclosePreFormatted in interface FormattingAppendablepublic boolean isPendingSpace()
FormattingAppendableisPendingSpace in interface FormattingAppendablepublic int getPendingSpace()
getPendingSpace in interface FormattingAppendablepublic boolean isPendingEOL()
FormattingAppendableisPendingEOL in interface FormattingAppendablepublic int getPendingEOL()
FormattingAppendablegetPendingEOL in interface FormattingAppendablepublic boolean isPreFormatted()
isPreFormatted in interface FormattingAppendablepublic FormattingAppendable 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 FormattingAppendable 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 © 2019. All rights reserved.