Package org.basex.query
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-22, BSD License, Christian Gruen
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(InputStream input)
Adds an input stream reference.void
addCollection(String name, String[] paths, StaticContext sc)
Adds a collection with the specified paths.void
addDoc(String name, String path, StaticContext sc)
Adds a document with the specified path.void
addFunctions(String path, Value funcs)
Adds inspected functions.void
addText(String uri, String... strings)
Adds a resource with the specified path.Value
collection(QueryInput qi, InputInfo ii)
Evaluatesfn:collection()
: opens an existing collection, or creates a new data reference.Data
database(String name, InputInfo ii)
Opens a new database or returns a reference to an already opened database.DBNode
doc(QueryInput qi, InputInfo ii)
Evaluatesfn:doc()
: opens an existing database document, or creates a new database and node.void
ftmaps(HashMap<String,IO> sw, HashMap<String,IO> th)
Attaches full-text maps.Value
functions(String path)
Returns inspected functions.<R extends QueryResource>
Rindex(Class<? extends R> resource)
Returns or creates an external resource of the specified class.ModuleLoader
modules()
Returns the module loader.void
remove(InputStream input)
Closes and removes an input stream reference.void
remove(String name)
Removes and closes the specified database.String[]
text(IO io)
Returns the document path of a textual resource and its encoding.
-
-
-
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 modulefuncs
- 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 databaseii
- input info- Returns:
- database instance
- Throws:
QueryException
- query exception
-
doc
public DBNode doc(QueryInput qi, InputInfo ii) throws QueryException
Evaluatesfn:doc()
: opens an existing database document, or creates a new database and node.- Parameters:
qi
- query inputii
- input info- Returns:
- document
- Throws:
QueryException
- query exception
-
collection
public Value collection(QueryInput qi, InputInfo ii) throws QueryException
Evaluatesfn:collection()
: opens an existing collection, or creates a new data reference.- Parameters:
qi
- query input (set tonull
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 benull
)path
- document pathsc
- static context (can benull
)- 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 uristrings
- 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 pathssc
- static context (can benull
)- Throws:
QueryException
- query exception
-
-