org.exist.xquery
Class ExternalModuleImpl

java.lang.Object
  extended by org.exist.xquery.ExternalModuleImpl
All Implemented Interfaces:
ExternalModule, Module

public class ExternalModuleImpl
extends java.lang.Object
implements ExternalModule

Default implementation of an ExternalModule.


Constructor Summary
ExternalModuleImpl(java.lang.String namespaceURI, java.lang.String prefix)
           
 
Method Summary
 void analyzeGlobalVars()
           
 void declareFunction(UserDefinedFunction func)
          Declare a new function.
 Variable declareVariable(QName qname, java.lang.Object value)
           
 void declareVariable(QName qname, VariableDeclaration decl)
           
 Variable declareVariable(Variable var)
           
 XQueryContext getContext()
           
 java.lang.String getDefaultPrefix()
          Returns an optional default prefix (used if no prefix is supplied with the "import module" directive).
 java.lang.String getDescription()
          Return a short description of this module to be displayed to a user.
 UserDefinedFunction getFunction(QName qname, int arity)
          Try to find the function identified by qname.
 java.util.Iterator<QName> getGlobalVariables()
          Returns an iterator over all global variables in this modules, which were either declared with "declare variable" (for external modules) or set in the module implementation (internal modules).
 java.lang.String getNamespaceURI()
          Returns the namespace URI that uniquely identifies this module.
 java.lang.String getReleaseVersion()
          Returns the release version in which the module was firstly available.
 Expression getRootExpression()
          Returns the root expression associated with this context.
 java.util.Iterator<FunctionSignature> getSignaturesForFunction(QName qname)
          Try to find the signature of the function identified by its QName.
 Source getSource()
          Get the source object this module has been read from.
 boolean isInternalModule()
          Is this an internal module?
 boolean isReady()
          Check if this module has been fully loaded and is ready for use.
 boolean isVarDeclared(QName qname)
           
 FunctionSignature[] listFunctions()
          Returns the signatures of all functions defined within this module.
 boolean moduleIsValid(DBBroker broker)
          Is this module still valid or should it be reloaded from its source?
 void reset(XQueryContext xqueryContext)
          Reset the module's internal state for being reused.
 Variable resolveVariable(QName qname)
           
 void setContext(XQueryContext context)
          Set the XQueryContext of this module.
 void setIsReady(boolean ready)
           
 void setNamespace(java.lang.String prefix, java.lang.String namespace)
           
protected  void setRootExpression(Expression expr)
          Set the root expression for this context.
 void setSource(Source source)
          Set the source object this module has been read from.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExternalModuleImpl

public ExternalModuleImpl(java.lang.String namespaceURI,
                          java.lang.String prefix)
Method Detail

setNamespace

public void setNamespace(java.lang.String prefix,
                         java.lang.String namespace)
Specified by:
setNamespace in interface ExternalModule

setIsReady

public void setIsReady(boolean ready)

isReady

public boolean isReady()
Description copied from interface: Module
Check if this module has been fully loaded and is ready for use.

Specified by:
isReady in interface Module
Returns:
false while the module is being compiled.

getDescription

public java.lang.String getDescription()
Description copied from interface: Module
Return a short description of this module to be displayed to a user.

Specified by:
getDescription in interface Module
Returns:
short description of this module

getReleaseVersion

public java.lang.String getReleaseVersion()
Description copied from interface: Module
Returns the release version in which the module was firstly available.

Specified by:
getReleaseVersion in interface Module
Returns:
available from which release version

getFunction

public UserDefinedFunction getFunction(QName qname,
                                       int arity)
Description copied from interface: ExternalModule
Try to find the function identified by qname. Returns null if the function is undefined.

Specified by:
getFunction in interface ExternalModule

declareFunction

public void declareFunction(UserDefinedFunction func)
Description copied from interface: ExternalModule
Declare a new function. Called by the XQuery compiler when parsing a library module for every function declaration.

Specified by:
declareFunction in interface ExternalModule

getNamespaceURI

public java.lang.String getNamespaceURI()
Description copied from interface: Module
Returns the namespace URI that uniquely identifies this module.

Specified by:
getNamespaceURI in interface Module
Returns:
namespace URI

getDefaultPrefix

public java.lang.String getDefaultPrefix()
Description copied from interface: Module
Returns an optional default prefix (used if no prefix is supplied with the "import module" directive).

Specified by:
getDefaultPrefix in interface Module
Returns:
optional default prefix

isInternalModule

public boolean isInternalModule()
Description copied from interface: Module
Is this an internal module?

Specified by:
isInternalModule in interface Module
Returns:
True if is internal module.

listFunctions

public FunctionSignature[] listFunctions()
Description copied from interface: Module
Returns the signatures of all functions defined within this module.

Specified by:
listFunctions in interface Module
Returns:
signatures of all functions

getSignaturesForFunction

public java.util.Iterator<FunctionSignature> getSignaturesForFunction(QName qname)
Description copied from interface: Module
Try to find the signature of the function identified by its QName.

Specified by:
getSignaturesForFunction in interface Module
Returns:
the function signature or null if the function is not defined.

getGlobalVariables

public java.util.Iterator<QName> getGlobalVariables()
Description copied from interface: Module
Returns an iterator over all global variables in this modules, which were either declared with "declare variable" (for external modules) or set in the module implementation (internal modules).

Specified by:
getGlobalVariables in interface Module
Returns:

declareVariable

public Variable declareVariable(QName qname,
                                java.lang.Object value)
                         throws XPathException
Specified by:
declareVariable in interface Module
Throws:
XPathException

declareVariable

public Variable declareVariable(Variable var)
Specified by:
declareVariable in interface Module

declareVariable

public void declareVariable(QName qname,
                            VariableDeclaration decl)
                     throws XPathException
Specified by:
declareVariable in interface ExternalModule
Throws:
XPathException

isVarDeclared

public boolean isVarDeclared(QName qname)
Specified by:
isVarDeclared in interface Module

resolveVariable

public Variable resolveVariable(QName qname)
                         throws XPathException
Specified by:
resolveVariable in interface Module
Throws:
XPathException

analyzeGlobalVars

public void analyzeGlobalVars()
                       throws XPathException
Specified by:
analyzeGlobalVars in interface ExternalModule
Throws:
XPathException

getSource

public Source getSource()
Description copied from interface: ExternalModule
Get the source object this module has been read from. This is required for query access control.

Specified by:
getSource in interface ExternalModule
Returns:
The source object this module has been read from.

setSource

public void setSource(Source source)
Description copied from interface: ExternalModule
Set the source object this module has been read from. This is required to check the validity of a compiled expression.

Specified by:
setSource in interface ExternalModule

setContext

public void setContext(XQueryContext context)
Description copied from interface: ExternalModule
Set the XQueryContext of this module. This will be a sub-context of the main context as parts of the static context are shared.

Specified by:
setContext in interface ExternalModule

getContext

public XQueryContext getContext()
Specified by:
getContext in interface ExternalModule

moduleIsValid

public boolean moduleIsValid(DBBroker broker)
Description copied from interface: ExternalModule
Is this module still valid or should it be reloaded from its source?

Specified by:
moduleIsValid in interface ExternalModule

reset

public void reset(XQueryContext xqueryContext)
Description copied from interface: Module
Reset the module's internal state for being reused.

Specified by:
reset in interface Module

setRootExpression

protected void setRootExpression(Expression expr)
Set the root expression for this context.

Parameters:
expr -

getRootExpression

public Expression getRootExpression()
Returns the root expression associated with this context.

Specified by:
getRootExpression in interface ExternalModule
Returns:
root expression