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[] str)
Constructor, specifying an initial array.
|
TokenBuilder(int i)
Constructor, specifying an initial array size.
|
TokenBuilder(java.lang.String str)
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 to the token:
If extensions are specified, all characters
"%" in the object
string are replaced by the specified extensions.
Extensions can either be tokens (byte arrays) or any other objects,
which will be represented as strings.
If a digit is found after the character "%", it is interpreted
as insertion position.
|
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 str)
str - initial stringpublic TokenBuilder(byte[] str)
str - initial stringpublic 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)
"%" in the object
string are replaced by the specified extensions."%", it is 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