Data Request Broker
2-3-release

fr.gael.drb.query
Class Environment

java.lang.Object
  extended by fr.gael.drb.query.Environment

public class Environment
extends Object

Environment of static analysis and dynamic evaluation of an XQuery.

The environment variable is provided to the query engine in input of its processings. The query engine uses the environment as context either during the static analysis or the dynamic evaluation phases.

The environment provides the active namespaces, the default namespace for unprefixed elements, types or functions. The environment also provides the base URI as well as mechanisms to resolve external variables that may be required by the XQuery script to be processed.

The current implementation of the environment does not already support schema definitions, external functions, collations, collections and validation mechanism.

It is important to notice that environment provides information that may be overrided during the different processing phases of the XQuery script. As an example, the default namespace used during the processing may differ from the environment is the XQuery defines explicitely a new one.


Field Summary
static String DRB_FUNCTIONS_PREFIX
          Prefix for DRB built-in functions drb = "http://www.gael.fr/drb"
static String DRB_FUNCTIONS_URI
          Namespace for DRB built-in functions drb = "http://www.gael.fr/drb"
static String GAEL_FUNCTIONS_URI
          Namespace for GAEL built-in functions gael = "http://www.gael.fr"
protected  boolean isBackwardCompatibilityModeSet
          True if the compatibility mode property has been set by the user or deduced from the corresponding system property.
static String MATH_FUNCTIONS_URI
          Namespace for Math built-in functions math = "http://exslt.org/math"
protected  ParameterResolver resolver
          Host the deprecated parameter resolver.
static String XPATH_FUNCTIONS_URI
          Namespace for XPath built-in functions fn = "http://www.w3.org/2005/xpath-functions"
static String XQT_ERRORS_PREFIX
          Prefix for XPath and XQuery error codes and messages err = "http://www.w3.org/2005/xqt-errors"
static String XQT_ERRORS_URI
          Namespace for XPath and XQuery error codes and messages err = "http://www.w3.org/2005/xqt-errors"
static String XQUERY_LOCAL_FUNCTIONS_URI
          Namespace for XPath and XQuery error codes and messages local = "http://www.w3.org/2005/xquery-local-functions"
 
Constructor Summary
Environment()
          Environment constructor.
 
Method Summary
protected  void addExternalVariable(ExternalVariable variable)
          Add external variables.
 boolean containsExternalVariable(fr.gael.drb.query.QName name)
          Check if an external variable is declared.
 boolean containsExternalVariable(String name)
          Check if an external variable is declared.
 String getBaseURI()
          Returns the base URI of the enviroment.
 String getDefaultElementNamespaceURI()
          Returns the default namespace URI of elements and types.
 String getDefaultFunctionNamespaceURI()
          Returns the default namespace URI of functions.
 ExternalVariable getExternalVariable(fr.gael.drb.query.QName name)
          Return an external variable if already declared.
 ExternalVariable getExternalVariable(String name)
          Return an external variable if already declared.
protected  Map<fr.gael.drb.query.QName,ExternalVariable> getExternalVariableMap()
          Return a reference to the external variable list.
 ExternalVariable[] getExternalVariables()
          Returns the set of external variables.
 Namespace getNamespace()
          Returns the namespace of the environment.
 boolean isBackwardCompatibilityMode()
          True denotes whether static and dynamic evaluations should attempt to support depreciated syntaxes, expressions or behaviors.
 fr.gael.drb.query.QName resolveQName(String name)
          Returns a qualified name from its string form.
 fr.gael.drb.query.QName resolveQName(String name, String default_namespace)
          Returns a qualified name from its string form.
 void setBackwardCompatibilityMode(boolean isBackwardCompatibilityMode)
          True denotes whether static and dynamic evaluations should attempt to support depreciated syntaxes, expressions or behaviors.
 void setBaseURI(String base_uri)
          Set the base URI of the environment.
 void setDefaultElementNamespaceURI(String namespace_uri)
          Set the default namespace URI for elements and types.
 void setDefaultFunctionNamespaceURI(String namespace_uri)
          Set the default namespace URI for functions.
