public class XmlQueryContext
extends java.lang.Object
XmlContainer. The context includes
namespace mappings, variable bindings, and flags that indicate how the
query result set should be determined and returned to the caller.
Multiple queries can be executed within the same XmlQueryContext;
however, XmlQueryContext is not thread-safe, and can only be
used by one thread at a time.
XmlQueryContext objects are created using XmlManager.createQueryContext(int, int).
XmlQueryContext allows you to define whether queries executed within the
context are to be evaluated lazily or eagerly, and whether the query is
to return live or dead values. For detailed descriptions of these
parameters see setReturnType(int) and
setEvaluationType(int). Note that these values are
also set when you create a query context using
XmlManager.createQueryContext(int, int).
The XQuery syntax permits expressions to refer to, as well as define namespace prefixes. The XmlQueryContext class provides namespace management methods so that the caller may manage the namespace prefix to URI mapping. By default the prefix "dbxml" is defined to be "http://www.sleepycat.com/2002/dbxml".
The XQuery syntax also permits expressions to refer to externally defined variables. The XmlQueryContext class provides methods that allow the caller to manage the externally-declared variable to value bindings.
A copy constructor is provided for this class. The class is implemented using a handle-body idiom. When a handle is copied both handles maintain a reference to the same body.
This object is not thread-safe, and can only be safely used by one thread at a time in an application.
| Modifier and Type | Field and Description |
|---|---|
static int |
Eager
The query is executed and its resultant values are derived and stored in-memory before evaluation of the query is completed.
|
static int |
Lazy
Minimal processing is performed before evaluation of the query is completed, and the remaining processing is deferred until the result set is enumerated.
|
static int |
LiveValues
A reference to the data stored in Berkeley DB XML is returned.
|
| Constructor and Description |
|---|
XmlQueryContext(XmlQueryContext o)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearNamespaces()
Remove all namespace mappings from the query context.
|
java.lang.String |
getBaseURI()
Returns the base URI set for this XmlQueryContext object.
|
XmlDebugListener |
getDebugListener()
Gets the
XmlDebugListener associated with this query context. |
java.lang.String |
getDefaultCollection()
Returns the default collection for use in fn:collection() with no
arguments in an XQuery expression.
|
int |
getEvaluationType()
Returns the evaluation type defined for this
XmlQueryContext. |
java.lang.String |
getNamespace(java.lang.String prefix)
Returns the namespace URI for the specified prefix.
|
int |
getQueryTimeoutSeconds()
Returns the query timeout value set in
setQueryTimeoutSeconds(int). |
int |
getReturnType()
Retrieve the return type defined for this
XmlQueryContext. |
XmlValue |
getVariableValue(java.lang.String name)
Returns the value that is bound to the specified variable.
|
XmlResults |
getVariableValues(java.lang.String name)
Returns the
XmlResults object representing the sequence of
values that is bound to the specified variable. |
void |
interruptQuery()
Interrupt the in-progress query using this
XmlQueryContext. |
void |
removeNamespace(java.lang.String prefix)
Remove the namespace prefix to URI mapping for the specified prefix.
|
void |
setBaseURI(java.lang.String baseURI)
Sets the base URI used for relative paths in query expressions.
|
void |
setDebugListener(XmlDebugListener listener)
Associates an
XmlDebugListener instance with the query context in order
to debug queries. |
void |
setDefaultCollection(java.lang.String uri)
Sets the default collection for use in fn:collection() with no
arguments in an XQuery expression.
|
void |
setEvaluationType(int type)
Allows the application to set the query evaluation type to "eager" or
"lazy".
|
void |
setNamespace(java.lang.String prefix,
java.lang.String uri)
Maps the specified URI to the specified namespace prefix.
|
void |
setQueryTimeoutSeconds(int seconds)
Sets the query timeout value for queries using this
XmlQueryContext. |
void |
setReturnType(int type)
Sets the return type of the query.
|
void |
setVariableValue(java.lang.String name,
XmlResults value)
Creates an externally-declared XQuery sequence variable by binding
the specified
XmlResults object to the specified variable name. |
void |
setVariableValue(java.lang.String name,
XmlValue value)
Creates an externally-declared XQuery variable by binding the specified
value to the specified variable name.
|
public static final int LiveValues
public static final int Eager
public static final int Lazy
public XmlQueryContext(XmlQueryContext o) throws XmlException
XmlExceptionpublic void setNamespace(java.lang.String prefix,
java.lang.String uri)
throws XmlException
prefix - The namespace prefix. If prefix is null, the uri will
be treated as the default element namespace.uri - The namespace URI.XmlExceptionpublic java.lang.String getNamespace(java.lang.String prefix)
throws XmlException
prefix - The namespace prefix whose URI mapping is required.XmlExceptionpublic void removeNamespace(java.lang.String prefix)
throws XmlException
prefix - The namespace prefix to be removed.XmlExceptionpublic void clearNamespaces()
throws XmlException
XmlExceptionpublic XmlDebugListener getDebugListener() throws XmlException
XmlDebugListener associated with this query context.XmlDebugListener associated with this query context, or null if there is none.XmlExceptionpublic void setDebugListener(XmlDebugListener listener) throws XmlException
XmlDebugListener instance with the query context in order
to debug queries. In order to prepare a query that contains debugging
information an XmlDebugListener must be set on the XmlQueryContext used
when the query is prepared. A different XmlDebugListener object (or none)
can be set for the query evaluation.listener - The XmlDebugListener to be used.XmlExceptionpublic void setDefaultCollection(java.lang.String uri)
throws XmlException
uri - The URI representing the container.XmlExceptionpublic java.lang.String getDefaultCollection()
throws XmlException
XmlExceptionpublic void setBaseURI(java.lang.String baseURI)
throws XmlException
baseURI - The base URI, as a string.XmlExceptionpublic java.lang.String getBaseURI()
throws XmlException
XmlExceptionpublic void setReturnType(int type)
throws XmlException
type - The type parameter specifies which of documents or values to return, and must be set to LiveValues.XmlExceptionpublic int getReturnType()
throws XmlException
XmlQueryContext.
Always returns LiveValues.XmlExceptionpublic void setEvaluationType(int type)
throws XmlException
XmlResults.next() is called the next resultant value is
determined.type - The evaluation type must be specified as either: Eager or Lazy.XmlExceptionpublic int getEvaluationType()
throws XmlException
XmlQueryContext.XmlExceptionpublic int getQueryTimeoutSeconds()
throws XmlException
setQueryTimeoutSeconds(int).XmlExceptionpublic void setQueryTimeoutSeconds(int seconds)
throws XmlException
XmlQueryContext.XmlExceptionpublic void interruptQuery()
throws XmlException
XmlQueryContext.XmlExceptionpublic void setVariableValue(java.lang.String name,
XmlValue value)
throws XmlException
This method may be called at any time during the life of the application.
name - The name of the variable to bind. Within the XQuery query, the variable can be referenced using the normal $name syntax.value - The value to bind to the named variable.XmlExceptionpublic void setVariableValue(java.lang.String name,
XmlResults value)
throws XmlException
XmlResults object to the specified variable name.
This method allows a sequence of values to be bound to an XQuery variable.
name - The name of the variable to bind. Within the XQuery query, the variable can be referenced using the normal $name syntax.value - The set of values to bind to the named variable.XmlExceptionpublic XmlValue getVariableValue(java.lang.String name) throws XmlException
null value (XmlValue.isNull() returns true).name - The name of the variable whose value is required.XmlExceptionpublic XmlResults getVariableValues(java.lang.String name) throws XmlException
XmlResults object representing the sequence of
values that is bound to the specified variable. If there is
no value binding then the value is set to the
null value (XmlResults.isNull() returns true).name - The name of the variable whose value is required.XmlExceptionCopyright (c) 2004,2014 Oracle. All rights reserved.