|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectorg.tbull.util.dev.IndentableLineBuffer
public class IndentableLineBuffer
Provides a line buffer of individually indentable lines. Maintains the notion of a current line. Once the current line is dismissed (by beginning a new line), the line is no longer individually accessible, and its contents (text and, for the most part, the individual indent level [REALLY?]) are considered immutable for user operations. Detail on indent levels: base [indent] level individual [indent] level resulting [indent] level default [individual] [line] [indent] level If the resulting indent level is less than 0, it is assumed to be 0. add/appendLines(): The notion is, that the sub-buffer is *integrated* into the main buffer, thus the sub-buffer is expected to be dismissed thereafter. Therefore it does not hurt to screw it up (by messing with the indent levels). Use clone(), if you don't like it. Unless otherwise documented, all methods return this same object to facilitate [BANDWURM invocations (hibernate: method chaining)]. implements java.lang.Appendable, so the buffer can be specified as the destination of a java.util.Formatter. However, the buffer will not properly deal with newlines in the appended char sequences, so don't use them. Use newLine() then, e.g. like lb.format(...).newLine().format(...)
Constructor Summary | |
---|---|
IndentableLineBuffer()
Constructs a new LineBuffer, initially consisting of no lines (empty). |
|
IndentableLineBuffer(int base_indent_level)
Constructs a new LineBuffer, initially empty, with the given base indent level. |
|
IndentableLineBuffer(String s)
Constructs a new LineBuffer, initially consisting of a line given by s. |
Method Summary | |
---|---|
IndentableLineBuffer |
addLine(int indent,
String s)
Begins a new line with the given indent level and copies the contents of s into it. |
IndentableLineBuffer |
addLine(int indent,
StringBuilder sb)
Begins a new line with the given indent level and copies the contents of sb into it. |
IndentableLineBuffer |
addLine(String s)
Begins a new line and copies the contents of s into it. |
IndentableLineBuffer |
addLine(StringBuilder sb)
Begins a new line and copies the contents of sb into it. |
IndentableLineBuffer |
addLines(IndentableLineBuffer other)
Adds the lines of the other line buffer to this one. |
IndentableLineBuffer |
append(char c)
Appends the specified character to the current last line. |
IndentableLineBuffer |
append(CharSequence csq)
Appends the specified character sequence to the current last line. |
IndentableLineBuffer |
append(CharSequence csq,
int start,
int end)
Appends a subsequence of the specified character sequence to the current last line. |
IndentableLineBuffer |
append(String s)
Appends the contents of s to the current last line. |
IndentableLineBuffer |
append(StringBuilder sb)
Appends the contents of sb to the current last line. |
IndentableLineBuffer |
appendLines(IndentableLineBuffer other)
Adds the lines of the other line buffer to this one, concatenating the [letzte und erste (adjoining?)] lines. |
IndentableLineBuffer |
clone()
Creates a deep copy of this object. |
IndentableLineBuffer |
dumpData()
|
IndentableLineBuffer |
format(Locale l,
String format,
Object... args)
Append a formatted string to the current last line using the specified locale, format string, and arguments. |
IndentableLineBuffer |
format(String format,
Object... args)
Append a formatted string to the current last line using the specified format string and arguments. |
IndentableLineBuffer |
indent(int indent)
Indents existing and future lines by modifing the base indent level. |
IndentableLineBuffer |
indentCurrentLine(int indent)
Indents the current line. |
IndentableLineBuffer |
indentExisting(int indent)
Indents existing lines by modifying each line's individual indent level. |
IndentableLineBuffer |
newLine()
Begins a new (empty) line. |
IndentableLineBuffer |
newLine(int indent)
Begins a new (empty) line with the given indent level. |
IndentableLineBuffer |
setBaseIndentLevel(int indent_level)
Sets the base indent level. |
IndentableLineBuffer |
setDefaultLineIndentLevel(int indent_level)
Sets the default individual line indent level. |
IndentableLineBuffer |
setIndentation(String indentation)
Sets the indentation string to use on stringification. |
IndentableLineBuffer |
setLineSeparator(String sep)
Sets the line separator used by toString() . |
String |
toString()
Returns all lines in the LineBuffer as String, separated by newlines. |
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public IndentableLineBuffer()
public IndentableLineBuffer(String s)
public IndentableLineBuffer(int base_indent_level)
Method Detail |
---|
public IndentableLineBuffer dumpData()
dumpData
in interface DataDumpable
public IndentableLineBuffer setIndentation(String indentation)
public IndentableLineBuffer setLineSeparator(String sep)
toString()
.
public IndentableLineBuffer setBaseIndentLevel(int indent_level)
public IndentableLineBuffer setDefaultLineIndentLevel(int indent_level)
public IndentableLineBuffer indent(int indent)
public IndentableLineBuffer indentExisting(int indent)
public IndentableLineBuffer indentCurrentLine(int indent)
public IndentableLineBuffer newLine()
public IndentableLineBuffer newLine(int indent)
public IndentableLineBuffer append(String s)
public IndentableLineBuffer append(StringBuilder sb)
public IndentableLineBuffer append(char c)
Formatter
.
append
in interface Appendable
public IndentableLineBuffer append(CharSequence csq)
Formatter
.
append
in interface Appendable
public IndentableLineBuffer append(CharSequence csq, int start, int end)
Formatter
.
append
in interface Appendable
public IndentableLineBuffer format(String format, Object... args) throws IllegalFormatException, FormatterClosedException
Formatter
, whose output is connected to this IndentableLineBuffer
,
and passes all arguments to its Formatter.format(String, Object...)
method. See there for
a description of the parameters and the format string.
IllegalFormatException
FormatterClosedException
public IndentableLineBuffer format(Locale l, String format, Object... args) throws IllegalFormatException, FormatterClosedException
Formatter
, whose output is connected to this IndentableLineBuffer
,
and passes all arguments to its Formatter.format(Locale, String, Object...)
method. See there for
a description of the parameters and the format string.
IllegalFormatException
FormatterClosedException
public IndentableLineBuffer addLine(String s)
public IndentableLineBuffer addLine(int indent, String s)
public IndentableLineBuffer addLine(StringBuilder sb)
public IndentableLineBuffer addLine(int indent, StringBuilder sb)
public IndentableLineBuffer addLines(IndentableLineBuffer other)
new resulting = this base + new individual = this base + former resulting = this base + other base + former individualAfter this operation the other buffer is pretty messed up. The idea is, the other buffer is merged into this one and then forgotten. If you don't like this,
clone()
the buffer in advance.
public IndentableLineBuffer appendLines(IndentableLineBuffer other)
addLines(IndentableLineBuffer)
, except that the first line of the other line buffer is
appended to the current last line of this line buffer, ignoring the indent level of the other line.
The individual lines are /not/ copied, they are taken over. The other buffer has to be considered destroyed
after this operation. If you don't like this, clone()
the buffer in advance.
public String toString()
toString
in class Object
public IndentableLineBuffer clone()
clone
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |