org.exist.xmldb
Class RemoteXPathQueryService

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

public class RemoteXPathQueryService
extends Object
implements XPathQueryServiceImpl, XQueryService


Constructor Summary
RemoteXPathQueryService(RemoteCollection collection)
          Creates a new RemoteXPathQueryService instance.
 
Method Summary
 void beginProtected()
          Execute all following queries in a protected environment.
 void clearNamespaces()
          The method clearNamespaces
 CompiledExpression compile(String query)
          The method compile
 CompiledExpression compileAndCheck(String query)
          The method compileAndCheck
 void declareVariable(String qname, Object initialValue)
          Declare an external XPath variable and assign a value to it.
 void dump(CompiledExpression expression, Writer writer)
          Return a diagnostic dump of the query.
 void endProtected()
          Close the protected environment.
 ResourceSet execute(CompiledExpression expression)
          Execute a compiled XQuery.
 ResourceSet execute(Source source)
           
 ResourceSet execute(XMLResource res, CompiledExpression expression)
           
 ResourceSet executeStoredQuery(String uri)
          Executes a query which is already stored in the database
 String getName()
          The method getName
 String getNamespace(String prefix)
          The method getNamespace
 String getProperty(String property)
          The method getProperty
 String getVersion()
          The method getVersion
 ResourceSet query(String query)
          The method query
 ResourceSet query(String query, String sortExpr)
          The method query
 ResourceSet query(XMLResource res, String query)
          The method query
 ResourceSet query(XMLResource res, String query, String sortExpr)
          The method query
 ResourceSet queryResource(String resource, String query)
          The method queryResource
 void removeNamespace(String ns)
          The method removeNamespace
 void setCollection(Collection col)
          The method setCollection
 void setModuleLoadPath(String path)
          Calling this method has no effect.
 void setNamespace(String prefix, String namespace)
          The method setNamespace
 void setProperty(String property, String value)
          The method setProperty
 void setXPathCompatibility(boolean backwardsCompatible)
          Enable or disable XPath 1.0 compatibility mode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteXPathQueryService

public RemoteXPathQueryService(RemoteCollection collection)
Creates a new RemoteXPathQueryService instance.

Parameters:
collection - a RemoteCollection value
Method Detail

query

public ResourceSet query(String query)
                  throws XMLDBException
The method query

Specified by:
query in interface XPathQueryService
Specified by:
query in interface XQueryService
Parameters:
query - a String value
Returns:
a ResourceSet value
Throws:
XMLDBException - if an error occurs

query

public ResourceSet query(String query,
                         String sortExpr)
                  throws XMLDBException
The method query

Specified by:
query in interface XPathQueryServiceImpl
Parameters:
query - a String value
sortExpr - a String value
Returns:
a ResourceSet value
Throws:
XMLDBException - if an error occurs

compile

public CompiledExpression compile(String query)
                           throws XMLDBException
The method compile

Specified by:
compile in interface XQueryService
Parameters:
query - a String value
Returns:
a CompiledExpression value
Throws:
XMLDBException - if an error occurs

compileAndCheck

public CompiledExpression compileAndCheck(String query)
                                   throws XMLDBException,
                                          XPathException
The method compileAndCheck

Parameters:
query - a String value
Returns:
a CompiledExpression value
Throws:
XMLDBException - if an error occurs
XPathException - if an error occurs

execute

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

executeStoredQuery

public ResourceSet executeStoredQuery(String uri)
                               throws XMLDBException
Description copied from interface: XPathQueryServiceImpl
Executes a query which is already stored in the database

Specified by:
executeStoredQuery in interface XPathQueryServiceImpl
Parameters:
uri - The URI of the query in the database
Throws:
XMLDBException

query

public ResourceSet query(XMLResource res,
                         String query)
                  throws XMLDBException
The method query

Specified by:
query in interface XPathQueryServiceImpl
Parameters:
res - a XMLResource value
query - a String value
Returns:
a ResourceSet value
Throws:
XMLDBException - if an error occurs

query

public ResourceSet query(XMLResource res,
                         String query,
                         String sortExpr)
                  throws XMLDBException
The method query

Specified by:
query in interface XPathQueryServiceImpl
Parameters:
res - a XMLResource value
query - a String value
sortExpr - a String value
Returns:
a ResourceSet value
Throws:
XMLDBException - if an error occurs

queryResource

public ResourceSet queryResource(String resource,
                                 String query)
                          throws XMLDBException
The method queryResource

Specified by:
queryResource in interface XPathQueryService
Specified by:
queryResource in interface XQueryService
Parameters:
resource - a String value
query - a String value
Returns:
a ResourceSet value
Throws:
XMLDBException - if an error occurs

