Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.basex.util
Class TokenBuilder

    java.lang.Object
      org.basex.util.TokenBuilder

    public final class TokenBuilder

extends java.lang.Object

This class serves as an efficient constructor for byte arrays. It bears some resemblance to Java's `StringBuilder`.

Author:
  Workgroup DBIS, University of Konstanz 2005-07, ISC License, Christian Gruen

Field Summary
`boolean` | `ent` Entity flag.
`int` | `size` Current token size.

Constructor Summary
`TokenBuilder()` Empty constructor.
`TokenBuilder(char ch)` Constructor, specifying an initial character.
`TokenBuilder(java.lang.String str)` Constructor, specifying an initial string.

Method Summary
`void` | `add(byte b)` Adds a single character to the token.
`void` | `add(byte[] b)` Adds a character array to the token.
`void` | `add(char ch)` Adds a single character to the token.
`void` | `add(int i)` Adds an integer to the token.
`void` | `add(java.lang.String s)` Adds a string to the token.
`void` | `add(java.lang.String string, java.lang.Object... ext)` Adds some query information.
`void` | `addUTF(int c)` Adds the specified UTF8 character.
`byte[]` | `finish()` Returns the token as a byte array.
`void` | `insert(byte b)` Inserts a single character at the beginning of the token.
`void` | `replace(byte b, int pos)` Replaces a character at the specified position.
`void` | `reset()` Resets the token buffer.
`java.lang.String` | `toString()`
`void` | `trim()` Chops trailing whitespaces.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### ent

    public boolean ent

  Entity flag.

### size

    public int size

  Current token size.

Constructor Detail

### TokenBuilder

    public TokenBuilder()

  Empty constructor.

### TokenBuilder

    public TokenBuilder(char ch)

  Constructor, specifying an initial character.

  Parameters:
    `ch` - first character

### TokenBuilder

    public TokenBuilder(java.lang.String str)

  Constructor, specifying an initial string.

  Parameters:
    `str` - initial string

Method Detail

### add

    public void add(byte b)

  Adds a single character to the token.

  Parameters:
    `b` - the character to be added

### add

    public void add(byte[] b)

  Adds a character array to the token.

  Parameters:
    `b` - the character array to be added

### add

    public void add(char ch)

  Adds a single character to the token.

  Parameters:
    `ch` - the character to be added

### add

    public void add(int i)

  Adds an integer to the token.

  Parameters:
    `i` - the integer to be added

### add

    public void add(java.lang.String s)

  Adds a string to the token.

  Parameters:
    `s` - the string to be added

### add

    public void add(java.lang.String string,
                    java.lang.Object... ext)

  Adds some query information.

  Parameters:
    `string` - query information
    `ext` - text text extensions

### addUTF

    public void addUTF(int c)

  Adds the specified UTF8 character.

  Parameters:
    `c` - the character to be added

### finish

    public byte[] finish()

  Returns the token as a byte array. Unused array bytes are chopped before the token is returned.

  Returns:
    character array

### insert

    public void insert(byte b)

  Inserts a single character at the beginning of the token. Use it carefully; might get pretty slow.

  Parameters:
    `b` - the character to be added

### replace

    public void replace(byte b,
                        int pos)

  Replaces a character at the specified position.

  Parameters:
    `b` - the character to be set
    `pos` - position

### reset

    public void reset()

  Resets the token buffer.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### trim

    public void trim()

  Chops trailing whitespaces.

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD