org.exist.xquery
Class ModuleContext

java.lang.Object
  extended by org.exist.xquery.XQueryContext
      extended by org.exist.xquery.ModuleContext

public class ModuleContext
extends XQueryContext

Subclass of XQueryContext for imported modules.

Author:
wolf

Field Summary
 
Fields inherited from class org.exist.xquery.XQueryContext
BUILT_IN_MODULE_CLASS_ATTRIBUTE, BUILT_IN_MODULE_SOURCE_ATTRIBUTE, BUILT_IN_MODULE_URI_ATTRIBUTE, CONFIGURATION_ELEMENT_NAME, CONFIGURATION_MODULE_ELEMENT_NAME, CONFIGURATION_MODULES_ELEMENT_NAME, ENABLE_QUERY_REWRITING_ATTRIBUTE, HTTP_SESSIONVAR_XMLDB_USER, PROPERTY_BUILT_IN_MODULES, PROPERTY_ENABLE_QUERY_REWRITING, PROPERTY_STATIC_MODULE_MAP, PROPERTY_XQUERY_BACKWARD_COMPATIBLE, PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL, XQUERY_BACKWARD_COMPATIBLE_ATTRIBUTE, XQUERY_CONTEXTVAR_XQUERY_UPDATE_ERROR, XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL_ATTRIBUTE, XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL_DEFAULT
 
Constructor Summary
ModuleContext(XQueryContext parentContext, String modulePrefix, String moduleNamespace, String location)
           
 
Method Summary
 void addDynamicOption(String qnameString, String contents)
          for dynamic run-time options i.e.
 XQueryContext copyContext()
           
 void declareInScopeNamespace(String prefix, String uri)
          Declare an in-scope namespace.
 LocalVariable declareVariableBinding(LocalVariable var)
          Declare a local variable.
 void expressionEnd(Expression expr)
           
 void expressionStart(Expression expr)
           
 Iterator getAllModules()
           
 AnyURIValue getBaseURI()
          Get the base URI of the evaluation context.
 DBBroker getBroker()
          Get the DBBroker instance used for the current query.
 XMLGregorianCalendar getCalendar()
           
 int getCurrentStackSize()
          Returns the current size of the stack.
 DebuggeeJoint getDebuggeeJoint()
           
 MemTreeBuilder getDocumentBuilder()
          Get the document builder currently used for creating temporary document fragments.
 MemTreeBuilder getDocumentBuilder(boolean explicitCreation)
           
 String getInheritedNamespace(String prefix)
           
 String getInheritedPrefix(String uri)
           
 String getInScopeNamespace(String prefix)
           
 String getInScopePrefix(String uri)
           
 Module getModule(String namespaceURI)
          Get the built-in module registered for the given namespace URI.
 String getPrefixForURI(String uri)
          First checks the parent context for in-scope namespaces, then the module's static context.
 Profiler getProfiler()
          Returns the Profiler instance of this context if profiling is enabled.
 XQueryContext getRootContext()
           
 Module getRootModule(String namespaceURI)
           
 Iterator getRootModules()
           
 DocumentSet getStaticallyKnownDocuments()
           
 String getURIForPrefix(String prefix)
          First checks the parent context for in-scope namespaces, then the module's static context.
 Map<QName,Variable> getVariables()
           
 XQueryWatchDog getWatchDog()
           
 Object getXQueryContextVar(String name)
          Delegate to parent context
 boolean hasParent()
          Returns true if this context has a parent context (means it is a module context).
 boolean isDebugMode()
           
 Module loadBuiltInModule(String namespaceURI, String moduleClass)
          Overwritten method: the module will be loaded by the parent context, but we need to declare its namespace in the module context.
 LocalVariable markLocalVariables(boolean newContext)
          Returns the last variable on the local variable stack.
 void popDocumentContext()
           
 void popInScopeNamespaces()
           
 void popLocalVariables(LocalVariable var)
          Restore the local variable stack to the position marked by variable var.
 void pushDocumentContext()
          Push any document fragment created within the current execution context on the stack.
 void pushInScopeNamespaces()
           
 void pushInScopeNamespaces(boolean inherit)
          Push all in-scope namespace declarations onto the stack.
 void registerUpdateListener(UpdateListener listener)
           
 Variable resolveVariable(QName qname)
          Try to resolve a variable.
 void setBaseURI(AnyURIValue uri)
          Set the base URI for the evaluation context.
 void setModule(String namespaceURI, Module module)
           
 void setParentContext(XQueryContext parentContext)
           
 void setXQueryContextVar(String name, Object XQvar)
          Delegate to parent context
 void stackEnter(Expression expr)
           
 void stackLeave(Expression expr)
           
 void updateContext(XQueryContext from)
          Update the current dynamic context using the properties of another context.
 void updateModuleRefs(XQueryContext rootContext)
           
 
Methods inherited from class org.exist.xquery.XQueryContext
addForwardReference, addLockedDocument, addModifiedDoc, addOption, analyzeAndOptimizeIfModulesChanged, checkModulesValid, checkOptions, declareFunction, declareGlobalVariable, declareNamespace, declareNamespaces, declareVariable, declareVariable, finishBatchTransaction, functionEnd, functionStart, getAccessContext, getAttribute, getBatchTransaction, getCollator, getContext, getContextPosition, getDefaultCollation, getDefaultCollator, getDefaultElementNamespace, getDefaultElementNamespaceSchema, getDefaultFunctionNamespace, getExpressionCount, getImplicitTimeZone, getModuleLoadPath, getModules, getOption, getPDP, getPragma, getProtectedDocs, getRootExpression, getSharedNamePool, getSignaturesForFunction, getSource, getSourceKey, getSourceType, getUser, hasBatchTransaction, importModule, inheritNamespaces, inProtectedMode, isBackwardsCompatible, isBaseURIDeclared, isProfilingEnabled, isProfilingEnabled, isRaiseErrorOnFailedRetrieval, isShared, isVarDeclared, loadModuleClasses, localFunctions, lockDocumentsOnLoad, mapModule, optimizationsEnabled, orderEmptyGreatest, popNamespaceContext, prepare, preserveNamespaces, proceed, proceed, proceed, pushNamespaceContext, removeNamespace, reset, reset, resolveForwardReferences, resolveFunction, resolveVariable, setAttribute, setBackwardsCompatibility, setBaseURI, setBatchTransactionTrigger, setBroker, setCalendar, setContextPosition, setDebuggeeJoint, setDebugMode, setDefaultCollation, setDefaultElementNamespace, setDefaultElementNamespaceSchema, setDefaultFunctionNamespace, setInheritNamespaces, setModuleLoadPath, setOrderEmptyGreatest, setPreserveNamespaces, setProtectedDocs, setRootExpression, setShared, setSource, setStaticallyKnownDocuments, setStaticallyKnownDocuments, setStripWhitespace, setTimeZone, startBatchTransaction, storeTemporaryDoc, stripWhitespace, tailRecursiveCall
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModuleContext

public ModuleContext(XQueryContext parentContext,
                     String modulePrefix,
                     String moduleNamespace,
                     String location)
Parameters:
parentContext -
Method Detail

setParentContext

public void setParentContext(XQueryContext parentContext)

setModule

public void setModule(String namespaceURI,
                      Module module)
Overrides:
setModule in class XQueryContext

hasParent

public boolean hasParent()
Description copied from class: XQueryContext
Returns true if this context has a parent context (means it is a module context).

Overrides:
hasParent in class XQueryContext
Returns:
False.

getRootContext

public XQueryContext getRootContext()
Overrides:
getRootContext in class XQueryContext

updateContext

public void updateContext(XQueryContext from)
Description copied from class: XQueryContext
Update the current dynamic context using the properties of another context. This is needed by Eval.

Overrides:
updateContext in class XQueryContext

copyContext

public XQueryContext copyContext()
Overrides:
copyContext in class XQueryContext

addDynamicOption

public void addDynamicOption(String qnameString,
                             String contents)
                      throws XPathException
Description copied from class: XQueryContext
for dynamic run-time options i.e. util:declare-option

