Class 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-22, BSD License, Christian Gruen
    • Method Detail

      • 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
      • functions

        public Value functions​(String path)
        Returns inspected functions.
        Parameters:
        path - path to module
        Returns:
        inspected functions
      • addFunctions

        public void addFunctions​(String path,
                                 Value funcs)
        Adds inspected functions.
        Parameters:
        path - path to module
        funcs - functions
      • 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​(IO io)
        Returns the document path of a textual resource and its encoding. Only required for test APIs.
        Parameters:
        io - resource
        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
      • addText

        public void addText​(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