Class QueryResources

java.lang.Object
org.basex.query.QueryResources

public final class QueryResources extends Object
This class provides access to all kinds of resources (databases, documents, database connections, sessions) used by an XQuery expression.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Method Details

    • index

      public <R extends QueryResource> R index(Class<? extends R> resource)
      Returns or creates an external resource of the specified class.
      Type Parameters:
      R - resource
      Parameters:
      resource - external resource
      Returns:
      resource
    • add

      public void add(InputStream input)
      Adds an input stream reference.
      Parameters:
      input - input stream
    • remove

      public void remove(InputStream input) throws IOException
      Closes and removes an input stream reference.
      Parameters:
      input - input stream
      Throws:
      IOException - I/O exception
    • database

      public Data database(String name, InputInfo ii) throws QueryException
      Opens a new database or returns a reference to an already opened database.
      Parameters:
      name - name of database
      ii - input info
      Returns:
      database instance
      Throws:
      QueryException - query exception
    • doc

      public DBNode doc(QueryInput qi, InputInfo ii) throws QueryException
      Evaluates fn:doc(): opens an existing database document, or creates a new database and node.
      Parameters:
      qi - query input
      ii - input info
      Returns:
      document
      Throws:
      QueryException - query exception
    • collection

      public Value collection(QueryInput qi, InputInfo ii) throws QueryException
      Evaluates fn:collection(): opens an existing collection, or creates a new data reference.
      Parameters:
      qi - query input (set to null if default collection is requested)
      ii - input info
      Returns:
      collection
      Throws:
      QueryException - query exception
    • modules

      public ModuleLoader modules()
      Returns the module loader. Called during parsing.
      Returns:
      module loader
    • remove

      public void remove(String name)
      Removes and closes the specified database. Called during updates.
      Parameters:
      name - name of database to be removed
    • text

      public String[] text(String uri)
      Returns the document path of a textual resource and its encoding. Only required for test APIs.
      Parameters:
      uri - resource uri
      Returns:
      path and encoding or null
    • addDoc

      public void addDoc(String name, String path, StaticContext sc) throws QueryException
      Adds a document with the specified path. Only called from the test APIs.
      Parameters:
      name - document identifier (may be null)
      path - document path
      sc - static context (can be null)
      Throws:
      QueryException - query exception
    • addResource

      public void addResource(String uri, String... strings)
      Adds a resource with the specified path. Only called from the test APIs.
      Parameters:
      uri - resource uri
      strings - resource strings (path, encoding)
    • addCollection

      public void addCollection(String name, String[] paths, StaticContext sc) throws QueryException
      Adds a collection with the specified paths. Only called from the test APIs.
      Parameters:
      name - name of collection (can be empty string)
      paths - documents paths
      sc - static context (can be null)
      Throws:
      QueryException - query exception
    • ftmaps

      public void ftmaps(HashMap<String,IO> sw, HashMap<String,IO> th)
      Attaches full-text maps. Only called from the test APIs.
      Parameters:
      sw - stop words
      th - thesaurus