public class ClientSession extends Session
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.| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,EventNotifier> |
notifiers
Event notifications.
|
protected java.io.InputStream |
sin
Server input.
|
protected PrintOutput |
sout
Server output (buffered).
|
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
void |
unwatch(java.lang.String name)
Unwatches an event.
|
void |
watch(java.lang.String name,
EventNotifier notifier)
Watches an event.
|
execute, execute, info, setOutputStreamprotected final java.util.Map<java.lang.String,EventNotifier> notifiers
protected final PrintOutput sout
protected final java.io.InputStream sin
public ClientSession(Context context, java.lang.String user, java.lang.String pass) throws java.io.IOException
context - database contextuser - user namepass - passwordjava.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 - passwordjava.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 exceptionpublic void create(java.lang.String name,
java.io.InputStream input)
throws java.io.IOException
Sessionpublic void add(java.lang.String path,
java.io.InputStream input)
throws java.io.IOException
Sessionpublic void replace(java.lang.String path,
java.io.InputStream input)
throws java.io.IOException
Sessionpublic void store(java.lang.String path,
java.io.InputStream input)
throws java.io.IOException
Sessionpublic ClientQuery query(java.lang.String query) throws java.io.IOException
Sessionpublic void close()
throws java.io.IOException
Sessionprotected void execute(java.lang.String cmd,
java.io.OutputStream os)
throws java.io.IOException
Sessionprotected void execute(Command cmd, java.io.OutputStream os) throws java.io.IOException
Sessionpublic void watch(java.lang.String name,
EventNotifier notifier)
throws java.io.IOException
name - event namenotifier - event notificationjava.io.IOException - I/O exceptionpublic void unwatch(java.lang.String name)
throws java.io.IOException
name - event namejava.io.IOException - I/O exceptionprotected static boolean ok(BufferInput bi) throws java.io.IOException
bi - buffer inputjava.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 argumentsjava.io.IOException - I/O exceptionprotected static void receive(BufferInput bi, java.io.OutputStream os) throws java.io.IOException
bi - buffered server inputos - output streamjava.io.IOException - I/O exceptionprotected void send(java.lang.String s)
throws java.io.IOException
s - string to be sentjava.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 streamjava.io.IOException - I/O exception