public interface LineFormattingAppendable extends Appendable
control output of new lines limiting them to terminate text but not create blank lines, and control number of blank lines output, eliminate spaces before and after \n, other than indents controlled by this class.
consecutive \n in the data are going go be collapsed to a single \n
tab is converted to a space if CONVERT_TABS option is selected
spaces before and after \n are removed controlled by SUPPRESS_TRAILING_WHITESPACE and ALLOW_LEADING_WHITESPACE
use line(), lineIf(boolean), blankLine(), blankLineIf(boolean)
and blankLine(int) for getting these appended to result
| Modifier and Type | Field and Description |
|---|---|
static int |
ALLOW_LEADING_EOL |
static int |
ALLOW_LEADING_WHITESPACE |
static int |
COLLAPSE_WHITESPACE |
static int |
CONVERT_TABS |
static int |
FORMAT_ALL |
static int |
PASS_THROUGH |
static int |
PREFIX_AFTER_PENDING_EOL |
static int |
PREFIX_PRE_FORMATTED |
static int |
SUPPRESS_TRAILING_WHITESPACE |
| Modifier and Type | Method and Description |
|---|---|
LineFormattingAppendable |
addIndentOnFirstEOL(Runnable runnable) |
LineFormattingAppendable |
addLine()
Add a new line or blank lines as needed.
|
default LineFormattingAppendable |
addPrefix(CharSequence prefix)
Add to prefix appended after a new line character for every line
and after a new line in pre-formatted sections
|
LineFormattingAppendable |
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
|
LineFormattingAppendable |
append(char c) |
LineFormattingAppendable |
append(CharSequence csq) |
LineFormattingAppendable |
append(CharSequence csq,
int start,
int end) |
default LineFormattingAppendable |
append(LineFormattingAppendable lineAppendable)
Append lines
|
default LineFormattingAppendable |
append(LineFormattingAppendable lineAppendable,
int startLine)
Append lines with given prefix
|
LineFormattingAppendable |
append(LineFormattingAppendable lineAppendable,
int startLine,
int endLine)
Append lines with given prefix
|
default LineFormattingAppendable |
appendTo(Appendable out)
append lines to appendable with no trailing blank lines, if these are desired at the end of the output use
appendTo(Appendable, int). |
default LineFormattingAppendable |
appendTo(Appendable out,
int maxBlankLines)
append lines to appendable with given maximum trailing blank lines
|
default LineFormattingAppendable |
appendTo(Appendable out,
int maxBlankLines,
CharSequence prefix)
append lines to appendable with given maximum trailing blank lines and given prefix to add to all lines
|
default LineFormattingAppendable |
appendTo(Appendable out,
int maxBlankLines,
CharSequence prefix,
int startLine)
append lines to appendable with given maximum trailing blank lines and given prefix to add to all lines
|
LineFormattingAppendable |
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
|
LineFormattingAppendable |
blankLine()
Add a blank line, if there is not one already appended.
|
LineFormattingAppendable |
blankLine(int count)
Add a blank lines, if there isn't already given number of blank lines appended.
|
LineFormattingAppendable |
blankLineIf(boolean predicate)
Add a blank line, if predicate is true and there isn't already blank lines appended.
|
default LineFormattingAppendable |
clearLineOnFirstText() |
LineFormattingAppendable |
closePreFormatted()
Close preformatted section and suspend content modification
|
int |
column()
Get column offset after last append
|
CharSequence |
getIndentPrefix()
Get prefix appended after a new line character for every indent level
|
default CharSequence |
getLineContent(int lineIndex)
Get Line content of given line
|
default List<CharSequence> |
getLineContents()
Get Lines without prefixes or EOL
|
default List<CharSequence> |
getLineContents(int startLine)
Get Lines without prefixes or EOL
|
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
|
default BasedSequence |
getLinePrefix(int lineIndex)
Get Line content of given line
|
default List<BasedSequence> |
getLinePrefixes()
Get Line prefixes
|
default List<BasedSequence> |
getLinePrefixes(int startLine)
Get Line prefixes
|
List<BasedSequence> |
getLinePrefixes(int startLine,
int endLine)
Get Line prefixes
|
default List<CharSequence> |
getLines()
Get Lines without EOL
|
default List<CharSequence> |
getLines(int startLine)
Get Lines without EOL
|
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
|
LineFormattingAppendable |
indent()
Increase the indent level, will terminate the current line if there is unterminated text
|
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
|
LineFormattingAppendable |
line()
Add a new line, if there was any unterminated text appended
|
LineFormattingAppendable |
lineIf(boolean predicate)
Add a new line, if predicate is true and there was any unterminated text appended
|
LineFormattingAppendable |
lineOnFirstText(boolean value) |
default LineFormattingAppendable |
lineWithTrailingSpaces()
Add a new line, keep trailing spaces if there was any unterminated text appended
|
LineFormattingAppendable |
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
|
default LineFormattingAppendable |
openPreFormatted()
Open preformatted section and suspend content modification but add prefix to first line
|
LineFormattingAppendable |
openPreFormatted(boolean addPrefixToFirstLine)
Open preformatted section and suspend content modification
|
default LineFormattingAppendable |
popPrefix()
Pop a prefix from the stack and set the current prefix
|
LineFormattingAppendable |
popPrefix(boolean afterEol)
Pop a prefix from the stack and set the current prefix
|
default LineFormattingAppendable |
prefixLines(CharSequence prefix)
Add prefix to all lines
|
LineFormattingAppendable |
prefixLines(CharSequence prefix,
boolean addAfterLinePrefix,
int startLine,
int endLine)
Add prefix to selected lines either before the line prefix or after it
|
default LineFormattingAppendable |
prefixLines(CharSequence prefix,
int startLine)
Add prefix to all lines starting at given line
|
default LineFormattingAppendable |
prefixLines(CharSequence prefix,
int startLine,
int endLine)
Add prefix to selected lines
|
LineFormattingAppendable |
pushPrefix()
Save the current prefix on the stack
|
LineFormattingAppendable |
removeIndentOnFirstEOL(Runnable runnable) |
LineFormattingAppendable |
removeLines(int startLine,
int endLine)
Remove line range from result set
|
LineFormattingAppendable |
repeat(char c,
int count) |
LineFormattingAppendable |
repeat(CharSequence csq,
int count) |
LineFormattingAppendable |
repeat(CharSequence csq,
int start,
int end,
int count) |
LineFormattingAppendable |
setIndentPrefix(CharSequence prefix)
Set prefix to append after a new line character for every indent level
|
default LineFormattingAppendable |
setLineOnFirstText() |
LineFormattingAppendable |
setOptions(int options)
Set options on processing text
|
default LineFormattingAppendable |
setPrefix(CharSequence prefix)
Set prefix appended after a new line character for every line
and after a new line in pre-formatted sections
|
LineFormattingAppendable |
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
|
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(int maxBlankLines)
get the resulting text for all lines
|
LineFormattingAppendable |
unIndent()
Decrease the indent level, min level is 0, will terminate the current line if there is unterminated text
|
LineFormattingAppendable |
unIndentNoEol()
Decrease the indent level, if there is unterminated text then unindented prefix
is to be applied after the next EOL.
|
static final int CONVERT_TABS
static final int COLLAPSE_WHITESPACE
static final int SUPPRESS_TRAILING_WHITESPACE
static final int PREFIX_AFTER_PENDING_EOL
static final int PASS_THROUGH
static final int ALLOW_LEADING_WHITESPACE
static final int ALLOW_LEADING_EOL
static final int PREFIX_PRE_FORMATTED
static final int FORMAT_ALL
int getOptions()
LineFormattingAppendable setOptions(int options)
options - option flagsLineFormattingAppendable append(CharSequence csq)
append in interface AppendableLineFormattingAppendable append(CharSequence csq, int start, int end)
append in interface AppendableLineFormattingAppendable append(char c)
append in interface AppendableLineFormattingAppendable repeat(char c, int count)
LineFormattingAppendable repeat(CharSequence csq, int count)
LineFormattingAppendable repeat(CharSequence csq, int start, int end, int count)
default LineFormattingAppendable append(LineFormattingAppendable lineAppendable)
lineAppendable - lines to appenddefault LineFormattingAppendable append(LineFormattingAppendable lineAppendable, int startLine)
lineAppendable - lines to appendstartLine - start line to appendLineFormattingAppendable append(LineFormattingAppendable lineAppendable, int startLine, int endLine)
lineAppendable - lines to appendstartLine - start line to appendendLine - end line to appendboolean isPreFormattedLine(int line)
line - lineint getLineCount()
default LineFormattingAppendable prefixLines(CharSequence prefix)
prefix - prefix to adddefault LineFormattingAppendable prefixLines(CharSequence prefix, int startLine)
prefix - prefix to addstartLine - starting line offsetdefault LineFormattingAppendable prefixLines(CharSequence prefix, int startLine, int endLine)
prefix - prefix to addstartLine - starting line offsetendLine - end line offsetLineFormattingAppendable prefixLines(CharSequence prefix, boolean addAfterLinePrefix, int startLine, int endLine)
prefix - prefix to addaddAfterLinePrefix - if true add given prefix after the line prefixstartLine - starting line offsetendLine - end line offsetdefault List<CharSequence> getLines()
default List<CharSequence> getLines(int startLine)
startLine - starting line offsetList<CharSequence> getLines(int startLine, int endLine)
startLine - starting line offsetendLine - end line offsetdefault List<CharSequence> getLineContents()
default CharSequence getLineContent(int lineIndex)
default BasedSequence getLinePrefix(int lineIndex)
LineFormattingAppendable removeLines(int startLine, int endLine)
startLine - starting line offsetendLine - end line offsetdefault List<CharSequence> getLineContents(int startLine)
startLine - starting line offsetList<CharSequence> getLineContents(int startLine, int endLine)
startLine - starting line offsetendLine - end line offsetdefault List<BasedSequence> getLinePrefixes()
default List<BasedSequence> getLinePrefixes(int startLine)
startLine - starting line offsetList<BasedSequence> getLinePrefixes(int startLine, int endLine)
startLine - starting line offsetendLine - end line offsetint column()
int offset()
int offsetWithPending()
offset() after line() call less 1 for EOLint textOnlyOffset()
int textOnlyOffsetWithPending()
offset() after line() call less 1 for EOLboolean isPendingSpace()
int getPendingSpace()
int getPendingEOL()
String toString(int maxBlankLines)
maxBlankLines - maximum blank lines to allow at end, if -1 then no trailing EOL will be generateddefault LineFormattingAppendable appendTo(Appendable out) throws IOException
appendTo(Appendable, int).out - appendable to output the resulting linesIOException - if thrown by appendabledefault LineFormattingAppendable appendTo(Appendable out, int maxBlankLines) throws IOException
out - appendable to output the resulting linesmaxBlankLines - maximum blank lines to allow at endIOException - if thrown by appendabledefault LineFormattingAppendable appendTo(Appendable out, int maxBlankLines, CharSequence prefix) throws IOException
out - appendable to output the resulting linesmaxBlankLines - maximum blank lines to allow at endprefix - prefix to add before each lineIOException - if thrown by appendabledefault LineFormattingAppendable appendTo(Appendable out, int maxBlankLines, CharSequence prefix, int startLine) throws IOException
out - appendable to output the resulting linesmaxBlankLines - maximum blank lines to allow at endprefix - prefix to add before each linestartLine - line from which to start outputIOException - if thrown by appendableLineFormattingAppendable appendTo(Appendable out, int maxBlankLines, CharSequence prefix, int startLine, int endLine) throws IOException
out - 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 appendableLineFormattingAppendable line()
default LineFormattingAppendable lineWithTrailingSpaces()
LineFormattingAppendable lineWithTrailingSpaces(int count)
count - number of trailing spaces to addLineFormattingAppendable addLine()
LineFormattingAppendable lineIf(boolean predicate)
predicate - if true then new line will be startedLineFormattingAppendable blankLine()
LineFormattingAppendable blankLineIf(boolean predicate)
predicate - when true append blank lineLineFormattingAppendable blankLine(int count)
count - number of blank lines to appendboolean isPreFormatted()
default LineFormattingAppendable openPreFormatted()
LineFormattingAppendable openPreFormatted(boolean addPrefixToFirstLine)
addPrefixToFirstLine - if true will add current prefix to first lineLineFormattingAppendable closePreFormatted()
LineFormattingAppendable indent()
NOTE: this is equivalent to pushPrefix(), addPrefix(getIndentPrefix()) but adds flag to
validate that unIndent() is called only on prefixes added by indent()
LineFormattingAppendable unIndent()
NOTE: this is equivalent to popPrefix() but with validation
that it is called only on prefixes added by indent()
LineFormattingAppendable unIndentNoEol()
Will NOT terminate the current line if there is unterminated text
NOTE: should be used with addIndentOnFirstEOL(Runnable) if callback is invoked
CharSequence getIndentPrefix()
LineFormattingAppendable setIndentPrefix(CharSequence prefix)
prefix - prefix characters for new lines appended after this is setCharSequence getPrefix()
default LineFormattingAppendable addPrefix(CharSequence prefix)
This appends the sequence to current prefix
prefix - prefix characters to add to current prefix for new lines appended after this is setdefault LineFormattingAppendable setPrefix(CharSequence prefix)
This appends the sequence to current prefix
prefix - prefix characters to add to current prefix for new lines appended after this is setLineFormattingAppendable addPrefix(CharSequence prefix, boolean afterEol)
This appends the sequence to current prefix
prefix - prefix characters to add to current prefix for new lines appended after this is setafterEol - if true prefix will take effect after EOLLineFormattingAppendable setPrefix(CharSequence prefix, boolean afterEol)
This appends the sequence to current prefix
prefix - prefix characters to add to current prefix for new lines appended after this is setafterEol - if true prefix will take effect after EOLLineFormattingAppendable pushPrefix()
default LineFormattingAppendable popPrefix()
LineFormattingAppendable popPrefix(boolean afterEol)
afterEol - if true prefix will take effect after EOLdefault LineFormattingAppendable setLineOnFirstText()
default LineFormattingAppendable clearLineOnFirstText()
LineFormattingAppendable lineOnFirstText(boolean value)
LineFormattingAppendable addIndentOnFirstEOL(Runnable runnable)
LineFormattingAppendable removeIndentOnFirstEOL(Runnable runnable)
Copyright © 2019. All rights reserved.