public final class TokenBuilder
extends java.lang.Object
StringBuilder.| Modifier and Type | Field and Description |
|---|---|
static byte |
HLINE
Half new line.
|
static byte |
MARK
Mark flag.
|
static byte |
NLINE
New line.
|
| Constructor and Description |
|---|
TokenBuilder()
Empty constructor.
|
TokenBuilder(byte[] t)
Constructor, specifying an initial token.
|
TokenBuilder(int i)
Constructor, specifying an initial array size.
|
TokenBuilder(java.lang.String s)
Constructor, specifying an initial string.
|
| Modifier and Type | Method and Description |
|---|---|
TokenBuilder |
add(byte[] b)
Adds a byte array to the token.
|
TokenBuilder |
add(byte[] b,
int s,
int e)
Adds a partial byte array to the token.
|
TokenBuilder |
add(int ch)
Adds the specified UTF8 character.
|
TokenBuilder |
add(java.lang.String s)
Adds a string to the token.
|
TokenBuilder |
addByte(byte b)
Adds a byte to the token.
|
TokenBuilder |
addExt(java.lang.Object str,
java.lang.Object... ext)
Adds the string representation of an object:
objects of type
Throwable are converted to a string representation
via Util.message(java.lang.Throwable).
objects of type Class are converted via Util.name(Class).
null references are replaced by the string "null".
byte arrays are directly inserted as tokens.
for all other typed, Object.toString() is called.
The specified string may contain "%" characters as place holders. |
TokenBuilder |
addLong(long i)
Adds a number to the token.
|
TokenBuilder |
addSep(java.lang.Object[] s,
java.lang.String sep)
Adds multiple strings to the token, separated by the specified string.
|
TokenBuilder |
bold()
Adds a bold flag.
|
int |
cl(int p)
Returns the codepoint length of the specified byte.
|
int |
cp(int p)
Returns the codepoint at the specified position.
|
void |
delete(int p,
int s)
Deletes bytes from the token.
|
byte[] |
finish()
Returns the token as byte array.
|
byte |
get(int p)
Returns the byte at the specified position.
|
TokenBuilder |
hline()
Adds a half new line.
|
TokenBuilder |
insert(int pos,
int ch)
Inserts the specified UTF8 character.
|
boolean |
isEmpty()
Tests if the token is empty.
|
TokenBuilder |
nline()
Adds a new line.
|
TokenBuilder |
norm()
Adds a norm flag.
|
TokenBuilder |
reset()
Resets the token buffer.
|
void |
set(byte b,
int p)
Sets a byte at the specified position.
|
int |
size()
Returns the number of bytes.
|
void |
size(int s)
Sets the number of bytes.
|
java.lang.String |
toString() |
TokenBuilder |
trim()
Trims leading and trailing whitespaces.
|
public static final byte HLINE
public static final byte MARK
public static final byte NLINE
public TokenBuilder()
public TokenBuilder(int i)
i - sizepublic TokenBuilder(java.lang.String s)
s - initial stringpublic TokenBuilder(byte[] t)
t - initial tokenpublic int size()
public void size(int s)
s - number of bytespublic boolean isEmpty()
public TokenBuilder reset()
public TokenBuilder bold()
public TokenBuilder norm()
public TokenBuilder nline()
public TokenBuilder hline()
public TokenBuilder add(int ch)
ch - the character to be addedpublic TokenBuilder insert(int pos, int ch)
pos - insertion indexch - the character to be addedpublic int cp(int p)
p - positionpublic int cl(int p)
p - positionpublic byte get(int p)
p - positionpublic void set(byte b,
int p)
b - byte to be setp - positionpublic void delete(int p,
int s)
p - positions - number of bytes to be removedpublic TokenBuilder addByte(byte b)
ByteList instances should be preferred
for the construction of pure byte arrays.b - the byte to be addedpublic TokenBuilder addLong(long i)
i - the integer to be addedpublic TokenBuilder add(byte[] b)
b - the character array to be addedpublic TokenBuilder add(byte[] b, int s, int e)
b - the character array to be addeds - start positione - end positionpublic TokenBuilder add(java.lang.String s)
s - the string to be addedpublic TokenBuilder addSep(java.lang.Object[] s, java.lang.String sep)
s - the string to be addedsep - separatorpublic TokenBuilder addExt(java.lang.Object str, java.lang.Object... ext)
Throwable are converted to a string representation
via Util.message(java.lang.Throwable).Class are converted via Util.name(Class).null references are replaced by the string "null".Object.toString() is called."%" characters as place holders.
All place holders will be replaced by the specified extensions. If a digit is
specified after the place holder character, it will be interpreted as insertion
position.str - string to be extendedext - optional extensionspublic TokenBuilder trim()
public byte[] finish()
public java.lang.String toString()
toString in class java.lang.Object