org.exist.xquery
Class AbstractInternalModule

java.lang.Object
  extended by org.exist.xquery.AbstractInternalModule
All Implemented Interfaces:
InternalModule, Module
Direct Known Subclasses:
BackupModule, FnModule, InspectionModule, MapModule, MathModule, RequestModule, ResponseModule, SecurityManagerModule, SessionModule, SystemModule, TextModule, TransformModule, UtilModule, ValidationModule, XMLDBModule

public abstract class AbstractInternalModule
extends Object
implements InternalModule

Abstract base class for an InternalModule. Functions are defined in an array of FunctionDef, which is passed to the constructor. A single implementation class can be registered for more than one function signature, given that the signatures differ in name or the number of expected arguments. It is thus possible to implement similar XQuery functions in one single class.

Author:
Wolfgang Meier (wolfgang@exist-db.org), ljo

Nested Class Summary
static class AbstractInternalModule.FunctionComparator
           
 
Constructor Summary
AbstractInternalModule(FunctionDef[] functions, Map<String,List<? extends Object>> parameters)
           
AbstractInternalModule(FunctionDef[] functions, Map<String,List<? extends Object>> parameters, boolean functionsOrdered)
           
 
Method Summary
 Variable declareVariable(QName qname, Object value)
           
 Variable declareVariable(Variable var)
           
 FunctionDef getFunctionDef(QName qname, int arity)
          Returns the implementing class for the function identified by qname or null if it is not defined.
 List<FunctionSignature> getFunctionsByName(QName qname)
          Returns all functions defined in this module matching the specified qname.
 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).
 Iterator<FunctionSignature> getSignaturesForFunction(QName qname)
          Try to find the signature of the function identified by its QName.
 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.
 void reset(XQueryContext xqueryContext)
          Reset the module's internal state for being reused.
 Variable resolveVariable(QName qname)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.exist.xquery.Module
getDefaultPrefix, getDescription, getNamespaceURI, getReleaseVersion
 

Constructor Detail

AbstractInternalModule

public AbstractInternalModule(FunctionDef[] functions,
                              Map<String,List<? extends Object>> parameters)

AbstractInternalModule

public AbstractInternalModule(FunctionDef[] functions,
                              Map<String,List<? extends Object>> parameters,
                              boolean functionsOrdered)
Method Detail

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.

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.

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 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.

getFunctionDef

public FunctionDef getFunctionDef(QName qname,
                                  int arity)
Description copied from interface: InternalModule
Returns the implementing class for the function identified by qname or null if it is not defined. Called by FunctionFactory.

Specified by:
getFunctionDef in interface InternalModule
Returns:
implementing class for the function

getFunctionsByName

public List<FunctionSignature> getFunctionsByName(QName qname)
Description copied from interface: InternalModule
Returns all functions defined in this module matching the specified qname.

Specified by:
getFunctionsByName in interface InternalModule
Returns:
all functions defined in this module

getGlobalVariables

public 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

declareVariable

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

declareVariable

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

resolveVariable

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

isVarDeclared

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

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


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