Overview | Package | Class | Use | Tree | Deprecated | 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-09, ISC License, Christian Gruen

Field Summary
`boolean` | `ent` Entity flag.

Constructor Summary
`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.

Method Summary
`TokenBuilder` | `add(byte b)` Adds a single character to the token.
`TokenBuilder` | `add(byte[] b)` Adds a byte array to the token.
`void` | `add(byte[] b, int s, int e)` Adds a partial byte array to the token.
`TokenBuilder` | `add(char ch)` Adds a single character to the token.
`TokenBuilder` | `add(int i)` Adds an integer to the token.
`TokenBuilder` | `add(java.lang.Object str, java.lang.Object... ext)` Replaces all % characters in the input string by the specified extension objects, which can be byte arrays or any other object.
`TokenBuilder` | `add(java.lang.String s)` Adds a string to the token.
`void` | `addUTF(int c)` Adds the specified UTF8 character.
`void` | `chop()` Chops leading and trailing whitespaces.
`byte[]` | `finish()` Returns the token as a byte array.
`TokenBuilder` | `high()` Adds a highlight flag.
`TokenBuilder` | `hl()` Adds a half new line.
`TokenBuilder` | `nl()` Adds a new line.
`TokenBuilder` | `norm()` Adds a norm flag.
`void` | `reset()` Resets the token buffer.
`int` | `size()` Returns the number of entries.
`java.lang.String` | `toString()`

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

Field Detail

### ent

    public boolean ent

  Entity flag.

Constructor Detail

### TokenBuilder

    public TokenBuilder()

  Empty constructor.

### TokenBuilder

    public TokenBuilder(int i)

  Constructor, specifying an initial array size.

  Parameters:
    `i` - size

### TokenBuilder

    public TokenBuilder(java.lang.String str)

  Constructor, specifying an initial string.

  Parameters:
    `str` - initial string

### TokenBuilder

    public TokenBuilder(byte[] str)

  Constructor, specifying an initial array.

  Parameters:
    `str` - initial string

Method Detail

### size

    public int size()

  Returns the number of entries.

  Returns:
    number of entries

### reset

    public void reset()

  Resets the token buffer.

### high

    public TokenBuilder high()

  Adds a highlight flag. This flag is evaluated by the text renderer in the frontend.

  Returns:
    self reference

### norm

    public TokenBuilder norm()

  Adds a norm flag. This flag is evaluated by the text renderer in the frontend.

  Returns:
    self reference

### nl

    public TokenBuilder nl()

  Adds a new line. This flag is evaluated by the text renderer in the frontend.

  Returns:
    self reference

### hl

    public TokenBuilder hl()

  Adds a half new line. This flag is evaluated by the text renderer in the frontend.

  Returns:
    self reference

### add

    public TokenBuilder add(char ch)

  Adds a single character to the token.

  Parameters:
    `ch` - the character to be added
  Returns:
    self reference

### add

    public TokenBuilder add(byte b)

  Adds a single character to the token.

  Parameters:
    `b` - the character to be added
  Returns:
    self reference

### addUTF

    public void addUTF(int c)

  Adds the specified UTF8 character.

  Parameters:
    `c` - the character to be added

### add

    public TokenBuilder add(int i)

  Adds an integer to the token.

  Parameters:
    `i` - the integer to be added
  Returns:
    self reference

### add

    public TokenBuilder add(byte[] b)

  Adds a byte array to the token.

  Parameters:
    `b` - the character array to be added
  Returns:
    self reference

### add

    public void add(byte[] b,
                    int s,
                    int e)

  Adds a partial byte array to the token.

  Parameters:
    `b` - the character array to be added
    `s` - start position
    `e` - end position

### add

    public TokenBuilder add(java.lang.String s)

  Adds a string to the token.

  Parameters:
    `s` - the string to be added
  Returns:
    self reference

### add

    public TokenBuilder add(java.lang.Object str,
                            java.lang.Object... ext)

  Replaces all % characters in the input string by the specified extension objects, which can be byte arrays or any other object. If a digit is found after %, it is interpreted as insertion position.

  Parameters:
    `str` - query information
    `ext` - text text extensions
  Returns:
    self reference

### chop

    public void chop()

  Chops leading and trailing whitespaces.

### finish

    public byte[] finish()

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

  Returns:
    character array

### toString

    public java.lang.String toString()

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

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