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

Method Summary
 Data build(Parser p, java.lang.String db)
          Builds the database by running the specified parser.
abstract  void close()
          Closes open references.
 void comment(byte[] com)
          Stores comments; called by the building instance.
 java.lang.String det()
          Returns detailed information on this progress.
 void emptyNode(byte[] tag, byte[][] att)
          Stores an empty tag; called by the building instance.
 void encoding(java.lang.String enc)
          Sets the document encoding.
 void endNode(byte[] tag)
          Closes a tag; called by the building instance.
 java.lang.String head()
          Returns short information on this process.
 void nodeAndText(byte[] tag, byte[] txt)
          Convenience method for adding a tag and a text node; called by the building instance.
 void pi(byte[] pi)
          Stores processing instructions; called by the building instance.
 double prog()
          Returns progress information.
 void startNode(byte[] tag, byte[][] att)
          Opens a new tag; called by the building instance.
 java.lang.Object[] state()
          Returns current progress header.
 void text(byte[] tok, boolean chars)
          Stores text nodes; called by the building instance.
 
Methods inherited from class org.basex.core.Progress
detail, header, progress, progress, stop, stopped
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

build

public final Data build(Parser p,
                        java.lang.String db)
                 throws java.io.IOException
Builds the database by running the specified parser.

Parameters:
p - parser instance
db - name of database
Returns:
data database instance
Throws:
java.io.IOException - in case of parsing or writing problems

close

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

Throws:
java.io.IOException - in case of parsing or writing problems

comment

public final void comment(byte[] com)
                   throws java.io.IOException
Stores comments; called by the building instance.

Parameters:
com - the comment to be processed
Throws:
java.io.IOException - in case of parsing or writing problems

det

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

Returns:
information in detail

emptyNode

public final void emptyNode(byte[] tag,
                            byte[][] att)
                     throws java.io.IOException
Stores an empty tag; called by the building instance.

Parameters:
tag - the tag to be processed
att - the tag attributes
Throws:
java.io.IOException - in case of parsing or writing problems

encoding

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

Parameters:
enc - encoding

endNode

public final void endNode(byte[] tag)
                   throws java.io.IOException
Closes a tag; called by the building instance.

Parameters:
tag - the tag to be processed
Throws:
java.io.IOException - in case of parsing or writing problems

head

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

Returns:
header information

nodeAndText

public final void nodeAndText(byte[] tag,
                              byte[] txt)
                       throws java.io.IOException
Convenience method for adding a tag and a text node; called by the building instance.

Parameters:
tag - the tag to be processed
txt - text node
Throws:
java.io.IOException - in case of parsing or writing problems

pi

public final void pi(byte[] pi)
              throws java.io.IOException
Stores processing instructions; called by the building instance.

Parameters:
pi - the processing instruction to be processed
Throws:
java.io.IOException - in case of parsing or writing problems

prog

public final double prog()
Description copied from class: Progress
Returns progress information.

Returns:
header information

startNode

public final void startNode(byte[] tag,
                            byte[][] att)
                     throws java.io.IOException
Opens a new tag; called by the building instance.

Parameters:
tag - the tag to be processed
att - the tag attributes
Throws:
java.io.IOException - in case of parsing or writing problems

state

public final java.lang.Object[] state()
Returns current progress header.

Returns:
progress information

text

public final void text(byte[] tok,
                       boolean chars)
                throws java.io.IOException
Stores text nodes; called by the building instance.

Parameters:
tok - the text to be processed
chars - indicates if the text node is not a pure whitespace node
Throws:
java.io.IOException - in case of parsing or writing problems