|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.basex.server.Session
org.basex.server.ClientSession
public class ClientSession
This class offers methods to execute database commands via the client/server architecture. Commands are sent to the server instance over a socket connection:
execute(java.lang.String, java.io.OutputStream)
method sends database commands to the server.
All strings are encoded as UTF8 and suffixed by a zero byte.close()
closes the session by sending the Commands.Cmd.EXIT
command to the server.
Field Summary | |
---|---|
protected java.util.Map<java.lang.String,EventNotifier> |
notifiers
Event notifications. |
protected java.io.InputStream |
sin
Server input. |
protected PrintOutput |
sout
Server output (buffered). |
Fields inherited from class org.basex.server.Session |
---|
out |
Constructor Summary | |
---|---|
ClientSession(Context context,
java.lang.String user,
java.lang.String pass)
Constructor, specifying login data. |
|
ClientSession(Context context,
java.lang.String user,
java.lang.String pass,
java.io.OutputStream output)
Constructor, specifying login data and an output stream. |
|
ClientSession(java.lang.String host,
int port,
java.lang.String user,
java.lang.String pass)
Constructor, specifying the server host:port combination and login data. |
|
ClientSession(java.lang.String host,
int port,
java.lang.String user,
java.lang.String pass,
java.io.OutputStream output)
Constructor, specifying the server host:port combination, login data and an output stream. |
Method Summary | |
---|---|
void |
add(java.lang.String path,
java.io.InputStream input)
Adds a document to the opened database. |
void |
close()
Closes the session. |
void |
create(java.lang.String name,
java.io.InputStream input)
Creates a database. |
protected java.lang.String |
exec(ServerCmd cmd,
java.lang.String arg,
java.io.OutputStream os)
Executes a command and sends the result to the specified output stream. |
protected void |
execute(Command cmd,
java.io.OutputStream os)
Executes a command and prints the result to the specified output stream. |
protected void |
execute(java.lang.String cmd,
java.io.OutputStream os)
Executes a command and prints the result to the specified output stream. |
protected static boolean |
ok(BufferInput bi)
Checks the next success flag. |
ClientQuery |
query(java.lang.String query)
Returns a query object for the specified query string. |
protected static void |
receive(BufferInput bi,
java.io.OutputStream os)
Retrieves data from the server. |
void |
replace(java.lang.String path,
java.io.InputStream input)
Replaces a document in an open database. |
protected void |
send(ServerCmd cmd,
java.io.InputStream input,
java.lang.String... strings)
Sends the specified command, string arguments and input. |
protected void |
send(java.lang.String s)
Sends a string to the server. |
void |
store(java.lang.String path,
java.io.InputStream input)
Stores raw data in an open database. |
java.lang.String |
toString()
|
void |
unwatch(java.lang.String name)
Unwatches an event. |
void |
watch(java.lang.String name,
EventNotifier notifier)
Watches an event. |
Methods inherited from class org.basex.server.Session |
---|
execute, execute, getOutputStream, info, setOutputStream |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final java.util.Map<java.lang.String,EventNotifier> notifiers
protected final PrintOutput sout
protected final java.io.InputStream sin
Constructor Detail |
---|
public ClientSession(Context context, java.lang.String user, java.lang.String pass) throws java.io.IOException
context
- database contextuser
- user namepass
- password
java.io.IOException
- I/O exceptionpublic ClientSession(Context context, java.lang.String user, java.lang.String pass, java.io.OutputStream output) throws java.io.IOException
context
- database contextuser
- user namepass
- passwordoutput
- client output; if set to null
, results will
be returned as strings.
java.io.IOException
- I/O exceptionpublic ClientSession(java.lang.String host, int port, java.lang.String user, java.lang.String pass) throws java.io.IOException
host
- server nameport
- server portuser
- user namepass
- password
java.io.IOException
- I/O exceptionpublic ClientSession(java.lang.String host, int port, java.lang.String user, java.lang.String pass, java.io.OutputStream output) throws java.io.IOException
host
- server nameport
- server portuser
- user namepass
- passwordoutput
- client output; if set to null
, results will
be returned as strings.
java.io.IOException
- I/O exceptionMethod Detail |
---|
public void create(java.lang.String name, java.io.InputStream input) throws java.io.IOException
Session
create
in class Session
name
- name of databaseinput
- xml input
java.io.IOException
- I/O exceptionpublic void add(java.lang.String path, java.io.InputStream input) throws java.io.IOException
Session
add
in class Session
path
- target pathinput
- xml input
java.io.IOException
- I/O exceptionpublic void replace(java.lang.String path, java.io.InputStream input) throws java.io.IOException
Session
replace
in class Session
path
- document(s) to replaceinput
- new content
java.io.IOException
- I/O exceptionpublic void store(java.lang.String path, java.io.InputStream input) throws java.io.IOException
Session
store
in class Session
path
- target pathinput
- binary input
java.io.IOException
- I/O exceptionpublic ClientQuery query(java.lang.String query) throws java.io.IOException
Session
query
in class Session
query
- query string
java.io.IOException
- I/O exceptionpublic void close() throws java.io.IOException
Session
close
in class Session
java.io.IOException
- I/O exceptionprotected void execute(java.lang.String cmd, java.io.OutputStream os) throws java.io.IOException
Session
execute
in class Session
cmd
- command to be parsedos
- output stream
java.io.IOException
- I/O exceptionprotected void execute(Command cmd, java.io.OutputStream os) throws java.io.IOException
Session
execute
in class Session
cmd
- command to be executedos
- output stream
java.io.IOException
- I/O exceptionpublic void watch(java.lang.String name, EventNotifier notifier) throws java.io.IOException
name
- event namenotifier
- event notification
java.io.IOException
- I/O exceptionpublic void unwatch(java.lang.String name) throws java.io.IOException
name
- event name
java.io.IOException
- I/O exceptionprotected static boolean ok(BufferInput bi) throws java.io.IOException
bi
- buffer input
java.io.IOException
- I/O exceptionprotected void send(ServerCmd cmd, java.io.InputStream input, java.lang.String... strings) throws java.io.IOException
cmd
- commandinput
- input streamstrings
- string arguments
java.io.IOException
- I/O exceptionprotected static void receive(BufferInput bi, java.io.OutputStream os) throws java.io.IOException
bi
- buffered server inputos
- output stream
java.io.IOException
- I/O exceptionprotected void send(java.lang.String s) throws java.io.IOException
s
- string to be sent
java.io.IOException
- I/O exceptionprotected java.lang.String exec(ServerCmd cmd, java.lang.String arg, java.io.OutputStream os) throws java.io.IOException
cmd
- server commandarg
- argumentos
- target output stream
java.io.IOException
- I/O exceptionpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |