Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.basex.server
Class ClientSession

    java.lang.Object
      org.basex.core.Session
          org.basex.server.ClientSession

    public final class ClientSession

extends Session

This wrapper sends commands to the server instance over a socket connection. It extends the `Session` class:

- A socket instance is created by the constructor.
- The `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.
- If the command has been successfully processed, the result string is read.
- Next, the processing info string is read.
- A last byte is next sent to indicate if command execution was successful (0) or not (1).
- `close()` closes the session by sending the `Commands.Cmd.EXIT` command to the server.

Author:
  Workgroup DBIS, University of Konstanz 2005-10, ISC License, Christian Gruen

Constructor Summary
`ClientSession(Context context, String user, String pw)` Constructor, specifying the database context and the login and password.
`ClientSession(String host, int port, String user, String pw)` Constructor, specifying the server host:port combination and the login and password.

Method Summary
`void` | `close()` Closes the session.
`boolean` | `execute(Proc pr, OutputStream o)` Executes a process and prints the result to the specified stream.
`boolean` | `execute(String cmd, OutputStream o)` Executes a command and prints the result to the specified stream.
`String` | `info()` Returns process info.

Methods inherited from class org.basex.core.Session
`execute, execute`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ClientSession

    public ClientSession(Context context,
                         String user,
                         String pw)
                  throws IOException

  Constructor, specifying the database context and the login and password.

  Parameters:
    `context` - database context
    `user` - user name
    `pw` - password
  Throws:
    `IOException` - I/O exception

### ClientSession

    public ClientSession(String host,
                         int port,
                         String user,
                         String pw)
                  throws IOException

  Constructor, specifying the server host:port combination and the login and password.

  Parameters:
    `host` - server name
    `port` - server port
    `user` - user name
    `pw` - password
  Throws:
    `IOException` - I/O exception

Method Detail

### execute

    public boolean execute(String cmd,
                           OutputStream o)
                    throws IOException

  Description copied from class: `Session`
  Executes a command and prints the result to the specified stream.

  Specified by:
    `execute` in class `Session`
  Parameters:
    `cmd` - command to be executed
    `o` - output stream
  Returns:
    success of operation
  Throws:
    `IOException` - I/O exception

### execute

    public boolean execute(Proc pr,
                           OutputStream o)
                    throws IOException

  Description copied from class: `Session`
  Executes a process and prints the result to the specified stream.

  Specified by:
    `execute` in class `Session`
  Parameters:
    `pr` - process to be executed
    `o` - output stream
  Returns:
    success of operation
  Throws:
    `IOException` - I/O exception

### info

    public String info()

  Description copied from class: `Session`
  Returns process info.

  Specified by:
    `info` in class `Session`
  Returns:
    process info

### close

    public void close()
               throws IOException

  Description copied from class: `Session`
  Closes the session.

  Specified by:
    `close` in class `Session`
  Throws:
    `IOException` - I/O exception

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD