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_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_XQUERY_BACKWARD_COMPATIBLE, XQUERY_BACKWARD_COMPATIBLE_ATTRIBUTE, XQUERY_CONTEXTVAR_XQUERY_UPDATE_ERROR
 
Constructor Summary
ModuleContext(XQueryContext parentContext, String modulePrefix, String moduleNamespace)
           
 
Method Summary
 XQueryContext copyContext()
           
 void declareInScopeNamespace(String prefix, String uri)
          Declare an in-scope namespace.
 LocalVariable declareVariableBinding(LocalVariable var)
          Declare a local variable.
 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.
 MemTreeBuilder getDocumentBuilder()
          Get the document builder currently used for creating temporary document fragments.
 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.
 Iterator getModules()
           
 String getPrefixForURI(String uri)
          First checks the parent context for in-scope namespaces, then the module's static context.
 DocumentSet getStaticallyKnownDocuments()
           
 String getURIForPrefix(String prefix)
          First checks the parent context for in-scope namespaces, then the module's static context.
 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).
 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()
          Push all in-scope namespace declarations onto the stack.
 void registerUpdateListener(UpdateListener listener)
           
 void setBaseURI(AnyURIValue uri)
          Set the base URI for the evaluation context.
 void setXQueryContextVar(String name, Object XQvar)
          Delegate to parent context
 void updateContext(XQueryContext from)
          Update the current dynamic context using the properties of another context.
 
Methods inherited from class org.exist.xquery.XQueryContext
addForwardReference, addLockedDocument, addOption, checkModulesValid, checkOptions, declareFunction, declareGlobalVariable, declareNamespace, declareNamespaces, declareVariable, finishBatchTransaction, functionEnd, functionStart, getAccessContext, getAttribute, getBatchTransaction, getCollator, getContextPosition, getDefaultCollation, getDefaultCollator, getDefaultElementNamespace, getDefaultElementNamespaceSchema, getDefaultFunctionNamespace, getExpressionCount, getImplicitTimeZone, getModuleLoadPath, getOption, getPDP, getPragma, getProfiler, getProtectedDocs, getRootExpression, getSharedNamePool, getSignaturesForFunction, getSourceKey, getSourceType, getUser, hasBatchTransaction, importModule, inheritNamespaces, inProtectedMode, isBackwardsCompatible, isBaseURIDeclared, isProfilingEnabled, isProfilingEnabled, isVarDeclared, loadModuleClasses, localFunctions, lockDocumentsOnLoad, optimizationsEnabled, orderEmptyGreatest, popNamespaceContext, prepare, preserveNamespaces, proceed, proceed, proceed, pushNamespaceContext, recover, removeNamespace, reset, reset, resolveForwardReferences, resolveFunction, resolveVariable, resolveVariable, setAttribute, setBackwardsCompatibility, setBaseURI, setBatchTransactionTrigger, setBroker, setCalendar, setContextPosition, setDefaultCollation, setDefaultElementNamespace, setDefaultElementNamespaceSchema, setDefaultFunctionNamespace, setInheritNamespaces, setModuleLoadPath, setOrderEmptyGreatest, setPreserveNamespaces, setProtectedDocs, setRootExpression, setShared, setSourceKey, setSourceType, setStaticallyKnownDocuments, setStaticallyKnownDocuments, setStripWhitespace, setTimeZone, setXQuerySerializer, 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)
Parameters:
parentContext -
Method Detail

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:
TRUE is context has parent context.

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

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

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

getModules

public Iterator getModules()
Overrides:
getModules in class XQueryContext
Returns:
iterator over all built-in modules currently registered.

getWatchDog

public XQueryWatchDog getWatchDog()
Overrides:
getWatchDog in class XQueryContext

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

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

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()
Description copied from class: XQueryContext
Push all in-scope namespace declarations onto the stack.

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


Copyright (C) Wolfgang Meier. All rights reserved.