org.basex.server
Class Session

java.lang.Object
  extended by org.basex.server.Session
Direct Known Subclasses:
ClientSession, LocalSession

public abstract class Session
extends java.lang.Object

This class defines methods for evaluating 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-12, BSD License, Christian Gruen

Field Summary
protected  java.io.OutputStream out
          Client output stream.
 
Method Summary
abstract  void add(java.lang.String path, java.io.InputStream input)
          Adds a document to the opened database.
abstract  void close()
          Closes the session.
abstract  void create(java.lang.String name, java.io.InputStream input)
          Creates a database.
 java.lang.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 cmd, java.io.OutputStream os)
          Executes a command and prints the result to the specified output stream.
 java.lang.String execute(java.lang.String command)
          Executes a command and returns the result as string or serializes it to the specified output stream.
protected abstract  void execute(java.lang.String cmd, java.io.OutputStream os)
          Executes a command and prints the result to the specified output stream.
 java.io.OutputStream getOutputStream()
          Returns the assigned output stream.
 java.lang.String info()
          Returns command info as a string, regardless of whether an output stream was specified.
abstract  Query query(java.lang.String query)
          Returns a query object for the specified query string.
abstract  void replace(java.lang.String path, java.io.InputStream input)
          Replaces a document in an open database.
 void setOutputStream(java.io.OutputStream output)
          Specifies an output stream.
abstract  void store(java.lang.String path, java.io.InputStream input)
          Stores raw data in an open database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

protected java.io.OutputStream out
Client output stream.

Method Detail

execute

public final java.lang.String execute(Command command)
                               throws java.io.IOException
Executes a Command and returns the result as string or serializes it to the specified output stream.

Parameters:
command - command to be executed
Returns:
result, or null reference
Throws:
java.io.IOException - I/O exception

execute

public final java.lang.String execute(java.lang.String command)
                               throws java.io.IOException
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 null reference
Throws:
java.io.IOException - I/O exception

query

public abstract Query query(java.lang.String query)
                     throws java.io.IOException
Returns a query object for the specified query string.

Parameters:
query - query string
Returns:
query
Throws:
java.io.IOException - I/O exception

create

public abstract void create(java.lang.String name,
                            java.io.InputStream input)
                     throws java.io.IOException
Creates a database.

Parameters:
name - name of database
input - xml input
Throws:
java.io.IOException - I/O exception

add

public abstract void add(java.lang.String path,
                         java.io.InputStream input)
                  throws java.io.IOException
Adds a document to the opened database.

Parameters:
path - target path
input - xml input
Throws:
java.io.IOException - I/O exception

replace

public abstract void replace(java.lang.String path,
                             java.io.InputStream input)
                      throws java.io.IOException
Replaces a document in an open database.

Parameters:
path - document(s) to replace
input - new content
Throws:
java.io.IOException - I/O exception

store

public abstract void store(java.lang.String path,
                           java.io.InputStream input)
                    throws java.io.IOException
Stores raw data in an open database.

Parameters:
path - target path
input - binary input
Throws:
java.io.IOException - I/O exception

info

public final java.lang.String info()
Returns command info as a string, regardless of whether an output stream was specified.

Returns:
command info

setOutputStream

public final void setOutputStream(java.io.OutputStream output)
Specifies an output stream. The output stream can be invalidated by passing on null as argument.

Parameters:
output - client output stream

getOutputStream

public java.io.OutputStream getOutputStream()
Returns the assigned output stream.

Returns:
client output stream

close

public abstract void close()
                    throws java.io.IOException
Closes the session.

Throws:
java.io.IOException - I/O exception

execute

protected abstract void execute(java.lang.String cmd,
                                java.io.OutputStream os)
                         throws java.io.IOException
Executes a command and prints the result to the specified output stream.

Parameters:
cmd - command to be parsed
os - output stream
Throws:
java.io.IOException - I/O exception

execute

protected abstract void execute(Command cmd,
                                java.io.OutputStream os)
                         throws java.io.IOException
Executes a command and prints the result to the specified output stream.

Parameters:
cmd - command to be executed
os - output stream
Throws:
java.io.IOException - I/O exception