Class Query

java.lang.Object
org.basex.api.client.Query
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
ClientQuery, LocalQuery

public abstract class Query extends Object implements Closeable

This class defines methods for evaluating queries. It is implemented by ClientQuery and LocalQuery.

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-21, BSD License, Christian Gruen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected TokenList
    Cached results.
    protected OutputStream
    Client output stream.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    bind(String name, Object value)
    Binds a value to an external variable.
    abstract void
    bind(String name, Object value, String type)
    Binds a value with an optional type to an external variable.
    abstract void
    cache(boolean full)
    Caches the query result.
    final void
    context(Object value)
    Binds a value to the context value.
    abstract void
    context(Object value, String type)
    Binds a value with an optional type to an external variable.
    abstract String
    Returns the complete result of the query.
    abstract String
    Returns query info.
    boolean
    Returns true if more items are available.
    final String
    Returns the next item of the query as string.
    abstract String
    Returns the serialization options.
    final Type
    Returns the XQuery type of the current item (must be called after next().
    abstract boolean
    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

    Methods inherited from interface java.io.Closeable

    close
  • Field Details

    • out

      protected OutputStream out
      Client output stream.
    • cache

      protected TokenList cache
      Cached results.
  • Constructor Details

    • Query

      public Query()
  • Method Details

    • bind

      public final void bind(String name, Object value) throws IOException
      Binds a value to an external variable.
      Parameters:
      name - name of variable
      value - value to be bound
      Throws:
      IOException - I/O exception
    • bind

      public abstract void bind(String name, Object value, String type) throws IOException
      Binds a value with an optional type to an external variable.
      Parameters:
      name - name of variable
      value - value to be bound
      type - value type (may be null)
      Throws:
      IOException - I/O exception
    • context

      public final void context(Object value) throws IOException
      Binds a value to the context value.
      Parameters:
      value - value to be bound
      Throws:
      IOException - I/O exception
    • context

      public abstract void context(Object value, String type) throws IOException
      Binds a value with an optional type to an external variable.
      Parameters:
      value - value to be bound
      type - value type (may be null)
      Throws:
      IOException - I/O exception
    • more

      public boolean more() throws IOException
      Returns true if more items are available.
      Returns:
      result of check
      Throws:
      IOException - I/O exception
    • cache

      public abstract void cache(boolean full) throws IOException
      Caches the query result.
      Parameters:
      full - retrieve full type information
      Throws:
      IOException - I/O exception
    • next

      public final String next() throws IOException
      Returns the next item of the query as string.
      Returns:
      string or null
      Throws:
      IOException - I/O exception
    • type

      public final Type type()
      Returns the XQuery type of the current item (must be called after next().
      Returns:
      item type
    • execute

      public abstract String execute() throws IOException
      Returns the complete result of the query.
      Returns:
      item string or null
      Throws:
      IOException - I/O exception
    • options

      public abstract String options() throws IOException
      Returns the serialization options.
      Returns:
      serialization options
      Throws:
      IOException - I/O exception
    • updating

      public abstract boolean updating() throws IOException
      Returns true if the query may perform updates.
      Returns:
      updating flag
      Throws:
      IOException - I/O exception
    • info

      public abstract String info() throws IOException
      Returns query info.
      Returns:
      query info
      Throws:
      IOException - I/O exception