com.virtualweaver.xotics.datamodel.xpath
Class XpContext

java.lang.Object
  extended bycom.virtualweaver.xotics.datamodel.xpath.XpContext
All Implemented Interfaces:
java.lang.Cloneable

public final class XpContext
extends java.lang.Object
implements java.lang.Cloneable

XPath dynamic execution context, containing various tools and infos useful to process XPath requests.

Version:
4.1

Constructor Summary
XpContext(com.virtualweaver.xotics.datamodel.core.XoXPathStaticContext sc, XoRequestToolkit rt)
          Creates a new instance.
 
Method Summary
 java.lang.Object clone()
          Clone method
 XpContext cloneContext(XdpSequence newSeq)
          Clone this context with a new context sequence provided as argument
 XdpSequence getContextSequence()
          returns the context sequence
 int getCurrentPosition()
          Returns position of current context item in context sequence.
 java.lang.Class getDataTypeClass(java.lang.String qname)
          Returns the class of a registered XS datatype identified by a QName of the form : prefix:localname, format used to reference a datatype or a function in an XPath request.
 java.lang.Class getFunctionClass(java.lang.String qname)
          Returns the class of a registered XPath function identified by a QName of the form : prefix:localname, format used to reference a datatype or a function in an XPath request.
 java.lang.String getNamespace(java.lang.String prefix)
          Returns the namespace associated to prefix param.
 java.lang.String getPrefix(java.lang.String namespace)
          Returns the prefix associated to namespace param.
 XoRequestToolkit getRequestToolkit()
          Returns current request toolkit.
 java.util.Map getVariables()
          Returns current XPath variables defined in this dynamic context
 boolean isInstance(XsdDataType dt, java.lang.String qname)
          Utility method to know whether dt param derives from or is instance of XS datatype (in XSD context) identified by gname (in prefix:localname format).
 boolean isInstance(XsdDataType dt, java.lang.String[] ns, java.lang.String[] localName)
          Utility method to perform multiple checks like isInstance(XsdDataType, String, String) does.
 boolean isInstance(XsdDataType dt, java.lang.String ns, java.lang.String localName)
          same method as isInstance(XsdDataType, String) with a dattype designated by namespace and local name rather than prefix:localname.
 boolean isNumericType(XsdDataType dt)
          Utility method to know if dt is a numeric XSD.
 void setContextSequence(XdpSequence contextSequence)
          sets the context sequence
 void setCurrentPosition(int currentPosition)
          Sets position of current context item in context sequence.
 void setVariables(java.util.Map variables)
          Sets a new Map containing couples (variable name, value), as XPath variables.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XpContext

public XpContext(com.virtualweaver.xotics.datamodel.core.XoXPathStaticContext sc,
                 XoRequestToolkit rt)
Creates a new instance. This constructor is used only by internal core system

Parameters:
sc - static context, not visible : all its features are wrapped and made available by this.
rt - the request toolkit to use
Method Detail

clone

public java.lang.Object clone()
Clone method

Returns:
cloned dynamic context

cloneContext

public XpContext cloneContext(XdpSequence newSeq)
Clone this context with a new context sequence provided as argument

Parameters:
newSeq - a new XPath Context sequence
Returns:
a new dynamic context with same properties except context sequence

getVariables

public java.util.Map getVariables()
Returns current XPath variables defined in this dynamic context

Returns:
current XPath variables as a Map object.

setVariables

public void setVariables(java.util.Map variables)
Sets a new Map containing couples (variable name, value), as XPath variables.

Parameters:
variables - new XPath variables

getContextSequence

public XdpSequence getContextSequence()
returns the context sequence

Returns:
context sequence

setContextSequence

public void setContextSequence(XdpSequence contextSequence)
sets the context sequence

Parameters:
contextSequence - the new context sequence

getCurrentPosition

public int getCurrentPosition()
Returns position of current context item in context sequence. As defined in XPath standard, position starts at 1. So, if no current position, returns 0.

Returns:
position of current context item or 0 if no context item

setCurrentPosition

public void setCurrentPosition(int currentPosition)
Sets position of current context item in context sequence. As defined in XPath standard, position starts at 1. So, no current position means value 0.

Parameters:
currentPosition - new position of context item or 0 if no context item

getRequestToolkit

public XoRequestToolkit getRequestToolkit()
Returns current request toolkit. There is one instance of XoRequestToolkit per DM instance.

Returns:
current request toolkit.

getPrefix

public java.lang.String getPrefix(java.lang.String namespace)
Returns the prefix associated to namespace param. This namespace concerns both XPath functions and new XS datatypes.

Parameters:
namespace - a namespace for XPath function or XS datatype
Returns:
corresponding prefix or null if unknown

getNamespace

public java.lang.String getNamespace(java.lang.String prefix)
Returns the namespace associated to prefix param. This namespace concerns both XPath functions and new XS datatypes.

Parameters:
prefix - a prefix for XPath function or XS datatype
Returns:
corresponding namespace or null if unknown

getDataTypeClass

public java.lang.Class getDataTypeClass(java.lang.String qname)
Returns the class of a registered XS datatype identified by a QName of the form : prefix:localname, format used to reference a datatype or a function in an XPath request.

Parameters:
qname - a string of the form prefix:localname
Returns:
associated class, which must represents an XsdDataType class, or null if not found.

getFunctionClass

public java.lang.Class getFunctionClass(java.lang.String qname)
Returns the class of a registered XPath function identified by a QName of the form : prefix:localname, format used to reference a datatype or a function in an XPath request.

Parameters:
qname - a string of the form prefix:localname
Returns:
associated class, which must represents an XpFunction class, or null if not found.

isInstance

public boolean isInstance(XsdDataType dt,
                          java.lang.String qname)

Utility method to know whether dt param derives from or is instance of XS datatype (in XSD context) identified by gname (in prefix:localname format). This method is important because in Xotics API, derivation hierarchy tree of XS datatypes is not allways the same as Java derivation hierarchy.

For instance : XsdShort represents an XSD short, which derives from an XSD int, but XsdShort class derives from XsdAnySimpleType class and not from Xsdint class.

Parameters:
dt - a datatype to check
qname - a prefix:localname string identifying an XS datatype
Returns:
true if dt represents an XSD derived from qname.

isInstance

public boolean isInstance(XsdDataType dt,
                          java.lang.String ns,
                          java.lang.String localName)
same method as isInstance(XsdDataType, String) with a dattype designated by namespace and local name rather than prefix:localname.

Parameters:
dt - datatype to check
ns - namespace of a particular XSD
localName - local name of a particular XSD
Returns:
true if dt represents an XSD derived from XSD designated by ns:localName

isNumericType

public boolean isNumericType(XsdDataType dt)
Utility method to know if dt is a numeric XSD. Numeric XSD are :

Parameters:
dt - datatype to check
Returns:
true if dt is instance of or derived from one of XSD numeric types.

isInstance

public boolean isInstance(XsdDataType dt,
                          java.lang.String[] ns,
                          java.lang.String[] localName)
Utility method to perform multiple checks like isInstance(XsdDataType, String, String) does.

Parameters:
dt - datatype to check
ns - namespace of particular XSD list
localName - local name of particular XSD list
Returns:
true if one match occurs.