Overrides:
addDynamicOption in class XQueryContext
Throws:
XPathException

getStaticallyKnownDocuments

public DocumentSet getStaticallyKnownDocuments()
                                        throws XPathException
Overrides:
getStaticallyKnownDocuments in class XQueryContext
Returns:
set of statically known documents.
Throws:
XPathException

getModule

public Module getModule(String namespaceURI)
Description copied from class: XQueryContext
Get the built-in module registered for the given namespace URI.

Overrides:
getModule in class XQueryContext
Returns:
built-in module

getRootModules

public Iterator getRootModules()
Overrides:
getRootModules in class XQueryContext
Returns:
iterator over all modules registered in the entire context tree

getAllModules

public Iterator getAllModules()
Overrides:
getAllModules in class XQueryContext

getRootModule

public Module getRootModule(String namespaceURI)
Overrides:
getRootModule in class XQueryContext

loadBuiltInModule

public Module loadBuiltInModule(String namespaceURI,
                                String moduleClass)
Overwritten method: the module will be loaded by the parent context, but we need to declare its namespace in the module context.

Overrides:
loadBuiltInModule in class XQueryContext

updateModuleRefs

public void updateModuleRefs(XQueryContext rootContext)

getWatchDog

public XQueryWatchDog getWatchDog()
Overrides:
getWatchDog in class XQueryContext

getProfiler

public Profiler getProfiler()
Description copied from class: XQueryContext
Returns the Profiler instance of this context if profiling is enabled.

Overrides:
getProfiler in class XQueryContext
Returns:
the profiler instance.

getCalendar

public XMLGregorianCalendar getCalendar()
Overrides:
getCalendar in class XQueryContext

getBaseURI

public AnyURIValue getBaseURI()
                       throws XPathException
Description copied from class: XQueryContext
Get the base URI of the evaluation context. This is the URI returned by the fn:base-uri() function.

Overrides:
getBaseURI in class XQueryContext
Returns:
base URI of the evaluation context
Throws:
XPathException - if an error occurs

setBaseURI

public void setBaseURI(AnyURIValue uri)
Description copied from class: XQueryContext
Set the base URI for the evaluation context. This is the URI returned by the fn:base-uri() function.

Overrides:
setBaseURI in class XQueryContext

setXQueryContextVar

public void setXQueryContextVar(String name,
                                Object XQvar)
Delegate to parent context

Overrides:
setXQueryContextVar in class XQueryContext
Parameters:
name - The variable name
XQvar - The variable value, may be of any xs: type
See Also:
XQueryContext.setXQueryContextVar(String, Object)

getXQueryContextVar

public Object getXQueryContextVar(String name)
Delegate to parent context

Overrides:
getXQueryContextVar in class XQueryContext
Parameters:
name - The variable name
Returns:
The variable value indicated by name.
See Also:
XQueryContext.getXQueryContextVar(String)

getBroker

public DBBroker getBroker()
Description copied from class: XQueryContext
Get the DBBroker instance used for the current query. The DBBroker is the main database access object, providing access to all internal database functions.

Overrides:
getBroker in class XQueryContext
Returns:
DBBroker instance

getDocumentBuilder

public MemTreeBuilder getDocumentBuilder()
Description copied from class: XQueryContext
Get the document builder currently used for creating temporary document fragments. A new document builder will be created on demand.

Overrides:
getDocumentBuilder in class XQueryContext
Returns:
document builder

getDocumentBuilder

public MemTreeBuilder getDocumentBuilder(boolean explicitCreation)
Overrides:
getDocumentBuilder in class XQueryContext

pushDocumentContext

public void pushDocumentContext()
Description copied from class: XQueryContext
Push any document fragment created within the current execution context on the stack.

Overrides:
pushDocumentContext in class XQueryContext

markLocalVariables

public LocalVariable markLocalVariables(boolean newContext)
Description copied from class: XQueryContext
Returns the last variable on the local variable stack. The current variable context can be restored by passing the return value to XQueryContext.popLocalVariables(LocalVariable).