getVersion

public String getVersion()
                  throws XMLDBException
The method getVersion

Specified by:
getVersion in interface Service
Returns:
a String value
Throws:
XMLDBException - if an error occurs

setCollection

public void setCollection(Collection col)
                   throws XMLDBException
The method setCollection

Specified by:
setCollection in interface Service
Parameters:
col - a Collection value
Throws:
XMLDBException - if an error occurs

getName

public String getName()
               throws XMLDBException
The method getName

Specified by:
getName in interface Service
Returns:
a String value
Throws:
XMLDBException - if an error occurs

getProperty

public String getProperty(String property)
                   throws XMLDBException
The method getProperty

Specified by:
getProperty in interface Configurable
Parameters:
property - a String value
Returns:
a String value
Throws:
XMLDBException - if an error occurs

setProperty

public void setProperty(String property,
                        String value)
                 throws XMLDBException
The method setProperty

Specified by:
setProperty in interface Configurable
Parameters:
property - a String value
value - a String value
Throws:
XMLDBException - if an error occurs

clearNamespaces

public void clearNamespaces()
                     throws XMLDBException
The method clearNamespaces

Specified by:
clearNamespaces in interface XPathQueryService
Specified by:
clearNamespaces in interface XQueryService
Throws:
XMLDBException - if an error occurs

removeNamespace

public void removeNamespace(String ns)
                     throws XMLDBException
The method removeNamespace

Specified by:
removeNamespace in interface XPathQueryService
Specified by:
removeNamespace in interface XQueryService
Parameters:
ns - a String value
Throws:
XMLDBException - if an error occurs

setNamespace

public void setNamespace(String prefix,
                         String namespace)
                  throws XMLDBException
The method setNamespace

Specified by:
setNamespace in interface XPathQueryService
Specified by:
setNamespace in interface XQueryService
Parameters:
prefix - a String value
namespace - a String value
Throws:
XMLDBException - if an error occurs

getNamespace

public String getNamespace(String prefix)
                    throws XMLDBException
The method getNamespace

Specified by:
getNamespace in interface XPathQueryService
Specified by:
getNamespace in interface XQueryService
Parameters:
prefix - a String value
Returns:
a String value
Throws:
XMLDBException - if an error occurs

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

execute

public ResourceSet execute(CompiledExpression expression)
                    throws XMLDBException
Description copied from interface: XQueryService
Execute a compiled XQuery. The implementation should pass all namespaces and variables declared through XQueryService to the compiled XQuery code. Note: CompiledExpression is not thread safe. Please make sure you don't call the same compiled expression from two threads at the same time.

Specified by:
execute in interface XQueryService
Throws:
XMLDBException

execute

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

setXPathCompatibility

public void setXPathCompatibility(boolean backwardsCompatible)
Description copied from interface: XQueryService
Enable or disable XPath 1.0 compatibility mode. In XPath 1.0 compatibility mode, some XQuery expressions will behave different. In particular, additional automatic type conversions will be applied to the operands of numeric operators.

Specified by:
setXPathCompatibility in interface XQueryService

setModuleLoadPath

public void setModuleLoadPath(String path)
Calling this method has no effect. The server loads modules relative to its own context.

Specified by:
setModuleLoadPath in interface XQueryService
See Also:
XQueryService.setModuleLoadPath(java.lang.String)

dump

public void dump(CompiledExpression expression,
                 Writer writer)
          throws XMLDBException
Description copied from interface: XQueryService
Return a diagnostic dump of the query. The query should have been executed before calling this function.

Throws:
XMLDBException

beginProtected

public void beginProtected()
Description copied from interface: XPathQueryServiceImpl
Execute all following queries in a protected environment. Acquire a write lock on all resources in the current collection (i.e. the one from which this service was obtained) before executing the query. If a query spans multiple collections, call beginProtected on the outer collection which contains all the other collections. It is thus guaranteed that documents referenced by the query or the result set are not modified by other threads until XPathQueryServiceImpl.endProtected() is called.

Specified by:
beginProtected in interface XPathQueryServiceImpl

endProtected

public void endProtected()
Description copied from interface: XPathQueryServiceImpl
Close the protected environment. All locks held by the current thread are released. The query result set is no longer guaranteed to be stable. Note: if beginProtected was used, you have to make sure endProtected is called in ALL cases. Otherwise some resource locks may not be released properly.

Specified by:
endProtected in interface XPathQueryServiceImpl


Copyright (C) The eXist-db Project. All rights reserved.