org.basex.server
Class Query

java.lang.Object
  extended by org.basex.server.Query
Direct Known Subclasses:
ClientQuery, LocalQuery

public abstract class Query
extends java.lang.Object

This class defines methods for executing queries. It is implemented by ClientQuery.

Results are either returned as string or serialized to the output stream that has been specified via the constructor or via Session.setOutputStream(OutputStream).

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
protected  TokenList cache
          Cached results.
protected  java.io.OutputStream out
          Client output stream.
 
Constructor Summary
Query()
           
 
Method Summary
 void bind(java.lang.String n, java.lang.Object v)
          Binds a value to an external variable.
abstract  void bind(java.lang.String n, java.lang.Object v, java.lang.String t)
          Binds a value with an optional type to an external variable.
protected abstract  void cache()
          Caches the query result.
protected  void cache(java.io.InputStream is)
          Caches the incoming input.
abstract  void close()
          Closes the query.
 void context(java.lang.Object v)
          Binds a value to the context item.
abstract  void context(java.lang.Object v, java.lang.String t)
          Binds a value with an optional type to an external variable.
abstract  java.lang.String execute()
          Returns the complete result of the query.
abstract  java.lang.String info()
          Returns query info.
 boolean more()
          Returns true if more items are available.
 java.lang.String next()
          Returns the next item of the query.
abstract  java.lang.String options()
          Returns the serialization options.
 Type type()
          Returns the current XQuery type (must be called after next().
abstract  boolean updating()
          Returns true if the query may perform updates.
 
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.


cache

protected TokenList cache
Cached results.

Constructor Detail

Query

public Query()
Method Detail

bind

public final void bind(java.lang.String n,
                       java.lang.Object v)
                throws java.io.IOException
Binds a value to an external variable.

Parameters:
n - name of variable
v - value to be bound
Throws:
java.io.IOException - I/O exception

bind

public abstract void bind(java.lang.String n,
                          java.lang.Object v,
                          java.lang.String t)
                   throws java.io.IOException
Binds a value with an optional type to an external variable.

Parameters:
n - name of variable
v - value to be bound
t - data type (may be null)
Throws:
java.io.IOException - I/O exception

context

public final void context(java.lang.Object v)
                   throws java.io.IOException
Binds a value to the context item.

Parameters:
v - value to be bound
Throws:
java.io.IOException - I/O exception

context

public abstract void context(java.lang.Object v,
                             java.lang.String t)
                      throws java.io.IOException
Binds a value with an optional type to an external variable.

Parameters:
v - value to be bound
t - data type (may be null)
Throws:
java.io.IOException - I/O exception

more

public boolean more()
             throws java.io.IOException
Returns true if more items are available.

Returns:
result of check
Throws:
java.io.IOException - I/O exception

cache

protected abstract void cache()
                       throws java.io.IOException
Caches the query result.

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

next

public final java.lang.String next()
                            throws java.io.IOException
Returns the next item of the query.

Returns:
item string or null.
Throws:
java.io.IOException - I/O exception

type

public final Type type()
Returns the current XQuery type (must be called after next().

Returns:
item type

cache

protected void cache(java.io.InputStream is)
              throws java.io.IOException
Caches the incoming input.

Parameters:
is - input stream
Throws:
java.io.IOException - I/O exception

execute

public abstract java.lang.String execute()
                                  throws java.io.IOException
Returns the complete result of the query.

Returns:
item string or null.
Throws:
java.io.IOException - I/O exception

options

public abstract java.lang.String options()
                                  throws java.io.IOException
Returns the serialization options.

Returns:
serialization options.
Throws:
java.io.IOException - I/O exception

updating

public abstract boolean updating()
                          throws java.io.IOException
Returns true if the query may perform updates.

Returns:
updating flag
Throws:
java.io.IOException - I/O exception

info

public abstract java.lang.String info()
                               throws java.io.IOException
Returns query info.

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

close

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

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