org.exist.xmldb
Class LocalXPathQueryService

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

public class LocalXPathQueryService
extends java.lang.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()
           
 org.xmldb.api.base.CompiledExpression compile(java.lang.String query)
           
 org.xmldb.api.base.CompiledExpression compileAndCheck(java.lang.String query)
           
 void declareVariable(java.lang.String qname, java.lang.Object initialValue)
          Declare an external XPath variable and assign a value to it.
 void dump(org.xmldb.api.base.CompiledExpression expression, java.io.Writer writer)
           
 void endProtected()
          Close the protected environment.
 org.xmldb.api.base.ResourceSet execute(org.xmldb.api.base.CompiledExpression expression)
           
 org.xmldb.api.base.ResourceSet execute(Source source)
           
 org.xmldb.api.base.ResourceSet execute(org.xmldb.api.modules.XMLResource res, org.xmldb.api.base.CompiledExpression expression)
           
 java.lang.String getName()
           
 java.lang.String getNamespace(java.lang.String prefix)
           
 java.lang.String getProperty(java.lang.String property)
           
 java.lang.String getVersion()
           
 org.xmldb.api.base.ResourceSet query(java.lang.String query)
           
 org.xmldb.api.base.ResourceSet query(java.lang.String query, java.lang.String sortBy)
          Process an XPath query and sort the results by applying a second XPath expression to each of the search results.
 org.xmldb.api.base.ResourceSet query(org.xmldb.api.modules.XMLResource res, java.lang.String query)
          Process an XPath query based on the result of a previous query.
 org.xmldb.api.base.ResourceSet query(org.xmldb.api.modules.XMLResource res, java.lang.String query, java.lang.String sortBy)
          Process an XPath query based on the result of a previous query and sort the results using the second XPath expression.
 org.xmldb.api.base.ResourceSet queryResource(java.lang.String resource, java.lang.String query)
           
 void removeNamespace(java.lang.String ns)
           
 void setCollection(org.xmldb.api.base.Collection col)
           
 void setModuleLoadPath(java.lang.String path)
           
 void setNamespace(java.lang.String prefix, java.lang.String namespace)
           
 void setProperty(java.lang.String property, java.lang.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 org.xmldb.api.base.XMLDBException
Specified by:
clearNamespaces in interface org.xmldb.api.modules.XPathQueryService
Specified by:
clearNamespaces in interface org.xmldb.api.modules.XQueryService
Throws:
org.xmldb.api.base.XMLDBException

getName

public java.lang.String getName()
                         throws org.xmldb.api.base.XMLDBException
Specified by:
getName in interface org.xmldb.api.base.Service
Throws:
org.xmldb.api.base.XMLDBException

getNamespace

public java.lang.String getNamespace(java.lang.String prefix)
                              throws org.xmldb.api.base.XMLDBException
Specified by:
getNamespace in interface org.xmldb.api.modules.XPathQueryService
Specified by:
getNamespace in interface org.xmldb.api.modules.XQueryService
Throws:
org.xmldb.api.base.XMLDBException

getProperty

public java.lang.String getProperty(java.lang.String property)
                             throws org.xmldb.api.base.XMLDBException
Specified by:
getProperty in interface org.xmldb.api.base.Configurable
Throws:
org.xmldb.api.base.XMLDBException

getVersion

public java.lang.String getVersion()
                            throws org.xmldb.api.base.XMLDBException
Specified by:
getVersion in interface org.xmldb.api.base.Service
Throws:
org.xmldb.api.base.XMLDBException

query

public org.xmldb.api.base.ResourceSet query(java.lang.String query)
                                     throws org.xmldb.api.base.XMLDBException
Specified by:
query in interface org.xmldb.api.modules.XPathQueryService
Specified by:
query in interface org.xmldb.api.modules.XQueryService
Throws:
org.xmldb.api.base.XMLDBException

query

public org.xmldb.api.base.ResourceSet query(org.xmldb.api.modules.XMLResource res,
                                            java.lang.String query)
                                     throws org.xmldb.api.base.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:
org.xmldb.api.base.XMLDBException

query

public org.xmldb.api.base.ResourceSet query(java.lang.String query,
                                            java.lang.String sortBy)
                                     throws org.xmldb.api.base.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.
Returns:
Throws:
org.xmldb.api.base.XMLDBException

query

public org.xmldb.api.base.ResourceSet query(org.xmldb.api.modules.XMLResource res,
                                            java.lang.String query,
                                            java.lang.String sortBy)
                                     throws org.xmldb.api.base.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:
org.xmldb.api.base.XMLDBException

execute

public org.xmldb.api.base.ResourceSet execute(org.xmldb.api.base.CompiledExpression expression)
                                       throws org.xmldb.api.base.XMLDBException
Specified by:
execute in interface org.xmldb.api.modules.XQueryService
Throws:
org.xmldb.api.base.XMLDBException

execute

public org.xmldb.api.base.ResourceSet execute(org.xmldb.api.modules.XMLResource res,
                                              org.xmldb.api.base.CompiledExpression expression)
                                       throws org.xmldb.api.base.XMLDBException
Throws:
org.xmldb.api.base.XMLDBException

execute

public org.xmldb.api.base.ResourceSet execute(Source source)
                                       throws org.xmldb.api.base.XMLDBException
Throws:
org.xmldb.api.base.XMLDBException

compile

public org.xmldb.api.base.CompiledExpression compile(java.lang.String query)
                                              throws org.xmldb.api.base.XMLDBException
Specified by:
compile in interface org.xmldb.api.modules.XQueryService
Throws:
org.xmldb.api.base.XMLDBException

compileAndCheck

public org.xmldb.api.base.CompiledExpression compileAndCheck(java.lang.String query)
                                                      throws org.xmldb.api.base.XMLDBException,
                                                             XPathException
Throws:
org.xmldb.api.base.XMLDBException
XPathException

queryResource

public org.xmldb.api.base.ResourceSet queryResource(java.lang.String resource,
                                                    java.lang.String query)
                                             throws org.xmldb.api.base.XMLDBException
Specified by:
queryResource in interface org.xmldb.api.modules.XPathQueryService
Specified by:
queryResource in interface org.xmldb.api.modules.XQueryService
Throws:
org.xmldb.api.base.XMLDBException

beginProtected

public void beginProtected()
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

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(java.lang.String ns)
                     throws org.xmldb.api.base.XMLDBException
Specified by:
removeNamespace in interface org.xmldb.api.modules.XPathQueryService
Specified by:
removeNamespace in interface org.xmldb.api.modules.XQueryService
Throws:
org.xmldb.api.base.XMLDBException

setCollection

public void setCollection(org.xmldb.api.base.Collection col)
                   throws org.xmldb.api.base.XMLDBException
Specified by:
setCollection in interface org.xmldb.api.base.Service
Throws:
org.xmldb.api.base.XMLDBException

setNamespace

public void setNamespace(java.lang.String prefix,
                         java.lang.String namespace)
                  throws org.xmldb.api.base.XMLDBException
Specified by:
setNamespace in interface org.xmldb.api.modules.XPathQueryService
Specified by:
setNamespace in interface org.xmldb.api.modules.XQueryService
Throws:
org.xmldb.api.base.XMLDBException

setProperty

public void setProperty(java.lang.String property,
                        java.lang.String value)
                 throws org.xmldb.api.base.XMLDBException
Specified by:
setProperty in interface org.xmldb.api.base.Configurable
Throws:
org.xmldb.api.base.XMLDBException

declareVariable

public void declareVariable(java.lang.String qname,
                            java.lang.Object initialValue)
                     throws org.xmldb.api.base.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 org.xmldb.api.modules.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:
org.xmldb.api.base.XMLDBException

setXPathCompatibility

public void setXPathCompatibility(boolean backwardsCompatible)
Specified by:
setXPathCompatibility in interface org.xmldb.api.modules.XQueryService

setModuleLoadPath

public void setModuleLoadPath(java.lang.String path)
Specified by:
setModuleLoadPath in interface org.xmldb.api.modules.XQueryService

dump

public void dump(org.xmldb.api.base.CompiledExpression expression,
                 java.io.Writer writer)
          throws org.xmldb.api.base.XMLDBException
Throws:
org.xmldb.api.base.XMLDBException


Copyright (C) Wolfgang Meier. All rights reserved.