Qizx/Open v0.4

net.xfra.qizxopen.xquery
Interface EvalContext


public interface EvalContext

XQuery Evaluation Context. (internal use)


Field Summary
static int DOUBLE_REGISTER
           
static int INT_REGISTER
           
static int ITEM_REGISTER
           
static int LAST_REGISTER
           
static int MAX_REGISTER
          Maximum number of registers for each scalar type (integer, double, string, item)
static int STRING_REGISTER
           
 
Method Summary
 void at(net.xfra.qizxopen.xquery.op.Expression pt)
          Notes the current evaluation point for trace & debug.
 Value error(net.xfra.qizxopen.xquery.op.Expression location, EvalException error)
          Raises an EvalException that is located to this context.
 Value error(net.xfra.qizxopen.xquery.op.Expression location, java.lang.String error)
           
 EvalContext getCallerContext()
          Returns the calling context, null if not inside a user function.
 java.text.Collator getCollator(java.lang.String uri)
          Finds a collation by its URI.
 java.util.Date getCurrentDate()
          Time at start of query evaluation.
 net.xfra.qizxopen.xquery.op.Expression getCurrentLocation()
           
 java.io.PrintWriter getDefaultOutput()
          Defined externally (by default stdout or servlet output)
 Value getDocument(java.lang.String uri)
          Finds a document by URI.
 DocumentManager getDocumentManager()
          Returns the document manager used by this context.
 int getImplicitTimezone()
          implicit time zone as a difference in minutes from GMT (or UTC).
 Value getInput()
          Returns the document or collection input.
 Log getLog()
          Gets a message Log, either set explictly or from the static context.
 java.lang.Object getProperty(java.lang.String name)
          Retrieves a named property from the context.
 StaticContext getStaticContext()
          Returns the initial static context.
 Value loadGlobal(net.xfra.qizxopen.xquery.op.GlobalVariable var)
          Gets the value of a global variable.
 Value loadLocal(int address)
          Gets the value of a local variable.
 double loadLocalDouble(int address)
          Loads a scalar double local variable
 long loadLocalInteger(int address)
          Loads a scalar integer local variable
 Item loadLocalItem(int address)
          Loads a scalar local variable
 java.lang.String loadLocalString(int address)
          Loads a scalar String local variable
 void printStack(Log log, int maxDepth)
          Prints the calling stack to a Log, with amaximum depth.
 void storeLocal(int address, net.xfra.qizxopen.xquery.op.Expression expr, Type dynamicType, Focus focus, EvalContext calling)
          Evaluates an expression and store the result into a local variable.
 void storeLocal(int address, Value value, boolean current)
          Stores a value or its current item to a local variable [for, some, every].
 void storeLocalInteger(int address, long value)
          Stores the positional variable in [for, some, every].
 EvalContext subContext(net.xfra.qizxopen.xquery.fn.UserFunction.Call called)
          Helper creating a context for the called function.
 

Field Detail

MAX_REGISTER

public static final int MAX_REGISTER
Maximum number of registers for each scalar type (integer, double, string, item)

See Also:
Constant Field Values

INT_REGISTER

public static final int INT_REGISTER
See Also:
Constant Field Values

DOUBLE_REGISTER

public static final int DOUBLE_REGISTER
See Also:
Constant Field Values

STRING_REGISTER

public static final int STRING_REGISTER
See Also:
Constant Field Values

ITEM_REGISTER

public static final int ITEM_REGISTER
See Also:
Constant Field Values

LAST_REGISTER

public static final int LAST_REGISTER
See Also:
Constant Field Values
Method Detail

getStaticContext

public StaticContext getStaticContext()
Returns the initial static context.


getCallerContext

public EvalContext getCallerContext()
Returns the calling context, null if not inside a user function.


subContext

public EvalContext subContext(net.xfra.qizxopen.xquery.fn.UserFunction.Call called)
                       throws EvalException
Helper creating a context for the called function.

EvalException

at

public void at(net.xfra.qizxopen.xquery.op.Expression pt)
        throws XQueryException
Notes the current evaluation point for trace & debug. Can also raise an EvalException if a time limit is reached.

XQueryException

getInput

public Value getInput()
Returns the document or collection input.


getDocument

public Value getDocument(java.lang.String uri)
                  throws XQueryException
Finds a document by URI. Ensures that a document is loaded once only.

XQueryException

getDocumentManager

public DocumentManager getDocumentManager()
Returns the document manager used by this context.


getDefaultOutput

public java.io.PrintWriter getDefaultOutput()
Defined externally (by default stdout or servlet output)


getLog

public Log getLog()
Gets a message Log, either set explictly or from the static context.


getProperty

public java.lang.Object getProperty(java.lang.String name)
Retrieves a named property from the context.


getCollator

public java.text.Collator getCollator(java.lang.String uri)
                               throws XQueryException
Finds a collation by its URI. If not found, an error is raised. The codepoint collator is represented by a null value.

Parameters:
uri - collation URI. If null, the default collation is returned.
XQueryException

getCurrentDate

public java.util.Date getCurrentDate()
Time at start of query evaluation.


getImplicitTimezone

public int getImplicitTimezone()
implicit time zone as a difference in minutes from GMT (or UTC).


error

public Value error(net.xfra.qizxopen.xquery.op.Expression location,
                   EvalException error)
            throws EvalException
Raises an EvalException that is located to this context.

EvalException

error

public Value error(net.xfra.qizxopen.xquery.op.Expression location,
                   java.lang.String error)
            throws EvalException
EvalException

getCurrentLocation

public net.xfra.qizxopen.xquery.op.Expression getCurrentLocation()

printStack

public void printStack(Log log,
                       int maxDepth)
Prints the calling stack to a Log, with amaximum depth.


loadGlobal

public Value loadGlobal(net.xfra.qizxopen.xquery.op.GlobalVariable var)
                 throws XQueryException
Gets the value of a global variable.

Throws:
EvalException - if the variable has no specified value.
XQueryException

loadLocal

public Value loadLocal(int address)
                throws XQueryException
Gets the value of a local variable. The address is computed by the compiler, it can be a simple rank or a scalar register.

XQueryException

loadLocalInteger

public long loadLocalInteger(int address)
                      throws XQueryException
Loads a scalar integer local variable

XQueryException

loadLocalDouble

public double loadLocalDouble(int address)
                       throws XQueryException
Loads a scalar double local variable

XQueryException

loadLocalString

public java.lang.String loadLocalString(int address)
                                 throws XQueryException
Loads a scalar String local variable

XQueryException

loadLocalItem

public Item loadLocalItem(int address)
                   throws XQueryException
Loads a scalar local variable

XQueryException

storeLocal

public void storeLocal(int address,
                       net.xfra.qizxopen.xquery.op.Expression expr,
                       Type dynamicType,
                       Focus focus,
                       EvalContext calling)
                throws XQueryException
Evaluates an expression and store the result into a local variable. Used for user function calls, let. Checks the type on the fly if dynamicType is not null.

Throws:
TypeException - if improper check
XQueryException

storeLocal

public void storeLocal(int address,
                       Value value,
                       boolean current)
                throws XQueryException
Stores a value or its current item to a local variable [for, some, every].

Parameters:
current - if true, stores only the current item, else stores the whole sequence.
Throws:
TypeException - if improper check
XQueryException

storeLocalInteger

public void storeLocalInteger(int address,
                              long value)
Stores the positional variable in [for, some, every].


 Copyright Xavier FRANC 2003-2004