Instances of the class DynamicContext contain the information that is available at the time the query is executed. More...
#include <zorba/dynamic_context.h>
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 ExternalFunctionParameter * | getExternalFunctionParameter (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. |
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()).
Definition at line 43 of file dynamic_context.h.
virtual zorba::DynamicContext::~DynamicContext | ( | ) | [inline, protected, virtual] |
Destructor.
Definition at line 282 of file dynamic_context.h.
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).
aName | the name of the parameter to add. If an entry with the same name already exists, the existing entry is replaced. |
aValue | the value that can be accessed in the evaluate method. |
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).
aName | the name of the parameter to add. If an entry with the same name already exists, the existing entry is replaced. |
aParam | the parameter to add |
Returns the current value of the context item.
aItem | an Item representing the current value of the context item. |
ZorbaException | if 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()).
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.
ZorbaException | if 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).
aName | the name of the parameter to retrieve |
aValue | the value matching the given name if true is returned. |
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).
aName | the name of the parameter to retrieve |
virtual int zorba::DynamicContext::getImplicitTimezone | ( | ) | const [pure virtual] |
Retrieve the implicit timezone used in comparisons or arithmetic operations of date, time, or dateTime values.
ZorbaException | if 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.
aNamespace | the namespace URI of the variable's expanded QName |
aLocalname | the local name of the variable's expanded QName |
aItem | an Item representing the current (single-item) value of the external variable. |
aIterator | an Iterator representing the current (possibly multi-item) value of the external variable. |
ZorbaException | if 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.
aNamespace | the namespace of the qname of the variable to check |
aLocalname | the localname of the qname of the variable to check |
Defines the context item.
aItem | the Item that is used as value for the context item. |
ZorbaException | if an error occured (e.g. the given Item is not valid). |
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.
aDateTimeItem | the dateTime Item. |
ZorbaException | if an error occured (e.g. the given Item is invalid or not a Item of type dateTime) |
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.
aCollectionUri | the URI of the collection used by the fn:collection function. |
ZorbaException | if 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.
aTimezone | the implicit timezone as int that should be used. |
ZorbaException | if 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.
aQName | the QName that identifies the external variable. |
aItem | the Item that is used as value for the variable. |
ZorbaException | if an error occured (e.g. the given Item is not valid). |
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.
aQName | the QName that identifies the external variable. |
aIterator | the Iterator producing the sequence that is assigned to the variable. |
ZorbaException | if 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.
aNamespace | the namespace URI of the variable's expanded QName |
aLocalname | the local name of the variable's expanded QName |
aIterator | the Iterator producing the sequence that is assigned to the variable. |
ZorbaException | if an error occured (e.g. the given Iterator is not valid). |