Overrides:
markLocalVariables in class XQueryContext
Returns:
last variable on the local variable stack

popLocalVariables

public void popLocalVariables(LocalVariable var)
Description copied from class: XQueryContext
Restore the local variable stack to the position marked by variable var.

Overrides:
popLocalVariables in class XQueryContext

declareVariableBinding

public LocalVariable declareVariableBinding(LocalVariable var)
                                     throws XPathException
Description copied from class: XQueryContext
Declare a local variable. This is called by variable binding expressions like "let" and "for".

Overrides:
declareVariableBinding in class XQueryContext
Throws:
XPathException

resolveVariable

public Variable resolveVariable(QName qname)
                         throws XPathException
Try to resolve a variable.

Overrides:
resolveVariable in class XQueryContext
Parameters:
qname - the qualified name of the variable
Returns:
the declared Variable object
Throws:
XPathException - if the variable is unknown

getVariables

public Map<QName,Variable> getVariables()
Overrides:
getVariables in class XQueryContext

getCurrentStackSize

public int getCurrentStackSize()
Description copied from class: XQueryContext
Returns the current size of the stack. This is used to determine where a variable has been declared.

Overrides:
getCurrentStackSize in class XQueryContext
Returns:
current size of the stack

popDocumentContext

public void popDocumentContext()
Overrides:
popDocumentContext in class XQueryContext

getURIForPrefix

public String getURIForPrefix(String prefix)
First checks the parent context for in-scope namespaces, then the module's static context.

Overrides:
getURIForPrefix in class XQueryContext
Parameters:
prefix - the prefix to look up
Returns:
the namespace currently mapped to that prefix

getPrefixForURI

public String getPrefixForURI(String uri)
First checks the parent context for in-scope namespaces, then the module's static context.

Overrides:
getPrefixForURI in class XQueryContext
Parameters:
uri - the URI to look up
Returns:
a prefix for the URI

getInScopeNamespace

public String getInScopeNamespace(String prefix)
Overrides:
getInScopeNamespace in class XQueryContext

getInScopePrefix

public String getInScopePrefix(String uri)
Overrides:
getInScopePrefix in class XQueryContext

getInheritedNamespace

public String getInheritedNamespace(String prefix)
Overrides:
getInheritedNamespace in class XQueryContext

getInheritedPrefix

public String getInheritedPrefix(String uri)
Overrides:
getInheritedPrefix in class XQueryContext

declareInScopeNamespace

public void declareInScopeNamespace(String prefix,
                                    String uri)
Description copied from class: XQueryContext
Declare an in-scope namespace. This is called during query execution.

Overrides:
declareInScopeNamespace in class XQueryContext

pushInScopeNamespaces

public void pushInScopeNamespaces(boolean inherit)
Description copied from class: XQueryContext
Push all in-scope namespace declarations onto the stack.

Overrides:
pushInScopeNamespaces in class XQueryContext

pushInScopeNamespaces

public void pushInScopeNamespaces()
Overrides:
pushInScopeNamespaces in class XQueryContext

popInScopeNamespaces

public void popInScopeNamespaces()
Overrides:
popInScopeNamespaces in class XQueryContext

registerUpdateListener

public void registerUpdateListener(UpdateListener listener)
Overrides:
registerUpdateListener in class XQueryContext

getDebuggeeJoint

public DebuggeeJoint getDebuggeeJoint()
Overrides:
getDebuggeeJoint in class XQueryContext

isDebugMode

public boolean isDebugMode()
Overrides:
isDebugMode in class XQueryContext

expressionStart

public void expressionStart(Expression expr)
                     throws TerminatedException
Overrides:
expressionStart in class XQueryContext
Throws:
TerminatedException

expressionEnd

public void expressionEnd(Expression expr)
Overrides:
expressionEnd in class XQueryContext

stackEnter

public void stackEnter(Expression expr)
                throws TerminatedException
Overrides:
stackEnter in class XQueryContext
Throws:
TerminatedException

stackLeave

public void stackLeave(Expression expr)
Overrides:
stackLeave in class XQueryContext


Copyright (C) Wolfgang Meier. All rights reserved.