public abstract class Session extends Object implements Closeable
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.
Modifier and Type | Field and Description |
---|---|
protected String |
info
Command info.
|
protected OutputStream |
out
Client output stream.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
add(String path,
InputStream input)
Adds a document to the opened database.
|
abstract void |
create(String name,
InputStream input)
Creates a database.
|
String |
execute(Command command)
Executes a
Command and returns the result as string or serializes
it to the specified output stream. |
protected abstract void |
execute(Command command,
OutputStream output)
Executes a command and prints the result to the specified output stream.
|
String |
execute(String command)
Executes a command and returns the result as string or serializes
it to the specified output stream.
|
protected abstract void |
execute(String command,
OutputStream output)
Executes a command and prints the result to the specified output stream.
|
OutputStream |
getOutputStream()
Returns the assigned output stream.
|
String |
info()
Returns command info as a string, regardless of whether an output stream
was specified.
|
abstract Query |
query(String query)
Returns a query object for the specified query string.
|
abstract void |
replace(String path,
InputStream input)
Replaces a document in an open database.
|
void |
setOutputStream(OutputStream output)
Specifies an output stream.
|
abstract void |
store(String path,
InputStream input)
Stores raw data in an open database.
|
protected OutputStream out
protected String info
public final String execute(Command command) throws IOException
Command
and returns the result as string or serializes
it to the specified output stream.command
- command to be executednull
referenceIOException
- I/O exceptionpublic final String execute(String command) throws IOException
command
- command to be parsednull
referenceIOException
- I/O exceptionpublic abstract Query query(String query) throws IOException
query
- query stringIOException
- I/O exceptionpublic abstract void create(String name, InputStream input) throws IOException
name
- name of databaseinput
- xml inputIOException
- I/O exceptionpublic abstract void add(String path, InputStream input) throws IOException
path
- target pathinput
- xml inputIOException
- I/O exceptionpublic abstract void replace(String path, InputStream input) throws IOException
path
- document(s) to replaceinput
- new contentIOException
- I/O exceptionpublic abstract void store(String path, InputStream input) throws IOException
path
- target pathinput
- binary inputIOException
- I/O exceptionpublic final String info()
public final void setOutputStream(OutputStream output)
null
as argument.output
- client output streampublic OutputStream getOutputStream()
protected abstract void execute(String command, OutputStream output) throws IOException
command
- command to be parsedoutput
- output streamIOException
- I/O exceptionprotected abstract void execute(Command command, OutputStream output) throws IOException
command
- command to be executedoutput
- output streamIOException
- I/O exceptionCopyright © 2005–2015 BaseX Team. All rights reserved.