org.basex.build
Class Builder

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

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-10, ISC License, Christian Gruen

Field Summary
 MetaData meta
          Meta data on built database.
 Parser parser
          Parser instance.
 
Method Summary
 Data build()
          Builds the database by running the specified parser.
abstract  Data build(String db)
          Builds the database by running the specified parser.
abstract  void close()
          Closes open references.
 void comment(TokenBuilder com)
          Stores a comment.
 String det()
          Returns short information on this process.
 void emptyElem(byte[] tag, Atts att)
          Stores an empty element.
 void encoding(String enc)
          Sets the document encoding.
 void endDoc()
          Closes a document node.
 void endElem(byte[] tag)
          Closes an element.
 void pi(TokenBuilder pi)
          Stores a processing instruction.
 double prog()
          Returns progress information.
 void startDoc(byte[] doc)
          Opens a document node.
 int startElem(byte[] tag, Atts att)
          Opens a new element node.
 void startNS(byte[] pref, byte[] uri)
          Adds a new namespace; called by the building instance.
 void text(TokenBuilder t)
          Stores a text node.
 String tit()
          Returns short information on this process.
 
Methods inherited from class org.basex.core.Progress
abort, 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

build

public final Data build()
                 throws IOException
Builds the database by running the specified parser.

Returns:
data database instance
Throws:
IOException - I/O exception

startDoc

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

Parameters:
doc - document name
Throws:
IOException - I/O exception

endDoc

public final void endDoc()
                  throws IOException
Closes a document node.

Throws:
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 int startElem(byte[] tag,
                           Atts att)
                    throws IOException
Opens a new element node.

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

emptyElem

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

Parameters:
tag - tag name
att - attributes
Throws:
IOException - I/O exception

endElem

public final void endElem(byte[] tag)
                   throws IOException
Closes an element.

Parameters:
tag - tag name
Throws:
IOException - I/O exception

text

public final void text(TokenBuilder t)
                throws IOException
Stores a text node.

Parameters:
t - text value
Throws:
IOException - I/O exception

comment

public final void comment(TokenBuilder com)
                   throws IOException
Stores a comment.

Parameters:
com - comment text
Throws:
IOException - I/O exception

pi

public final void pi(TokenBuilder pi)
              throws IOException
Stores a processing instruction.

Parameters:
pi - processing instruction name and value
Throws:
IOException - I/O exception

encoding

public final void encoding(String enc)
Sets the document encoding.

Parameters:
enc - encoding

tit

public final 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 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

build

public abstract Data build(String db)
                    throws IOException
Builds the database by running the specified parser.

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

close

public abstract void close()
                    throws IOException
Closes open references.

Throws:
IOException - I/O exception