org.basex.build
Class MemBuilder

java.lang.Object
  extended by org.basex.core.Progress
      extended by org.basex.build.Builder
          extended by org.basex.build.MemBuilder

public final class MemBuilder
extends Builder

This class creates a memory based database instance.

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

Field Summary
 
Fields inherited from class org.basex.build.Builder
elms, meta, size
 
Constructor Summary
MemBuilder()
           
 
Method Summary
 void addAttr(int n, int s, byte[] v, int d)
          Adds an attribute to the database.
 void addDoc(byte[] tok)
          Adds a document node to the database.
 void addElem(int tok, int s, int dis, int a, boolean n)
          Adds an element node to the database.
 void addText(byte[] tok, int par, byte kind)
          Adds a text node to the database.
 void close()
          Closes open references.
 MemData finish()
          Finishes the build process and returns a database reference.
 MemBuilder init(java.lang.String db)
          Initializes the database construction.
 void setAttValue(int pre, byte[] val)
          Stores an attribute value to the specified table position.
 void setSize(int pre, int val)
          Stores a size value to the specified table position.
 
Methods inherited from class org.basex.build.Builder
build, comment, det, emptyElem, encoding, endDoc, endElem, nodeAndText, pi, prog, startDoc, startElem, startNS, text, tit
 
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
 

Constructor Detail

MemBuilder

public MemBuilder()
Method Detail

init

public MemBuilder init(java.lang.String db)
Description copied from class: Builder
Initializes the database construction.

Specified by:
init in class Builder
Parameters:
db - name of database
Returns:
builder instance

finish

public MemData finish()
               throws java.io.IOException
Description copied from class: Builder
Finishes the build process and returns a database reference.

Specified by:
finish in class Builder
Returns:
data database instance
Throws:
java.io.IOException - in case of parsing or writing problems

close

public void close()
Description copied from class: Builder
Closes open references.

Specified by:
close in class Builder

addDoc

public void addDoc(byte[] tok)
Description copied from class: Builder
Adds a document node to the database.

Specified by:
addDoc in class Builder
Parameters:
tok - the token to be added (tag name or content)

addElem

public void addElem(int tok,
                    int s,
                    int dis,
                    int a,
                    boolean n)
             throws java.io.IOException
Description copied from class: Builder
Adds an element node to the database. This method stores a preliminary size value; if this node has further descendants, Builder.setSize(int, int) has to be called with the final size value.

Specified by:
addElem in class Builder
Parameters:
tok - the tag name reference
s - the tag namespace
dis - distance (relative parent reference)
a - number of attributes
n - element has namespaces
Throws:
java.io.IOException - in case of parsing or writing problems

addAttr

public void addAttr(int n,
                    int s,
                    byte[] v,
                    int d)
Description copied from class: Builder
Adds an attribute to the database.

Specified by:
addAttr in class Builder
Parameters:
n - attribute name
s - namespace
v - attribute value
d - distance (relative parent reference)

addText

public void addText(byte[] tok,
                    int par,
                    byte kind)
Description copied from class: Builder
Adds a text node to the database.

Specified by:
addText in class Builder
Parameters:
tok - the token to be added (tag name or content)
par - distance (relative parent reference)
kind - the node kind

setSize

public void setSize(int pre,
                    int val)
Description copied from class: Builder
Stores a size value to the specified table position.

Specified by:
setSize in class Builder
Parameters:
pre - pre reference
val - value to be stored

setAttValue

public void setAttValue(int pre,
                        byte[] val)
Description copied from class: Builder
Stores an attribute value to the specified table position.

Specified by:
setAttValue in class Builder
Parameters:
pre - pre reference
val - value to be stored