org.basex.build
Class MemBuilder

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

public final class MemBuilder
extends Builder

This class creates a database instance in main memory. The storage layout is described in the Data class.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 
Fields inherited from class org.basex.core.Proc
listen, updating
 
Constructor Summary
MemBuilder(java.lang.String nm, Parser parse)
          Constructor.
 
Method Summary
protected  void addAttr(int nm, byte[] value, int dist, int uri)
          Adds an attribute to the database.
protected  void addDoc(byte[] value)
          Adds a document node to the database.
protected  void addElem(int dist, int nm, int asize, int uri, boolean ne)
          Adds an element node to the database.
protected  void addText(byte[] value, int dist, byte kind)
          Adds a text node to the database.
 MemData build()
          Builds the database.
static MemData build(Parser parser)
          Builds a main memory database instance.
static MemData build(java.lang.String name, Parser parser)
          Builds a main memory database instance with the specified name.
 void close()
          Closes open references.
 Data data()
          Returns the data reference.
 void init()
          Initializes the builder.
protected  void setSize(int pre, int size)
          Stores a size value to the specified table position.
 
Methods inherited from class org.basex.build.Builder
closeDoc, closeElem, comment, det, emptyElem, encoding, openDoc, openElem, pi, prog, text, tit
 
Methods inherited from class org.basex.core.Proc
abort, checkStop, databases, detail, listen, proc, progress, registered, registered, startTimeout, stop, stopTimeout, title
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemBuilder

public MemBuilder(java.lang.String nm,
                  Parser parse)
Constructor.

Parameters:
nm - name of database
parse - parser
Method Detail

build

public static MemData build(Parser parser)
                     throws java.io.IOException
Builds a main memory database instance.

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

build

public static MemData build(java.lang.String name,
                            Parser parser)
                     throws java.io.IOException
Builds a main memory database instance with the specified name.

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

build

public MemData build()
              throws java.io.IOException
Description copied from class: Builder
Builds the database.

Specified by:
build in class Builder
Returns:
data database instance
Throws:
java.io.IOException - I/O exception

init

public void init()
Initializes the builder.


data

public Data data()
Returns the data reference.

Returns:
data reference

close

public void close()
           throws java.io.IOException
Description copied from class: Builder
Closes open references.

Specified by:
close in class Builder
Throws:
java.io.IOException - I/O exception

addDoc

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

Specified by:
addDoc in class Builder
Parameters:
value - name of the document

addElem

protected void addElem(int dist,
                       int nm,
                       int asize,
                       int uri,
                       boolean ne)
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) must be called to set the final size value.

Specified by:
addElem in class Builder
Parameters:
dist - distance to parent
nm - the tag name reference
asize - number of attributes
uri - namespace uri reference
ne - namespace flag

addAttr

protected void addAttr(int nm,
                       byte[] value,
                       int dist,
                       int uri)
Description copied from class: Builder
Adds an attribute to the database.

Specified by:
addAttr in class Builder
Parameters:
nm - attribute name
value - attribute value
dist - distance to parent
uri - namespace uri reference

addText

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

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

setSize

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

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