public class TextBuilder extends Object implements Cloneable
Modifier and Type | Class and Description |
---|---|
protected static class |
TextBuilder.StrBuf
A data structure used to store both character based content and it's
binary byte array.
|
Modifier and Type | Field and Description |
---|---|
protected StringBuilder |
__buffer
The internal buffer
|
protected TextBuilder |
__caller
The caller text builder.
|
Constructor and Description |
---|
TextBuilder()
Construct a root text builder
|
TextBuilder(TextBuilder caller)
Construct a chained text builder with a
caller() instance |
Modifier and Type | Method and Description |
---|---|
protected void |
__append(boolean b)
Append a boolean to internal buffer
|
protected void |
__append(byte b)
Append a byte to internal buffer
|
protected void |
__append(char c)
Append a char to internal buffer
|
protected void |
__append(double d)
Append a double to internal buffer
|
protected void |
__append(float f)
Append a float to internal buffer
|
protected void |
__append(int i)
Append an integer to internal buffer
|
protected void |
__append(long l)
Append a long to internal buffer
|
protected void |
__append(Object o)
Append a object to internal buffer or output (os or writer).
|
protected void |
__append(TextBuilder.StrBuf wrapper)
Append a
TextBuilder.StrBuf content into the buffer |
StringBuilder |
__getBuffer()
Alias of
buffer() |
void |
__setBuffer(StringBuilder buffer)
Set the internal buffer to this instance or if the
caller() exists, to the caller instance |
StringBuilder |
buffer()
Return the internal buffer of the text builder.
|
TextBuilder |
build()
Sub class could implement this method to append the generated
source code to the buffer
|
protected ITemplate |
caller()
Return the caller in
ITemplate type |
TextBuilder |
clone(TextBuilder caller)
return a clone of this TextBuilder instance
|
StringBuilder |
getSelfOut()
Get the buffer out from this instance
|
TextBuilder |
np(Object o)
Print an new line break followed by an object
|
TextBuilder |
p(boolean b)
Print a boolean to internal buffer or output (os or writer)
|
TextBuilder |
p(byte b)
Print a byte to internal buffer or output (os or writer)
|
TextBuilder |
p(char c)
Print a char to internal buffer or output (os or writer)
|
TextBuilder |
p(double d)
Print a double to internal buffer or output (os or writer)
|
TextBuilder |
p(float f)
Print a float to internal buffer or output (os or writer)
|
TextBuilder |
p(int i)
Print an integer to internal buffer or output (os or writer)
|
TextBuilder |
p(long l)
Print a long to internal buffer or output (os or writer)
|
TextBuilder |
p(Object o)
Print a
Object to internal buffer or output (os or writer)
null object will not be printed |
TextBuilder |
p(TextBuilder.StrBuf wrapper)
Print a
TextBuilder.StrBuf to internal buffer or output (os or writer)
null object will not be printed |
TextBuilder |
p2t(Object o)
Print an object followed by two tabs
\t |
TextBuilder |
p2tn(Object o)
Print an object followed by 2 tabs
\t and an line break |
TextBuilder |
p3t(Object o)
Print an object followed by 3 tabs
\t |
TextBuilder |
p3tn(Object o)
Print an object followed by 3 tabs
\t and an line break |
TextBuilder |
p4t(Object o)
Print an object followed by 4 tabs
\t |
TextBuilder |
p4tn(Object o)
Print an object followed by 4 tabs
\t and an line break |
TextBuilder |
pn()
Print an new line break
|
TextBuilder |
pn(Object o)
Print an object followed by an new line break
|
TextBuilder |
pt(Object o)
Print an object followed by a tab
\t |
TextBuilder |
ptn(Object o)
Print an object followed by a tab
\t and an new line break |
void |
setSelfOut(StringBuilder buffer)
Set the internal buffer to this instance
|
String |
toString()
Return the internal buffer or caller's internal buffer if it is null
|
protected StringBuilder __buffer
protected TextBuilder __caller
ITemplate
instancepublic TextBuilder()
public TextBuilder(TextBuilder caller)
caller()
instancecaller
- public StringBuilder buffer()
caller()
instance's bufferStringBuilder
public StringBuilder __getBuffer()
buffer()
StringBuilder
public void __setBuffer(StringBuilder buffer)
caller()
exists, to the caller instancebuffer
- public void setSelfOut(StringBuilder buffer)
buffer
- public StringBuilder getSelfOut()
StringBuilder
protected void __append(TextBuilder.StrBuf wrapper)
TextBuilder.StrBuf
content into the bufferwrapper
- public TextBuilder p(TextBuilder.StrBuf wrapper)
TextBuilder.StrBuf
to internal buffer or output (os or writer)
null
object will not be printedwrapper
- protected void __append(Object o)
o
- public final TextBuilder p(Object o)
Object
to internal buffer or output (os or writer)
null
object will not be printedo
- protected void __append(char c)
c
- public final TextBuilder p(char c)
c
- protected void __append(byte b)
b
- public final TextBuilder p(byte b)
b
- protected void __append(int i)
i
- public final TextBuilder p(int i)
i
- protected void __append(long l)
l
- public final TextBuilder p(long l)
l
- protected void __append(float f)
f
- public final TextBuilder p(float f)
f
- protected void __append(double d)
d
- public final TextBuilder p(double d)
d
- protected void __append(boolean b)
b
- public final TextBuilder p(boolean b)
b
- public final TextBuilder pn(Object o)
o
- public final TextBuilder pn()
public final TextBuilder np(Object o)
o
- public TextBuilder pt(Object o)
\t
o
- public TextBuilder ptn(Object o)
\t
and an new line breako
- public TextBuilder p2t(Object o)
\t
o
- public TextBuilder p2tn(Object o)
\t
and an line breako
- public TextBuilder p3t(Object o)
\t
o
- public TextBuilder p3tn(Object o)
\t
and an line breako
- public TextBuilder p4t(Object o)
\t
o
- public TextBuilder p4tn(Object o)
\t
and an line breako
- public TextBuilder build()
public String toString()
public TextBuilder clone(TextBuilder caller)
caller
- Copyright © 2015. All Rights Reserved.