org.basex.query
Class QueryProcessor

java.lang.Object
  extended by org.basex.core.Progress
      extended by org.basex.query.QueryProcessor

public final class QueryProcessor
extends Progress

This abstract class contains various methods which allow querying in the database. A variety of hierarchical parsers (XPath, XQuery, etc..) can be implemented on top of this class.

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

Field Summary
 QueryContext ctx
          Expression context.
 java.lang.String query
          Initial node set.
 
Constructor Summary
QueryProcessor(java.lang.String q)
          Default Constructor.
QueryProcessor(java.lang.String qu, IO f)
          XQuery Constructor.
QueryProcessor(java.lang.String qu, Nodes n)
          XQuery Constructor.
 
Method Summary
 void close()
          Parses the specified query and returns the result.
 void compile()
          Compiles the query.
 java.lang.String det()
          Returns short information on this process.
 Item eval()
          Returns the result as an item.
 java.lang.String info()
          Returns query background information.
 Iter iter()
          Returns a result iterator.
 void module(java.lang.String ns, java.lang.String file)
          Adds a module reference.
 void parse()
          Parses the specified query.
 void plan(Serializer ser)
          Returns the query plan in the dot notation.
 double prog()
          Returns progress information.
 Result query()
          Parses the specified query and returns the result.
 Nodes queryNodes()
          Parses the specified query and returns the result nodes.
 void setQuery(java.lang.String qu)
          Sets a new query.
 java.lang.String tit()
          Returns short information on this process.
 
Methods inherited from class org.basex.core.Progress
checkStop, detail, progress, progress, stop, title
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ctx

public final QueryContext ctx
Expression context.


query

public java.lang.String query
Initial node set.

Constructor Detail

QueryProcessor

public QueryProcessor(java.lang.String q)
Default Constructor.

Parameters:
q - query

QueryProcessor

public QueryProcessor(java.lang.String qu,
                      IO f)
XQuery Constructor.

Parameters:
qu - query
f - query file reference

QueryProcessor

public QueryProcessor(java.lang.String qu,
                      Nodes n)
XQuery Constructor.

Parameters:
qu - query
n - initial nodes
Method Detail

parse

public void parse()
           throws QueryException
Parses the specified query.

Throws:
QueryException - query exception

compile

public void compile()
             throws QueryException
Compiles the query.

Throws:
QueryException - query exception

iter

public Iter iter()
          throws QueryException
Returns a result iterator.

Returns:
result iterator
Throws:
QueryException - query exception

eval

public Item eval()
          throws QueryException
Returns the result as an item.

Returns:
result iterator
Throws:
QueryException - query exception

query

public Result query()
             throws QueryException
Parses the specified query and returns the result.

Returns:
result of query
Throws:
QueryException - query exception

queryNodes

public Nodes queryNodes()
                 throws QueryException
Parses the specified query and returns the result nodes.

Returns:
result of query
Throws:
QueryException - query exception

module

public void module(java.lang.String ns,
                   java.lang.String file)
Adds a module reference.

Parameters:
ns - module namespace
file - file name

setQuery

public void setQuery(java.lang.String qu)
Sets a new query. Should be called before parsing the query.

Parameters:
qu - query

close

public void close()
           throws java.io.IOException
Parses the specified query and returns the result.

Throws:
java.io.IOException - query exception

info

public java.lang.String info()
Returns query background information.

Returns:
background information

plan

public void plan(Serializer ser)
          throws java.lang.Exception
Returns the query plan in the dot notation.

Parameters:
ser - serializer
Throws:
java.lang.Exception - exception

tit

public java.lang.String tit()
Description copied from class: Progress
Returns short information on this process. Can be overwritten to give more detailed information.

Returns:
header information

det

public java.lang.String det()
Description copied from class: Progress
Returns short information on this process.

Overrides:
det in class Progress
Returns:
header information

prog

public double prog()
Description copied from class: Progress
Returns progress information. Can be overwritten to give more detailed information.

Overrides:
prog in class Progress
Returns:
header information