com.xml_project.morganaxquery
Class StaticXQueryContext

java.lang.Object
  extended by com.xml_project.morganaxquery.StaticXQueryContext

public class StaticXQueryContext
extends java.lang.Object

The static context of a query (XPath or XQuery).


Nested Class Summary
static class StaticXQueryContext.Modes
          The constructions modes.
static class StaticXQueryContext.OrderingModes
          The ordering modes.
 
Constructor Summary
StaticXQueryContext(com.xml_project.morganaxquery.configuration.XQueryConfiguration config, com.xml_project.morganaxquery.CompilerCommons.CompilerMode mode)
          Creates a new static query context.
 
Method Summary
 void addModule(com.xml_project.morganaxquery.XQueryModule module)
          Adds a module to the static context.
 void declareInscopeVariable(com.xml_project.morganaxquery.internal.VariableDeclaration decl)
          Declares an inscope variable.
 boolean dependsOnContextItem()
           
protected  void dumpVariables()
          Dumps.
 XS_AnyURI getBaseURI()
          Returns the baseURI of this query.
 StaticXQueryContext.Modes getBoundarySpacePolicy()
          Returns the Boundary Space Policy.
 com.xml_project.morganaxquery.configuration.Collation getCollation(java.lang.String collationURI)
          Returns the collation with the given uri.
 com.xml_project.morganaxquery.configuration.XQueryConfiguration getConfiguration()
          Return the configuration for this static context.
 StaticXQueryContext.Modes getConstructionMode()
          Returns the construction mode.
 java.lang.String getDefaultCollation()
          Return the default collation
 java.lang.String getDefaultElementNamespace()
          Return the default element namespace.
 java.lang.String getDefaultFunctionNamespace()
          Return the default function namespace.
 boolean getDefaultOrderForEmptySequences()
          Returns the value for empty order declaration.
 java.lang.String getEncoding()
          Return the used encoding.
 XPathFunction getFunction(javax.xml.namespace.QName fnName, int arity)
          Returns the function with the given name and arity from either default library or installed modules.
 boolean getInheritNamespaceInCopy()
          Return the current value for inherit namespace.
 java.lang.Object getInscopeElementDeclaration(javax.xml.namespace.QName name)
          Returns an inscope element declaration.
 java.lang.Class<? extends XS_AnyType> getInscopeSchemaType(javax.xml.namespace.QName name)
          Return an inscope schema type.
 java.util.List<com.xml_project.morganaxquery.internal.VariableDeclaration> getInscopeVariables()
          Returns all declare inscope variables.
 com.xml_project.morganaxquery.XQueryModule getModule(java.lang.String namespace)
          Gets a module from the static context.
 StaticXQueryContext.OrderingModes getOrderingMode()
          Return the ordering mode.
 boolean getPreserveNamespaceInCopy()
          Return the current value for preserve namespace.
 java.util.Set<javax.xml.namespace.QName> getReferencedVariables()
          Returns the variable names used in this XPath- / XQuery-expression
 com.xml_project.morganaxquery.internal.NamespaceList getStaticallyKnownNamespaces()
          Returns a list of statically known namespaces.
 void markContextItemDependency()
           
 void markVariable(javax.xml.namespace.QName name)
          Marks usage of a variable name for analytic purposes
 void setBaseURI(XS_AnyURI uri)
          Sets the base uri of this query.
 void setBoundarySpacePolicy(StaticXQueryContext.Modes newMode)
          Sets the boundary whitespace policy.
 void setConstructionMode(StaticXQueryContext.Modes newMode)
          Sets the construction mode.
 void setCopyNamespaces(boolean preserve, boolean inherit)
          Sets the policy for namespace when copying elements.
 void setDefaultCollation(java.lang.String uri)
          Sets the default collation
 void setDefaultFunctionNamespace(java.lang.String uri)
          Sets the default function namespace.
 void setDefaultOrderForEmptySequences(boolean emptyFirst)
          Sets the rule for sorting with empty sequences.
 void setEncoding(java.lang.String newEncoding)
          Sets encoding
 void setOrderingMode(StaticXQueryContext.OrderingModes newMode)
          Sets the ordering mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticXQueryContext

public StaticXQueryContext(com.xml_project.morganaxquery.configuration.XQueryConfiguration config,
                           com.xml_project.morganaxquery.CompilerCommons.CompilerMode mode)
Creates a new static query context.

Parameters:
config - the configuration.
mode - the compiler mode.
Method Detail

addModule

public void addModule(com.xml_project.morganaxquery.XQueryModule module)
Adds a module to the static context.

Parameters:
module - the module

getModule

public com.xml_project.morganaxquery.XQueryModule getModule(java.lang.String namespace)
Gets a module from the static context.

Parameters:
namespace - the namespace for the module to get.
Returns:
the module or null.

getBaseURI

public XS_AnyURI getBaseURI()
Returns the baseURI of this query.

Returns:
the baseURI.

getBoundarySpacePolicy

public StaticXQueryContext.Modes getBoundarySpacePolicy()
Returns the Boundary Space Policy.

Returns:
the current policy.

getCollation

public com.xml_project.morganaxquery.configuration.Collation getCollation(java.lang.String collationURI)
                                                                   throws XPathException
Returns the collation with the given uri.

