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.build
Class Builder

    java.lang.Object
      org.basex.core.Progress
          org.basex.build.Builder

Direct Known Subclasses:
  DiskBuilder, MemBuilder, NativeBuilder

    public abstract class Builder

extends Progress

This class provides an interface for building database instances. The specified `Parser` send events to this class whenever nodes are to be added or closed. The builder implementation decides whether the nodes are stored on disk or kept in memory.

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

Field Summary
`MetaData` | `meta` Meta data on built database.
`Parser` | `parser` Parser instance.

Method Summary
`abstract void` | `addAttr(int n, int s, byte[] v, int d)` Adds an attribute to the database.
`abstract void` | `addDoc(byte[] tok)` Adds a document node to the database.
`abstract void` | `addElem(int tok, int tns, int dis, int as, boolean n)` Adds an element node to the database.
`abstract void` | `addText(byte[] tok, int dis, byte kind)` Adds a text node to the database.
`Data` | `build()` Builds the database by running the specified parser.
`Data` | `build(java.lang.String db)` Builds the database by running the specified parser.
`abstract void` | `close()` Closes open references.
`void` | `comment(TokenBuilder com)` Stores a comment.
`java.lang.String` | `det()` Returns short information on this process.
`void` | `emptyElem(byte[] tag, Atts att)` Stores an empty element.
`void` | `encoding(java.lang.String enc)` Sets the document encoding.
`void` | `endDoc()` Closes a document node.
`void` | `endElem(byte[] tag)` Closes an element.
`abstract void` | `init(java.lang.String db)` Initializes the database construction.
`void` | `nodeAndText(byte[] tag, Atts att, byte[] txt)` Convenience method for adding an element and text node.
`void` | `pi(TokenBuilder pi)` Stores a processing instruction.
`double` | `prog()` Returns progress information.
`abstract void` | `setAttValue(int pre, byte[] val)` Stores an attribute value to the specified table position.
`abstract void` | `setSize(int pre, int val)` Stores a size value to the specified table position.
`void` | `startDoc(byte[] doc)` Opens a document node.
`int` | `startElem(byte[] tag, Atts att)` Opens a new element node.
`void` | `startNS(byte[] name, byte[] val)` Adds a new namespace; called by the building instance.
`void` | `text(TokenBuilder t, boolean w)` Stores a text node.
`java.lang.String` | `tit()` Returns short information on this process.

Methods inherited from class org.basex.core.Progress
`checkStop, detail, progress, progress, stop, title`

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

Field Detail

### parser

    public final Parser parser

  Parser instance.

### meta

    public MetaData meta

  Meta data on built database.

Method Detail

### init

    public abstract void init(java.lang.String db)
                       throws java.io.IOException

  Initializes the database construction.

  Parameters:
    `db` - name of database
  Throws:
    `java.io.IOException` - I/O exception

### close

    public abstract void close()
                        throws java.io.IOException

  Closes open references.

  Throws:
    `java.io.IOException` - I/O exception

### addDoc

    public abstract void addDoc(byte[] tok)
                         throws java.io.IOException

  Adds a document node to the database.

  Parameters:
    `tok` - the token to be added (tag name or content)
  Throws:
    `java.io.IOException` - I/O exception

### addElem

    public abstract void addElem(int tok,
                                 int tns,
                                 int dis,
                                 int as,
                                 boolean n)
                          throws java.io.IOException

  Adds an element node to the database. This method stores a preliminary size value; if this node has further descendants, `setSize(int, int)` has to be called with the final size value.

  Parameters:
    `tok` - the tag name reference
    `tns` - the tag namespace
    `dis` - distance (relative parent reference)
    `as` - number of attributes
    `n` - element has namespaces
  Throws:
    `java.io.IOException` - I/O exception

### addAttr

    public abstract void addAttr(int n,
                                 int s,
                                 byte[] v,
                                 int d)
                          throws java.io.IOException

  Adds an attribute to the database.

  Parameters:
    `n` - attribute name
    `s` - namespace
    `v` - attribute value
    `d` - distance (relative parent reference)
  Throws:
    `java.io.IOException` - I/O exception

