public final class PaddingStringBuffer extends Object
String
, long
and int
s
to the buffer.
Note: This class counts from 1, not 0.
It uses a StringBuffer behind the scenes.
To write a string with multiple lines, it is advisible to use the
newline()
function. Regular appending of strings with
newlines (\n) character should be safe though. Right appending of strings
with such characters is not safe.
Modifier and Type | Field and Description |
---|---|
protected StringBuffer |
buffer |
protected int |
linePos |
Constructor and Description |
---|
PaddingStringBuffer()
Create a new PaddingStringBuffer
|
Modifier and Type | Method and Description |
---|---|
PaddingStringBuffer |
append(int i)
append an
int to the buffer. |
PaddingStringBuffer |
append(long lo)
append a
long to the buffer. |
PaddingStringBuffer |
append(String string)
append a string directly to the buffer
|
PaddingStringBuffer |
newline()
Forces a new line in the buffer.
|
PaddingStringBuffer |
padTo(int col)
Pad to a given column.
|
PaddingStringBuffer |
raAppend(int col,
int i)
Append an
int right-aligned to the given column. |
PaddingStringBuffer |
raAppend(int col,
long lo)
Append a
long , right-aligned to the given column. |
PaddingStringBuffer |
raAppend(int col,
String string)
Append a string, right-aligned to the given columm.
|
void |
reset()
reset the buffer back to empty
|
String |
toString() |
protected StringBuffer buffer
protected int linePos
public PaddingStringBuffer()
public PaddingStringBuffer append(String string)
string
- the string to appendpublic PaddingStringBuffer raAppend(int col, String string)
col
- the column to right-align tostring
- the string, must not contain multiple lines.public PaddingStringBuffer padTo(int col)
col
- i
.public PaddingStringBuffer append(int i)
int
to the buffer.i
- the int to appendi
appended.public PaddingStringBuffer raAppend(int col, int i)
int
right-aligned to the given column. If the
buffer length is already greater than the column specified, it simply
appends the int
.col
- the column to right-align toi
- the int to appendpublic PaddingStringBuffer append(long lo)
long
to the buffer.lo
- the long
to appendpublic PaddingStringBuffer raAppend(int col, long lo)
long
, right-aligned to the given column. If the
buffer length is already greater than the column specified, it simply
appends the long
.col
- the column to right-align tolo
- the long to appendpublic void reset()
public PaddingStringBuffer newline()
Copyright © 2003-2014 Internet Archive. All Rights Reserved.