org.basex.build
Class Builder

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

public abstract class Builder
extends Progress

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.Progress
listen, updating
 
Method Summary
abstract  Data build()
          Builds the database.
abstract  void close()
          Closes open references.
 void comment(byte[] value)
          Stores a comment.
 java.lang.String det()
          Returns short information on this process.
 void emptyElem(byte[] nm, Atts att)
          Stores an empty element.
 void encoding(java.lang.String enc)
          Sets the document encoding.
 void endDoc()
          Closes a document node.
 void endElem()
          Closes an element.
 void pi(byte[] pi)
          Stores a processing instruction.
 double prog()
          Returns a progress value (0 - 1).
 void startDoc(byte[] value)
          Opens a document node.
 void startElem(byte[] nm, Atts att)
          Opens a new element node.
 void startNS(byte[] pref, byte[] uri)
          Adds a new namespace; called by the building instance.
 void text(byte[] value)
          Stores a text node.
 
Methods inherited from class org.basex.core.Progress
checkStop, detail, listen, progress, startTimeout, stop, stopTimeout, title
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

startDoc

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

Parameters:
value - 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[] pref,
                          byte[] uri)
Adds a new namespace; called by the building instance.

Parameters:
pref - the namespace prefix
uri - namespace uri

startElem

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

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

emptyElem

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

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

endElem

public final void endElem()
                   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

det

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

Returns:
header information

prog

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

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