protected  void setExternalVariableMap(Map<fr.gael.drb.query.QName,ExternalVariable> variable_list)
          Set a new external variable list.
 void setNamespace(Namespace namespace)
          Set the namespace provided in parameter.
 String toString()
          Returns relevant information of the environment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XPATH_FUNCTIONS_URI

public static final String XPATH_FUNCTIONS_URI
Namespace for XPath built-in functions fn = "http://www.w3.org/2005/xpath-functions"

See Also:
Constant Field Values

XQT_ERRORS_PREFIX

public static final String XQT_ERRORS_PREFIX
Prefix for XPath and XQuery error codes and messages err = "http://www.w3.org/2005/xqt-errors"

See Also:
Constant Field Values

XQT_ERRORS_URI

public static final String XQT_ERRORS_URI
Namespace for XPath and XQuery error codes and messages err = "http://www.w3.org/2005/xqt-errors"

See Also:
Constant Field Values

XQUERY_LOCAL_FUNCTIONS_URI

public static final String XQUERY_LOCAL_FUNCTIONS_URI
Namespace for XPath and XQuery error codes and messages local = "http://www.w3.org/2005/xquery-local-functions"

See Also:
Constant Field Values

DRB_FUNCTIONS_PREFIX

public static final String DRB_FUNCTIONS_PREFIX
Prefix for DRB built-in functions drb = "http://www.gael.fr/drb"

See Also:
Constant Field Values

GAEL_FUNCTIONS_URI

public static final String GAEL_FUNCTIONS_URI
Namespace for GAEL built-in functions gael = "http://www.gael.fr"

See Also:
Constant Field Values

DRB_FUNCTIONS_URI

public static final String DRB_FUNCTIONS_URI
Namespace for DRB built-in functions drb = "http://www.gael.fr/drb"

See Also:
Constant Field Values

MATH_FUNCTIONS_URI

public static final String MATH_FUNCTIONS_URI
Namespace for Math built-in functions math = "http://exslt.org/math"

See Also:
Constant Field Values

resolver

protected ParameterResolver resolver
Host the deprecated parameter resolver.


isBackwardCompatibilityModeSet

protected boolean isBackwardCompatibilityModeSet
True if the compatibility mode property has been set by the user or deduced from the corresponding system property. False otherwise.

Constructor Detail

Environment

public Environment()
Environment constructor. This operations initialises the environment with default values.

The following default namespaces are inserted:

xml http://www.w3.org/XML/1998/namespace
fn http://www.w3.org/2005/xpath-functions
xs http://www.w3.org/2001/XMLSchema
xsi http://www.w3.org/2001/XMLSchema-instance
xdt http://www.w3.org/2003/11/xpath-datatypes
local http://www.w3.org/2005/xquery-local-functions
drb http://www.gael.fr/drb
math http://exslt.org/math
gael http://www.gael.fr
esa http://www.esa.int

Method Detail

getNamespace

public Namespace getNamespace()
Returns the namespace of the environment.

Returns:
the namespace of the current environment.

resolveQName

public fr.gael.drb.query.QName resolveQName(String name)
Returns a qualified name from its string form.

Returns:
the qualified name of the passed string.

resolveQName

public fr.gael.drb.query.QName resolveQName(String name,
                                            String default_namespace)
Returns a qualified name from its string form.

Returns:
the qualified name of the passed string.

setNamespace

public void setNamespace(Namespace namespace)
Set the namespace provided in parameter. Any previous namespace will be discarded.

Parameters:
namespace - the namespace to be considered.

getDefaultElementNamespaceURI

public String getDefaultElementNamespaceURI()
Returns the default namespace URI of elements and types.

Returns:
the default namspace URI if exist or null otherwise.

setDefaultElementNamespaceURI

public void setDefaultElementNamespaceURI(String namespace_uri)
Set the default namespace URI for elements and types. Any previous default namespace URI will be overriden.

Parameters:
namespace_uri - the new default namespace URI to consider.

getDefaultFunctionNamespaceURI

public String getDefaultFunctionNamespaceURI()
Returns the default namespace URI of functions.

