Package org.basex.build
Class Builder
java.lang.Object
org.basex.core.jobs.Job
org.basex.build.Builder
- Direct Known Subclasses:
DiskBuilder,MemBuilder
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-21, BSD License, Christian Gruen
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddAttr(int nameId, byte[] value, int dist, int uriId) Adds an attribute to the database.protected abstract voidaddDoc(byte[] value) Adds a document node to the database.protected abstract voidaddElem(int dist, int nameId, int asize, int uriId, boolean ne) Adds an element node to the database.protected abstract voidaddText(byte[] value, int dist, byte kind) Adds a text node to the database.final voidStores binary data.final BuilderSets the path to the raw database files.abstract Databuild()Builds the database and returns the resulting database instance.final voidcloseDoc()Closes a document node.final voidCloses an element.final voidcomment(byte[] value) Stores a comment.final StringReturns detailed progress information.final voidStores an empty element.final voidopenDoc(byte[] value) Opens a document node.final voidOpens a new element node.final voidpi(byte[] pi) Stores a processing instruction.final doubleReturns a progress value (0 - 1).protected abstract voidsetSize(int pre, int size) Stores a size value to the specified table position.final StringReturns short progress information.final voidtext(byte[] value) Stores a text node.
-
Method Details
-
binaryDir
Sets the path to the raw database files. The path might differ from the actual database path if XML data is written to a temporary instance.- Parameters:
dir- database directory (can benull)- Returns:
- self reference
-
openDoc
Opens a document node.- Parameters:
value- document name- Throws:
IOException- I/O exception
-
closeDoc
Closes a document node.- Throws:
IOException- I/O exception
-
openElem
Opens a new element node.- Parameters:
name- name of elementatt- attributesnsp- namespaces- Throws:
IOException- I/O exception
-
emptyElem
Stores an empty element.- Parameters:
name- name of elementatt- attributesnsp- namespaces- Throws:
IOException- I/O exception
-
closeElem
Closes an element.- Throws:
IOException- I/O exception
-
text
Stores a text node.- Parameters:
value- text value- Throws:
IOException- I/O exception
-
comment
Stores a comment.- Parameters:
value- comment text- Throws:
IOException- I/O exception
-
pi
Stores a processing instruction.- Parameters:
pi- processing instruction name and value- Throws:
IOException- I/O exception
-
binary
Stores binary data.- Parameters:
target- database targetdata- data to store- Throws:
IOException- I/O exception
-
shortInfo
Description copied from class:JobReturns short progress information. Can be overwritten to give more specific feedback. -
detailedInfo
Description copied from class:JobReturns detailed progress information. Can be overwritten to give more specific feedback.- Overrides:
detailedInfoin classJob- Returns:
- header information
-
progressInfo
public final double progressInfo()Description copied from class:JobReturns a progress value (0 - 1). Can be overwritten to give more specific feedback.- Overrides:
progressInfoin classJob- Returns:
- header information
-
build
Builds the database and returns the resulting database instance.- Returns:
- data database instance
- Throws:
IOException- I/O exception
-
addDoc
Adds a document node to the database.- Parameters:
value- name of the document- Throws:
IOException- I/O exception
-
addElem
protected abstract void addElem(int dist, int nameId, int asize, int uriId, boolean ne) throws 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 parentnameId- id of element nameasize- number of attributesuriId- id of namespace urine- namespace flag (indicates if this element introduces new namespaces)- Throws:
IOException- I/O exception
-
addAttr
Adds an attribute to the database.- Parameters:
nameId- id of attribute namevalue- attribute valuedist- distance to parenturiId- id of namespace uri- Throws:
IOException- I/O exception
-
addText
Adds a text node to the database.- Parameters:
value- the token to be addeddist- distance to parentkind- the node kind- Throws:
IOException- I/O exception
-
setSize
Stores a size value to the specified table position.- Parameters:
pre- pre referencesize- value to be stored- Throws:
IOException- I/O exception
-