Parameters:
collationURI - the uri of the collaction to return.
Returns:
the collation.
Throws:
XPathException - thrown, if the uri is defective or the collation is not supported.

getConfiguration

public com.xml_project.morganaxquery.configuration.XQueryConfiguration getConfiguration()
Return the configuration for this static context.

Returns:
the configuration.

getDefaultOrderForEmptySequences

public boolean getDefaultOrderForEmptySequences()
Returns the value for empty order declaration.

Returns:
the value for empty order declaration.

getDefaultCollation

public java.lang.String getDefaultCollation()
Return the default collation

Returns:
the default collation.

getDefaultElementNamespace

public java.lang.String getDefaultElementNamespace()
Return the default element namespace.

Returns:
the default element namespace.

getDefaultFunctionNamespace

public java.lang.String getDefaultFunctionNamespace()
Return the default function namespace.

Returns:
the default function namespace

getReferencedVariables

public java.util.Set<javax.xml.namespace.QName> getReferencedVariables()
Returns the variable names used in this XPath- / XQuery-expression

Returns:
a list of QNames

getStaticallyKnownNamespaces

public com.xml_project.morganaxquery.internal.NamespaceList getStaticallyKnownNamespaces()
Returns a list of statically known namespaces.

Returns:
the statically known namespaces.

getEncoding

public java.lang.String getEncoding()
Return the used encoding.

Returns:
the used encoding.

getConstructionMode

public StaticXQueryContext.Modes getConstructionMode()
Returns the construction mode.

Returns:
the construction mode.

getOrderingMode

public StaticXQueryContext.OrderingModes getOrderingMode()
Return the ordering mode.

Returns:
the ordering mode.

setBaseURI

public void setBaseURI(XS_AnyURI uri)
                throws XPathException
Sets the base uri of this query.

Parameters:
uri - the base uri.
Throws:
XPathException

markVariable

public void markVariable(javax.xml.namespace.QName name)
Marks usage of a variable name for analytic purposes

Parameters:
name - the name of the used variable

setBoundarySpacePolicy

public void setBoundarySpacePolicy(StaticXQueryContext.Modes newMode)
Sets the boundary whitespace policy.

Parameters:
newMode - the boundary whitespace policy.

setConstructionMode

public void setConstructionMode(StaticXQueryContext.Modes newMode)
Sets the construction mode.

Parameters:
newMode - the construction mode to use.

getInscopeSchemaType

public java.lang.Class<? extends XS_AnyType> getInscopeSchemaType(javax.xml.namespace.QName name)
Return an inscope schema type.

Parameters:
name - the inscope schema type.
Returns:
the inscope schema type with the given name.

getInscopeElementDeclaration

public java.lang.Object getInscopeElementDeclaration(javax.xml.namespace.QName name)
Returns an inscope element declaration.

Parameters:
name - the name of the inscope element declation.
Returns:
null, because not supported.

getPreserveNamespaceInCopy

public boolean getPreserveNamespaceInCopy()
Return the current value for preserve namespace.

Returns:
the current value for preserve namespace.

getInheritNamespaceInCopy

public boolean getInheritNamespaceInCopy()
Return the current value for inherit namespace.

Returns:
the current value for inherit namespace.

setDefaultCollation

public void setDefaultCollation(java.lang.String uri)
                         throws XPathException
Sets the default collation

Parameters:
uri - the uri of the default collation.
Throws:
XPathException - thrown, if the uri is defective or the collation is unknown/unsupported.

setCopyNamespaces

public void setCopyNamespaces(boolean preserve,
                              boolean inherit)
Sets the policy for namespace when copying elements.

Parameters:
preserve - value for preserve.
inherit - value for inherit.

setDefaultFunctionNamespace

public void setDefaultFunctionNamespace(java.lang.String uri)
                                 throws XPathException
Sets the default function namespace.

Parameters:
uri - the uri of the default function namespace.
Throws:
XPathException - thrown, if the uri is not allowed as default function namespace.

setDefaultOrderForEmptySequences

public void setDefaultOrderForEmptySequences(boolean emptyFirst)
Sets the rule for sorting with empty sequences.

Parameters:
emptyFirst - the new rule.

setEncoding

public void setEncoding(java.lang.String newEncoding)
Sets encoding

Parameters:
newEncoding - the encoding to use.

getFunction

public XPathFunction getFunction(javax.xml.namespace.QName fnName,
                                 int arity)
                          throws XPathException
Returns the function with the given name and arity from either default library or installed modules.

Parameters:
fnName - the name of the function.
arity - the arity of the function.
Returns:
the function or null.
Throws:
XPathException - thrown, if the function can not be found in the default library, but should be there.

setOrderingMode

public void setOrderingMode(StaticXQueryContext.OrderingModes newMode)
Sets the ordering mode.

Parameters:
newMode - the new ordering mode to use.

dependsOnContextItem

public boolean dependsOnContextItem()

markContextItemDependency

public void markContextItemDependency()

declareInscopeVariable

public void declareInscopeVariable(com.xml_project.morganaxquery.internal.VariableDeclaration decl)
Declares an inscope variable.

Parameters:
decl - the declaration.

getInscopeVariables

public java.util.List<com.xml_project.morganaxquery.internal.VariableDeclaration> getInscopeVariables()
Returns all declare inscope variables.

Returns:
the declared variabled.

dumpVariables

protected void dumpVariables()
Dumps.