Public Member Functions | Protected Member Functions
zorba::DynamicContext Class Reference

Instances of the class DynamicContext contain the information that is available at the time the query is executed. More...

#include <zorba/dynamic_context.h>

List of all members.

Public Member Functions

virtual bool addExternalFunctionParam (const String &aName, void *aValue)=0
 Add a name-value pair to this context.
virtual bool addExternalFunctionParameter (const String &aName, ExternalFunctionParameter *aParam)=0
 Add a name-value pair to this context.
virtual bool getContextItem (Item &aItem) const =0
 Returns the current value of the context item.
virtual Item getCurrentDateTime () const =0
 Retrieve the dateTime Item used at the time the query is executed (see setCurrentDateTime()).
virtual Item getDefaultCollection () const =0
 Return the value of the default collection that is used when calling the fn:collection function without a parameter.
virtual bool getExternalFunctionParam (const String &aName, void *&aValue) const =0
 Get the value of a pair that was registered using the addExternalFunctionParam method.
virtual ExternalFunctionParametergetExternalFunctionParameter (const String &aName) const =0
 Get the value of a pair that was registered using the addExternalFunctionParam method.
virtual int getImplicitTimezone () const =0
 Retrieve the implicit timezone used in comparisons or arithmetic operations of date, time, or dateTime values.
virtual bool getVariable (const String &aNamespace, const String &aLocalname, Item &aItem, Iterator_t &aIterator) const =0
 Returns the current value of an external variable.
virtual bool isBoundContextItem () const =0
 Returns true if a context item has been bound to the Dynamic Context.
virtual bool isBoundExternalVariable (const String &aNamespace, const String &aLocalname) const =0
 Returns true if the variable is bound to a value.
virtual bool setContextItem (const Item &aItem)=0
 Defines the context item.
virtual bool setCurrentDateTime (const Item &aDateTimeItem)=0
 Defines the value of the current date time that can be accessed by the fn:current-dateTime() function at the time the query is executed.
virtual bool setDefaultCollection (const Item &aCollectionUri)=0
 Defines the value of the default collection that is used when calling the fn:collection function without a parameter.
virtual bool setImplicitTimezone (int aTimezone)=0
 Defines the variable of the implicit timezone to be used when a date, time, or dateTime value that does not have a timezone is used in a comparison or arithmetic operation.
virtual bool setVariable (const String &aQName, const Item &aItem)=0
 Defines the external variable identified by aQName and assigns it the value of aItem.
virtual bool setVariable (const String &aQName, const Iterator_t &aIterator)=0
 Defines the external variable identified by aQName and assigns it the sequence that is returned by evaluating aIterator.
virtual bool setVariable (const String &aNamespace, const String &aLocalname, const Iterator_t &aIterator)=0
 Defines the external variable identified by an expanded QName and assigns it the sequence that is returned by evaluating aIterator.

Protected Member Functions

virtual ~DynamicContext ()
 Destructor.

Detailed Description

Instances of the class DynamicContext contain the information that is available at the time the query is executed.

