org.exist.xmldb
Class LocalXPathQueryService

java.lang.Object
  extended by org.exist.xmldb.LocalXPathQueryService
All Implemented Interfaces:
XPathQueryServiceImpl, Configurable, Service, XPathQueryService, XQueryService

public class LocalXPathQueryService
extends Object
implements XPathQueryServiceImpl, XQueryService


Constructor Summary
LocalXPathQueryService(User user, BrokerPool pool, LocalCollection collection, AccessContext accessCtx)
           
 
Method Summary
 void beginProtected()
          Execute all following queries in a protected environment.
 void clearNamespaces()
           
 CompiledExpression compile(String query)
           
 CompiledExpression compileAndCheck(String query)
           
 void declareVariable(String qname, Object initialValue)
          Declare an external XPath variable and assign a value to it.
 void dump(CompiledExpression expression, Writer writer)
           
 void endProtected()
          Close the protected environment.
 ResourceSet execute(CompiledExpression expression)
           
 ResourceSet execute(Source source)
           
 ResourceSet execute(XMLResource res, CompiledExpression expression)
           
 String getName()
           
 String getNamespace(String prefix)
           
 String getProperty(String property)
           
 String getVersion()
           
 ResourceSet query(String query)
           
 ResourceSet query(String query, String sortBy)
          Process an XPath query and sort the results by applying a second XPath expression to each of the search results.
 ResourceSet query(XMLResource res, String query)
          Process an XPath query based on the result of a previous query.
 ResourceSet query(XMLResource res, String query, String sortBy)
          Process an XPath query based on the result of a previous query and sort the results using the second XPath expression.
 ResourceSet queryResource(String resource, String query)
           
 void removeNamespace(String ns)
           
 void setCollection(Collection col)
           
 void setModuleLoadPath(String path)
           
 void setNamespace(String prefix, String namespace)
           
 void setProperty(String property, String value)
           
 void setXPathCompatibility(boolean backwardsCompatible)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalXPathQueryService

public LocalXPathQueryService(User user,
                              BrokerPool pool,
                              LocalCollection collection,
                              AccessContext accessCtx)
Method Detail

clearNamespaces

public void clearNamespaces()
                     throws XMLDBException
Specified by:
clearNamespaces in interface XPathQueryService
Specified by:
clearNamespaces in interface XQueryService
Throws:
XMLDBException

getName

public String getName()
               throws XMLDBException
Specified by:
getName in interface Service
Throws:
XMLDBException

getNamespace

public String getNamespace(String prefix)
                    throws XMLDBException
Specified by:
getNamespace in interface XPathQueryService
Specified by:
getNamespace in interface XQueryService
Throws:
XMLDBException

getProperty

public String getProperty(String property)
                   throws XMLDBException
Specified by:
getProperty in interface Configurable
Throws:
XMLDBException

getVersion

public String getVersion()
                  throws XMLDBException
Specified by:
getVersion in interface Service
Throws:
XMLDBException

query

public ResourceSet query(String query)
                  throws XMLDBException
Specified by:
query in interface XPathQueryService
Specified by:
query in interface XQueryService
Throws:
XMLDBException

query

public ResourceSet query(XMLResource res,
                         String query)
                  throws XMLDBException
Description copied from interface: XPathQueryServiceImpl
Process an XPath query based on the result of a previous query. The XMLResource contains the result received from a previous query.

Specified by:
query in interface XPathQueryServiceImpl
Parameters:
res - an XMLResource as obtained from a previous query.
query - the XPath query
Throws:
XMLDBException

query

public ResourceSet query(String query,
                         String sortBy)
                  throws XMLDBException
Description copied from interface: XPathQueryServiceImpl
Process an XPath query and sort the results by applying a second XPath expression to each of the search results. The result of applying the sort expression is converted into a string, which is then used to sort the set of results.

Specified by:
query in interface XPathQueryServiceImpl
Parameters:
query - the XPath query
sortBy - another XPath expression, which is executed relative to the results of the primary expression.
Throws:
XMLDBException

query

public ResourceSet query(XMLResource res,
                         String query,
                         String sortBy)
                  throws XMLDBException