### addText

    public abstract void addText(byte[] tok,
                                 int dis,
                                 byte kind)
                          throws java.io.IOException

  Adds a text node to the database.

  Parameters:
    `tok` - the token to be added (tag name or content)
    `dis` - distance (relative parent reference)
    `kind` - the node kind
  Throws:
    `java.io.IOException` - I/O exception

### setSize

    public abstract void setSize(int pre,
                                 int val)
                          throws java.io.IOException

  Stores a size value to the specified table position.

  Parameters:
    `pre` - pre reference
    `val` - value to be stored
  Throws:
    `java.io.IOException` - I/O exception

### setAttValue

    public abstract void setAttValue(int pre,
                                     byte[] val)
                              throws java.io.IOException

  Stores an attribute value to the specified table position.

  Parameters:
    `pre` - pre reference
    `val` - value to be stored
  Throws:
    `java.io.IOException` - I/O exception

### build

    public final Data build()
                     throws java.io.IOException

  Builds the database by running the specified parser.

  Returns:
    data database instance
  Throws:
    `java.io.IOException` - I/O exception

### build

    public final Data build(java.lang.String db)
                     throws java.io.IOException

  Builds the database by running the specified parser.

  Parameters:
    `db` - name of database
  Returns:
    data database instance
  Throws:
    `java.io.IOException` - I/O exception

### startDoc

    public final void startDoc(byte[] doc)
                        throws java.io.IOException

  Opens a document node.

  Parameters:
    `doc` - document name
  Throws:
    `java.io.IOException` - I/O exception

### endDoc

    public final void endDoc()
                      throws java.io.IOException

  Closes a document node.

  Throws:
    `java.io.IOException` - I/O exception

### startNS

    public final void startNS(byte[] name,
                              byte[] val)

  Adds a new namespace; called by the building instance.

  Parameters:
    `name` - the attribute name to be processed
    `val` - attribute value

### startElem

    public final int startElem(byte[] tag,
                               Atts att)
                        throws java.io.IOException

  Opens a new element node.

  Parameters:
    `tag` - tag name
    `att` - attributes
  Returns:
    preValue of the created node
  Throws:
    `java.io.IOException` - I/O exception

### emptyElem

    public final void emptyElem(byte[] tag,
                                Atts att)
                         throws java.io.IOException

  Stores an empty element.

  Parameters:
    `tag` - tag name
    `att` - attributes
  Throws:
    `java.io.IOException` - I/O exception

### endElem

    public final void endElem(byte[] tag)
                       throws java.io.IOException

  Closes an element.

  Parameters:
    `tag` - tag name
  Throws:
    `java.io.IOException` - I/O exception

### text

    public final void text(TokenBuilder t,
                           boolean w)
                    throws java.io.IOException

  Stores a text node.

  Parameters:
    `t` - text value
    `w` - whitespace flag
  Throws:
    `java.io.IOException` - I/O exception

### comment

    public final void comment(TokenBuilder com)
                       throws java.io.IOException

  Stores a comment.

  Parameters:
    `com` - comment text
  Throws:
    `java.io.IOException` - I/O exception

### pi

    public final void pi(TokenBuilder pi)
                  throws java.io.IOException

  Stores a processing instruction.

  Parameters:
    `pi` - processing instruction name and value
  Throws:
    `java.io.IOException` - I/O exception

### encoding

    public final void encoding(java.lang.String enc)

  Sets the document encoding.

  Parameters:
    `enc` - encoding

### nodeAndText

    public final void nodeAndText(byte[] tag,
                                  Atts att,
                                  byte[] txt)
                           throws java.io.IOException

  Convenience method for adding an element and text node.

  Parameters:
    `tag` - the tag to be processed
    `att` - attributes
    `txt` - text node
  Throws:
    `java.io.IOException` - I/O exception

### tit

    public final java.lang.String tit()

  Description copied from class: `Progress`
  Returns short information on this process. Can be overwritten to give more detailed information.

  Overrides:
    `tit` in class `Progress`
  Returns:
    header information

### det

    public final java.lang.String det()

  Description copied from class: `Progress`
  Returns short information on this process.

  Overrides:
    `det` in class `Progress`
  Returns:
    header information

### prog

    public final double prog()

  Description copied from class: `Progress`
  Returns progress information. Can be overwritten to give more detailed information.

  Overrides:
    `prog` in class `Progress`
  Returns:
    header information

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