The class contains the information that is defined in the XQuery specification (see http://www.w3.org/TR/xquery/#eval_context).

A dynamic context always belongs to a particular query and, hence, can be retrieved by calling getDynamicContext on a compiled query (see XQuery::getDynamicContext()).

Examples:

context.cpp, external_functions.cpp, and simple.cpp.


Constructor & Destructor Documentation

virtual zorba::DynamicContext::~DynamicContext ( ) [inline, protected, virtual]

Destructor.

Definition at line 282 of file dynamic_context.h.


Member Function Documentation

virtual bool zorba::DynamicContext::addExternalFunctionParam ( const String aName,
void *  aValue 
) [pure virtual]

Add a name-value pair to this context.

The value can be accessed in the evaluate method of external functions (see ContextualExternalFunction).

Parameters:
aNamethe name of the parameter to add. If an entry with the same name already exists, the existing entry is replaced.
aValuethe value that can be accessed in the evaluate method.
Returns:
returns true if an entry with the same name did not already exist, false otherwise.
Examples:
external_functions.cpp.
virtual bool zorba::DynamicContext::addExternalFunctionParameter ( const String aName,
ExternalFunctionParameter aParam 
) [pure virtual]

Add a name-value pair to this context.

The value can be accessed in the evaluate method of external functions (see ContextualExternalFunction).

Parameters:
aNamethe name of the parameter to add. If an entry with the same name already exists, the existing entry is replaced.
aParamthe parameter to add
Returns:
true if an entry with the same name did not exist already, false otherwise.
virtual bool zorba::DynamicContext::getContextItem ( Item aItem) const [pure virtual]

Returns the current value of the context item.

Parameters:
aIteman Item representing the current value of the context item.
Returns:
true if the variable has been retrieved successfully, false otherwise.
Exceptions:
ZorbaExceptionif an error occured.
virtual Item zorba::DynamicContext::getCurrentDateTime ( ) const [pure virtual]

Retrieve the dateTime Item used at the time the query is executed (see setCurrentDateTime()).

Returns:
Item the dateTime Item used at the time the query is executed.
Examples:
external_functions.cpp.
virtual Item zorba::DynamicContext::getDefaultCollection ( ) const [pure virtual]

Return the value of the default collection that is used when calling the fn:collection function without a parameter.

Returns:
Item the default collection that is set in this dynamic context.
Exceptions:
ZorbaExceptionif an error occured.
virtual bool zorba::DynamicContext::getExternalFunctionParam ( const String aName,
void *&  aValue 
) const [pure virtual]

Get the value of a pair that was registered using the addExternalFunctionParam method.

This can be used in the evaluate method of external functions (see ContextualExternalFunction).

Parameters:
aNamethe name of the parameter to retrieve
aValuethe value matching the given name if true is returned.
Returns:
true if an entry with the given name was found, false otherwise.
Examples:
external_functions.cpp.
virtual ExternalFunctionParameter* zorba::DynamicContext::getExternalFunctionParameter ( const String aName) const [pure virtual]

Get the value of a pair that was registered using the addExternalFunctionParam method.

This can be used in the evaluate method of external functions (see ContextualExternalFunction).

Parameters:
aNamethe name of the parameter to retrieve
Returns:
the ExternalFunctionParameter* that was added using addExternalFunctionParameter, or 0 if no entry with the given name was found.
virtual int zorba::DynamicContext::getImplicitTimezone ( ) const [pure virtual]

Retrieve the implicit timezone used in comparisons or arithmetic operations of date, time, or dateTime values.

Returns:
int the implicit timezone. Note that 0 is returned if an error occured and an DiagnosticHandler is used.
Exceptions:
ZorbaExceptionif an error occured.
virtual bool zorba::DynamicContext::getVariable ( const String aNamespace,
const String aLocalname,
Item aItem,
Iterator_t aIterator 
) const [pure virtual]

Returns the current value of an external variable.

Exactly one of the two return values (aItem or aIterator) will be non-null; that is, have isNull() == false.

The named external variable may be located in the main query or in any modules imported directly or indirectly by the query.

Parameters:
aNamespacethe namespace URI of the variable's expanded QName
aLocalnamethe local name of the variable's expanded QName
aIteman Item representing the current (single-item) value of the external variable.
aIteratoran Iterator representing the current (possibly multi-item) value of the external variable.
Returns:
true if the variable has been retrieved successfully, false otherwise.
Exceptions:
ZorbaExceptionif an error occured.
virtual bool zorba::DynamicContext::isBoundContextItem ( ) const [pure virtual]

Returns true if a context item has been bound to the Dynamic Context.

virtual bool zorba::DynamicContext::isBoundExternalVariable ( const String aNamespace,
const String aLocalname 
) const [pure virtual]

Returns true if the variable is bound to a value.

Parameters:
aNamespacethe namespace of the qname of the variable to check
aLocalnamethe localname of the qname of the variable to check
virtual bool zorba::DynamicContext::setContextItem ( const Item aItem) [pure virtual]

Defines the context item.

Parameters:
aItemthe Item that is used as value for the context item.
Returns:
true if the context item was set, false otherwise.
Exceptions:
ZorbaExceptionif an error occured (e.g. the given Item is not valid).
Examples:
context.cpp, and simple.cpp.
virtual bool zorba::DynamicContext::setCurrentDateTime ( const Item aDateTimeItem) [pure virtual]

Defines the value of the current date time that can be accessed by the fn:current-dateTime() function at the time the query is executed.

If the current date time has not been set explicitly the value of the date and time is used at the time the query is created or cloned, respectively.

Parameters:
aDateTimeItemthe dateTime Item.
Returns:
true if the variable has been set successfully, false otherwise.
Exceptions:
ZorbaExceptionif an error occured (e.g. the given Item is invalid or not a Item of type dateTime)
Examples:
context.cpp.
virtual bool zorba::DynamicContext::setDefaultCollection ( const Item aCollectionUri) [pure virtual]

Defines the value of the default collection that is used when calling the fn:collection function without a parameter.

Parameters:
aCollectionUrithe URI of the collection used by the fn:collection function.
Returns:
true if the default collection has been set successfully, false otherwise.
Exceptions:
ZorbaExceptionif an error occured.
virtual bool zorba::DynamicContext::setImplicitTimezone ( int  aTimezone) [pure virtual]

Defines the variable of the implicit timezone to be used when a date, time, or dateTime value that does not have a timezone is used in a comparison or arithmetic operation.

Parameters:
aTimezonethe implicit timezone as int that should be used.
Returns:
true if the implicit timezone has been set successfully, false otherwise.
Exceptions:
ZorbaExceptionif an error occured.
virtual bool zorba::DynamicContext::setVariable ( const String aQName,
const Item aItem 
) [pure virtual]

Defines the external variable identified by aQName and assigns it the value of aItem.

aQName may be in one of two forms: A lexical QName (eg. "ns:foo"), or a James Clark-style universal name (eg. "{nsuri}:foo"). If it is a universal name, then this method will find the named external variable in the main query or in any modules imported directly or indirectly by the query. If it is a lexical QName, then it is only possible to resolve the prefix in the the context of the main query, hence only external variables in the main query or those in directly-imported modules may be bound.

Parameters:
aQNamethe QName that identifies the external variable.
aItemthe Item that is used as value for the variable.
Returns:
true if the variable has been set, false otherwise.
Exceptions:
ZorbaExceptionif an error occured (e.g. the given Item is not valid).
Examples:
context.cpp, and simple.cpp.
virtual bool zorba::DynamicContext::setVariable ( const String aQName,
const Iterator_t aIterator 
) [pure virtual]

Defines the external variable identified by aQName and assigns it the sequence that is returned by evaluating aIterator.

aQName may be in one of two forms: A lexical QName (eg. "ns:foo"), or a James Clark-style universal name (eg. "{nsuri}:foo"). If it is a universal name, then this method will find the named external variable in the main query or in any modules imported directly or indirectly by the query. If it is a lexical QName, then it is only possible to resolve the prefix in the the context of the main query, hence only external variables in the main query or those in directly-imported modules may be bound.

Parameters:
aQNamethe QName that identifies the external variable.
aIteratorthe Iterator producing the sequence that is assigned to the variable.
Returns:
true if the variable has been set successfully, false otherwise.
Exceptions:
ZorbaExceptionif an error occured (e.g. the given Iterator is not valid).
virtual bool zorba::DynamicContext::setVariable ( const String aNamespace,
const String aLocalname,
const Iterator_t aIterator 
) [pure virtual]

Defines the external variable identified by an expanded QName and assigns it the sequence that is returned by evaluating aIterator.

The named external variable may be located in the main query or in any modules imported directly or indirectly by the query.

Parameters:
aNamespacethe namespace URI of the variable's expanded QName
aLocalnamethe local name of the variable's expanded QName
aIteratorthe Iterator producing the sequence that is assigned to the variable.
Returns:
true if the variable has been set successfully, false otherwise.
Exceptions:
ZorbaExceptionif an error occured (e.g. the given Iterator is not valid).

The documentation for this class was generated from the following file:
blog comments powered by Disqus