Description copied from interface: XPathQueryServiceImpl
Process an XPath query based on the result of a previous query and sort the results using the second XPath expression. The XMLResource contains the result received from a previous query.

Specified by:
query in interface XPathQueryServiceImpl
Parameters:
res - an XMLResource as obtained from a previous query
query - the XPath query
sortBy - another XPath expression, which is executed relative to the results of the primary expression. The result of applying sortExpr is converted to a string value, which is then used to sort the results.
Throws:
XMLDBException

execute

public ResourceSet execute(CompiledExpression expression)
                    throws XMLDBException
Specified by:
execute in interface XQueryService
Throws:
XMLDBException

execute

public ResourceSet execute(XMLResource res,
                           CompiledExpression expression)
                    throws XMLDBException
Throws:
XMLDBException

execute

public ResourceSet execute(Source source)
                    throws XMLDBException
Throws:
XMLDBException

compile

public CompiledExpression compile(String query)
                           throws XMLDBException
Specified by:
compile in interface XQueryService
Throws:
XMLDBException

compileAndCheck

public CompiledExpression compileAndCheck(String query)
                                   throws XMLDBException,
                                          XPathException
Throws:
XMLDBException
XPathException

queryResource

public ResourceSet queryResource(String resource,
                                 String query)
                          throws XMLDBException
Specified by:
queryResource in interface XPathQueryService
Specified by:
queryResource in interface XQueryService
Throws:
XMLDBException

beginProtected

public void beginProtected()
                    throws XMLDBException
Execute all following queries in a protected environment. Protected means: it is guaranteed that documents referenced by the query or the result set are not modified by other threads until endProtected() is called.

Specified by:
beginProtected in interface XPathQueryServiceImpl
Throws:
XMLDBException

endProtected

public void endProtected()
Close the protected environment. All locks held by the current thread are released. The result set is no longer guaranteed to be stable.

Specified by:
endProtected in interface XPathQueryServiceImpl

removeNamespace

public void removeNamespace(String ns)
                     throws XMLDBException
Specified by:
removeNamespace in interface XPathQueryService
Specified by:
removeNamespace in interface XQueryService
Throws:
XMLDBException

setCollection

public void setCollection(Collection col)
                   throws XMLDBException
Specified by:
setCollection in interface Service
Throws:
XMLDBException

setNamespace

public void setNamespace(String prefix,
                         String namespace)
                  throws XMLDBException
Specified by:
setNamespace in interface XPathQueryService
Specified by:
setNamespace in interface XQueryService
Throws:
XMLDBException

setProperty

public void setProperty(String property,
                        String value)
                 throws XMLDBException
Specified by:
setProperty in interface Configurable
Throws:
XMLDBException

declareVariable

public void declareVariable(String qname,
                            Object initialValue)
                     throws XMLDBException
Description copied from interface: XPathQueryServiceImpl
Declare an external XPath variable and assign a value to it. A variable can be referenced inside an XPath expression as $variable. For example, if you declare a variable with
        declareVariable("name", "HAMLET");
 
you may use the variable in an XPath expression as follows:
        //SPEECH[SPEAKER=$name]
 
Any Java object may be passed as initial value. The query engine will try to map this into a corresponding XPath value. You may also pass an XMLResource as obtained from another XPath expression. This will be converted into a node.

Specified by:
declareVariable in interface XPathQueryServiceImpl
Specified by:
declareVariable in interface XQueryService
Parameters:
qname - a valid QName by which the variable is identified. Any prefix should have been mapped to a namespace, i.e. if a variable is called x:name, there should be a prefix/namespace mapping for the prefix x
initialValue - the initial value, which is assigned to the variable
Throws:
XMLDBException

setXPathCompatibility

public void setXPathCompatibility(boolean backwardsCompatible)
Specified by:
setXPathCompatibility in interface XQueryService

setModuleLoadPath

public void setModuleLoadPath(String path)
Specified by:
setModuleLoadPath in interface XQueryService

dump

public void dump(CompiledExpression expression,
                 Writer writer)
          throws XMLDBException
Throws:
XMLDBException


Copyright (C) Wolfgang Meier. All rights reserved.