org.basex.build
Class Builder

java.lang.Object
  extended by org.basex.core.Proc
      extended by org.basex.build.Builder
Direct Known Subclasses:
DiskBuilder, EmptyBuilder, MemBuilder

public abstract class Builder
extends Proc

This class provides an interface for building database instances. The specified Parser sends 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:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 
Fields inherited from class org.basex.core.Proc
listen, updating
 
Method Summary
protected abstract  void addAttr(int nm, byte[] value, int dist, int uri)
          Adds an attribute to the database.
protected abstract  void addDoc(byte[] value)
          Adds a document node to the database.
protected abstract  void addElem(int dist, int nm, int asize, int uri, boolean ne)
          Adds an element node to the database.
protected abstract  void addText(byte[] value, int dist, byte kind)
          Adds a text node to the database.
abstract  Data build()
          Builds the database.
abstract  void close()
          Closes open references.
 void closeDoc()
          Closes a document node.
 void closeElem()
          Closes an element.
 void comment(byte[] value)
          Stores a comment.
 java.lang.String det()
          Returns short information on this process.
 void emptyElem(byte[] nm, Atts att, Atts nsp)
          Stores an empty element.
 void encoding(java.lang.String enc)
          Sets the document encoding.
 void openDoc(byte[] value)
          Opens a document node.
 void openElem(byte[] nm, Atts att, Atts nsp)
          Opens a new element node.
 void pi(byte[] pi)
          Stores a processing instruction.
 double prog()
          Returns a progress value (0 - 1).
protected abstract  void setSize(int pre, int size)
          Stores a size value to the specified table position.
 void text(byte[] value)
          Stores a text node.
protected  java.lang.String tit()
          Returns short information on this process.
 
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
 

Method Detail

openDoc

public final void openDoc(byte[] value)
                   throws java.io.IOException
Opens a document node.

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

closeDoc

public final void closeDoc()
                    throws java.io.IOException
Closes a document node.

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

openElem

public final void openElem(byte[] nm,
                           Atts att,
                           Atts nsp)
                    throws java.io.IOException
Opens a new element node.

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

emptyElem

public final void emptyElem(byte[] nm,
                            Atts att,
                            Atts nsp)
                     throws java.io.IOException
Stores an empty element.

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

closeElem

public final void closeElem()
                     throws java.io.IOException
Closes an element.

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

text

public final void text(byte[] value)
                throws java.io.IOException
Stores a text node.

Parameters:
value - text value
Throws:
java.io.IOException - I/O exception

comment

public final void comment(byte[] value)
                   throws java.io.IOException
Stores a comment.

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

pi

public final void pi(byte[] 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

tit

protected final java.lang.String tit()
Description copied from class: Proc
Returns short information on this process. Can be overwritten to give more detailed information.

Overrides:
tit in class Proc
Returns:
header information

det

public final java.lang.String det()
Description copied from class: Proc
Returns short information on this process.

Overrides:
det in class Proc
Returns:
header information

prog

public final double prog()
Description copied from class: Proc
Returns a progress value (0 - 1). Can be overwritten to give more detailed information.

Overrides:
prog in class Proc
Returns:
header information

build

public abstract Data build()
                    throws java.io.IOException
Builds the database.

Returns:
data database instance
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

protected abstract void addDoc(byte[] value)
                        throws java.io.IOException
Adds a document node to the database.

Parameters:
value - name of the document
Throws:
java.io.IOException - I/O exception

addElem

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

Parameters:
dist - distance to parent
nm - the tag name reference
asize - number of attributes
uri - namespace uri reference
ne - namespace flag
Throws:
java.io.IOException - I/O exception

addAttr

protected abstract void addAttr(int nm,
                                byte[] value,
                                int dist,
                                int uri)
                         throws java.io.IOException
Adds an attribute to the database.

Parameters:
nm - attribute name
value - attribute value
dist - distance to parent
uri - namespace uri reference
Throws:
java.io.IOException - I/O exception

addText

protected abstract void addText(byte[] value,
                                int dist,
                                byte kind)
                         throws java.io.IOException
Adds a text node to the database.

Parameters:
value - the token to be added (tag name or content)
dist - distance to parent
kind - the node kind
Throws:
java.io.IOException - I/O exception

setSize

protected abstract void setSize(int pre,
                                int size)
                         throws java.io.IOException
Stores a size value to the specified table position.

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