Package org.basex.api.client
Class Session
java.lang.Object
org.basex.api.client.Session
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
ClientSession,LocalSession
This class defines methods for executing commands, either locally or via the client/server architecture.
The results of database commands are returned as strings. If an output stream is specified in
the constructor or with setOutputStream(OutputStream), results are instead serialized
to that stream.
The class is implemented by the ClientSession and LocalSession classes.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringCommand info.protected OutputStreamClient output stream. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidadd(String path, InputStream input) Adds a document to the opened database.abstract voidcreate(String name, InputStream input) Creates a database.final StringExecutes a command and returns the result as string or serializes it to the specified output stream.protected abstract voidexecute(String command, OutputStream output) Executes a command and prints the result to the specified output stream.final StringExecutes aCommandand returns the result as string or serializes it to the specified output stream.protected abstract voidexecute(Command command, OutputStream output) Executes a command and prints the result to the specified output stream.Returns the assigned output stream.final Stringinfo()Returns command info as a string, regardless of whether an output stream was specified.abstract QueryReturns a query object for the specified query string.abstract voidreplace(String path, InputStream input) Replaces a document in an open database.final voidsetOutputStream(OutputStream output) Specifies an output stream.abstract voidstore(String path, InputStream input) Stores raw data in an open database.
-
Field Details
-
out
Client output stream. -
info
Command info.
-
-
Method Details
-
execute
Executes aCommandand returns the result as string or serializes it to the specified output stream.- Parameters:
command- command to be executed- Returns:
- result or
nullreference - Throws:
IOException- I/O exception
-
execute
Executes a command and returns the result as string or serializes it to the specified output stream.- Parameters:
command- command to be parsed- Returns:
- result or
nullreference - Throws:
IOException- I/O exception
-
query
Returns a query object for the specified query string.- Parameters:
query- query string- Returns:
- query
- Throws:
IOException- I/O exception
-
create
Creates a database.- Parameters:
name- name of databaseinput- xml input- Throws:
IOException- I/O exception
-
add
Adds a document to the opened database.- Parameters:
path- target pathinput- xml input- Throws:
IOException- I/O exception
-
replace
Replaces a document in an open database.- Parameters:
path- document(s) to replaceinput- new content- Throws:
IOException- I/O exception
-
store
Stores raw data in an open database.- Parameters:
path- target pathinput- binary input- Throws:
IOException- I/O exception
-
info
Returns command info as a string, regardless of whether an output stream was specified.- Returns:
- command info
-
setOutputStream
Specifies an output stream. The output stream can be invalidated by passing onnullas argument.- Parameters:
output- client output stream
-
getOutputStream
Returns the assigned output stream.- Returns:
- client output stream
-
execute
Executes a command and prints the result to the specified output stream.- Parameters:
command- command to be parsedoutput- output stream- Throws:
IOException- I/O exception
-
execute
Executes a command and prints the result to the specified output stream.- Parameters:
command- command to be executedoutput- output stream- Throws:
IOException- I/O exception
-