Returns:
the default namspace URI if exist or null otherwise.

setDefaultFunctionNamespaceURI

public void setDefaultFunctionNamespaceURI(String namespace_uri)
Set the default namespace URI for functions. Any previous default namespace URI will be overriden.

Parameters:
namespace_uri - the new default namespace URI to consider.

getBaseURI

public String getBaseURI()
Returns the base URI of the enviroment.

Returns:
the base URI if exist or null otherwise.

setBaseURI

public void setBaseURI(String base_uri)
Set the base URI of the environment. Any previous base URI will be overriden.

Parameters:
base_uri - the new base URI to consider.

addExternalVariable

protected void addExternalVariable(ExternalVariable variable)
Add external variables.

Parameters:
variable - the external variable to be added.

setExternalVariableMap

protected void setExternalVariableMap(Map<fr.gael.drb.query.QName,ExternalVariable> variable_list)
Set a new external variable list. Any previous list will be discarded by this operation. In order to keep the class consistent, null reference is avoided. No object is duplicated.

Parameters:
variable_list - new list of external variables.

getExternalVariableMap

protected Map<fr.gael.drb.query.QName,ExternalVariable> getExternalVariableMap()
Return a reference to the external variable list.

Returns:
the external variable list.

getExternalVariable

public ExternalVariable getExternalVariable(String name)
Return an external variable if already declared. The external variable may originate from the environment creator or may have been added during the satic analysis phase of the XQuery processing.

Parameters:
name - the string form of the variable qualified name.
Returns:
the external variable.

getExternalVariable

public ExternalVariable getExternalVariable(fr.gael.drb.query.QName name)
Return an external variable if already declared. The external variable may originate from the environment creator or may have been added during the satic analysis phase of the XQuery processing.

Parameters:
name - the variable qualified name.
Returns:
the external variable.

getExternalVariables

public ExternalVariable[] getExternalVariables()
Returns the set of external variables. The external variable may originate from the environment creator or may have been added during the satic analysis phase of the XQuery processing.

Returns:
the array of external variables, if any, or null otherwise.

containsExternalVariable

public boolean containsExternalVariable(String name)
Check if an external variable is declared.

Parameters:
name - string form of the qualified name of the external variable.
Returns:
true if the variable is declared, false otherwise.

containsExternalVariable

public boolean containsExternalVariable(fr.gael.drb.query.QName name)
Check if an external variable is declared.

Parameters:
name - string form of the qualified name of the external variable.
Returns:
true if the variable is declared, false otherwise.

setBackwardCompatibilityMode

public void setBackwardCompatibilityMode(boolean isBackwardCompatibilityMode)
True denotes whether static and dynamic evaluations should attempt to support depreciated syntaxes, expressions or behaviors. This mode does not guarantee that all previous behaviors could be emulated and in particular for more than one backward software version. Callers should not rely on this mode but only for very short periods when the latest version is required but efforts to adapt the software to all incompatible improvements is too heavy, or in equivalent situation.

Parameters:
isBackwardCompatibilityMode - the mode to set.

isBackwardCompatibilityMode

public boolean isBackwardCompatibilityMode()
True denotes whether static and dynamic evaluations should attempt to support depreciated syntaxes, expressions or behaviors.

This mode does not guarantee that all previous behaviors could be emulated and in particular for more than one backward software version. Callers should not rely on this mode but only for very short periods when the latest version is required but efforts to adapt the software to all incompatible improvements is too heavy, or in equivalent situation.

The default value is false, unless an explicit user call to the setBackwardCompatibilityMode(boolean) method with a true parameter or a 'true' value of the system property fr.gael.drb.query.BackwardCompatibilityMode.

Returns:
the backward compatibility mode
See Also:
setBackwardCompatibilityMode(boolean)

toString

public String toString()
Returns relevant information of the environment.

Overrides:
toString in class Object
Returns:
environmental information.

Data Request Broker - DRB API®
2-3-release

Copyright© 2001-2009 GAEL Consultant. All rights reserved. Use is subject to license terms .