Class MemBuilder


public final class MemBuilder extends Builder
This class creates a database instance in main memory. The storage layout is described in the Data class.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • MemBuilder

      public MemBuilder(String name, Parser parse)
      Constructor.
      Parameters:
      name - name of database
      parse - parser
  • Method Details

    • build

      public static MemData build(IO input) throws IOException
      Builds a main memory database instance.
      Parameters:
      input - input
      Returns:
      data database instance
      Throws:
      IOException - I/O exception
    • build

      public static MemData build(Parser parser) throws IOException
      Builds a main memory database instance.
      Parameters:
      parser - parser
      Returns:
      data database instance
      Throws:
      IOException - I/O exception
    • build

      public static MemData build(String name, Parser parser) throws IOException
      Builds a main memory database instance with the specified name.
      Parameters:
      name - name of database
      parser - parser
      Returns:
      data database instance
      Throws:
      IOException - I/O exception
    • build

      public MemData build() throws IOException
      Description copied from class: Builder
      Builds the database and returns the resulting database instance.
      Specified by:
      build in class Builder
      Returns:
      data database instance
      Throws:
      IOException - I/O exception
    • init

      public void init()
      Initializes the builder.
    • data

      public Data data()
      Returns the data reference.
      Returns:
      data reference
    • addDoc

      protected void addDoc(byte[] value)
      Description copied from class: Builder
      Adds a document node to the database.
      Specified by:
      addDoc in class Builder
      Parameters:
      value - name of the document
    • addElem

      protected void addElem(int dist, int nameId, int asize, int uriId, boolean ne)
      Description copied from class: Builder
      Adds an element node to the database. This method stores a preliminary size value; if this node has further descendants, Builder.setSize(int, int) must be called to set the final size value.
      Specified by:
      addElem in class Builder
      Parameters:
      dist - distance to parent
      nameId - id of element name
      asize - number of attributes
      uriId - id of namespace uri
      ne - namespace flag (indicates if this element introduces new namespaces)
    • addAttr

      protected void addAttr(int nameId, byte[] value, int dist, int uriId)
      Description copied from class: Builder
      Adds an attribute to the database.
      Specified by:
      addAttr in class Builder
      Parameters:
      nameId - id of attribute name
      value - attribute value
      dist - distance to parent
      uriId - id of namespace uri
    • addText

      protected void addText(byte[] value, int dist, byte kind)
      Description copied from class: Builder
      Adds a text node to the database.
      Specified by:
      addText in class Builder
      Parameters:
      value - the token to be added
      dist - distance to parent
      kind - the node kind
    • setSize

      protected void setSize(int pre, int size)
      Description copied from class: Builder
      Stores a size value to the specified table position.
      Specified by:
      setSize in class Builder
      Parameters:
      pre - pre reference
      size - value to be stored