|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.basex.util.TokenBuilder
public final class TokenBuilder
This class serves as an efficient constructor for Tokens
.
It bears some resemblance to Java's StringBuilder
.
Field Summary | |
---|---|
static byte |
BOLD
Bold flag. |
static byte |
HLINE
Half new line. |
static byte |
MARK
Mark flag. |
static byte |
NLINE
New line. |
static byte |
NORM
Standard flag. |
static byte |
ULINE
Underline flag. |
Constructor Summary | |
---|---|
TokenBuilder()
Empty constructor. |
|
TokenBuilder(byte[] token)
Constructor, specifying an initial token. |
|
TokenBuilder(int capacity)
Constructor, specifying an initial internal array size. |
|
TokenBuilder(java.lang.String string)
Constructor, specifying an initial string. |
Method Summary | |
---|---|
TokenBuilder |
add(byte[] value)
Adds a byte array to the token. |
TokenBuilder |
add(byte[] value,
int start,
int end)
Adds part of a byte array to the token. |
TokenBuilder |
add(int cp)
Adds the specified UTF8 codepoint. |
TokenBuilder |
add(java.lang.String string)
Adds a string to the token. |
TokenBuilder |
addByte(byte value)
Adds a byte to the token. |
TokenBuilder |
addExt(java.lang.Object object,
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 |
addInt(int value)
Adds an integer value to the token. |
TokenBuilder |
addLong(long value)
Adds a number to the token. |
TokenBuilder |
addSep(java.lang.Object[] objects,
java.lang.String sep)
Adds multiple strings to the token, separated by the specified string. |
TokenBuilder |
bold()
Adds a bold flag. |
int |
cl(int pos)
Returns the length of the codepoints stored at the specified position. |
int |
cp(int pos)
Returns the codepoint stored at the specified position. |
void |
delete(int pos,
int length)
Deletes bytes from the token. |
byte[] |
finish()
Returns the token as byte array. |
byte |
get(int pos)
Returns the byte stored at the specified position. |
TokenBuilder |
hline()
Adds a half new line. |
TokenBuilder |
insert(int pos,
int cp)
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(int pos,
byte value)
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. |
TokenBuilder |
uline()
Adds an underline toggle flag. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final byte HLINE
public static final byte BOLD
public static final byte NORM
public static final byte MARK
public static final byte ULINE
public static final byte NLINE
Constructor Detail |
---|
public TokenBuilder()
public TokenBuilder(int capacity)
capacity
- initial array capacitypublic TokenBuilder(java.lang.String string)
string
- initial stringpublic TokenBuilder(byte[] token)
token
- initial tokenMethod Detail |
---|
public int size()
public void size(int s)
s
- number of bytespublic boolean isEmpty()
public TokenBuilder reset()
public TokenBuilder bold()
public TokenBuilder uline()
public TokenBuilder norm()
public TokenBuilder nline()
public TokenBuilder hline()
public TokenBuilder add(int cp)
cp
- the codepoint to be added
public TokenBuilder insert(int pos, int cp)
pos
- insertion positioncp
- the character to be added
public int cp(int pos)
pos
- position
public int cl(int pos)
pos
- position
public byte get(int pos)
pos
- position
public void set(int pos, byte value)
value
- byte to be setpos
- positionpublic void delete(int pos, int length)
pos
- positionlength
- number of bytes to be removedpublic TokenBuilder addByte(byte value)
ByteList
instances should be preferred
for the construction of pure byte arrays.
value
- the byte to be added
public TokenBuilder addInt(int value)
value
- value to be added
public TokenBuilder addLong(long value)
value
- value to be added
public TokenBuilder add(byte[] value)
value
- the byte array to be added
public TokenBuilder add(byte[] value, int start, int end)
value
- the byte array to be addedstart
- start positionend
- end position
public TokenBuilder add(java.lang.String string)
string
- the string to be added
public TokenBuilder addSep(java.lang.Object[] objects, java.lang.String sep)
objects
- the object to be addedsep
- separator string
public TokenBuilder addExt(java.lang.Object object, 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.
object
- string to be extendedext
- optional extensions
public TokenBuilder trim()
public byte[] finish()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |