com.japisoft.xpath
Class XPathContext

java.lang.Object
  |
  +--com.japisoft.xpath.XPathContext

public final class XPathContext
extends java.lang.Object

XPath context for the resolution

Author:
(c) 2002-2003 JAPISOFT
See Also:
XPathResolver

Constructor Summary
XPathContext(java.lang.Object refNode, XPathKit kit)
          Set this XPathContext with the following node.
 
Method Summary
 void addNamespace(java.lang.String prefix, java.lang.String uri)
          Add a namespace, linking a prefix to its namespace URI
 NodeSet getContextNodeSet()
           
 int getContextPosition()
           
 int getContextSize()
           
 java.lang.Object getFirstNodeFromContext()
           
 NodeSet getFullDocumentNodes(java.lang.Object refNode)
           
 java.lang.String getLang(java.lang.Object node)
           
 Lib getLibrary()
           
 java.lang.String getLocalName(java.lang.Object node)
           
 java.lang.String getName(java.lang.Object node)
           
 java.lang.String getNamespaceURI(java.lang.Object node)
           
 java.lang.String getNamespaceURI(java.lang.String prefix)
           
 Navigator getNavigator()
           
 java.lang.Object getNodeForId(java.lang.String id)
           
 java.lang.Object getNodeFromContext()
           
 java.lang.String getStringValue(java.lang.Object node)
          string-value is part of the node; for other types of node, the string-value is computed from the string-value of descendant nodes
 java.lang.Object getVariable(java.lang.String name)
           
 boolean hasNamespaceDeclaration(java.lang.String prefix)
          Check if the prefix has namespace URI declaration with the addNamespace method
 boolean hasVariable(java.lang.String name)
           
 boolean isPredicateMode()
          Particular case for predicate evaluation
 void removeNamespace(java.lang.String prefix)
          Remove a namespace declaration : a prefix
 void removeVariable(java.lang.String name)
          Remove a variable
 void setContextNode(java.lang.Object contextNode)
          Reset the current NodeSet with this node
 void setContextNodeSet(NodeSet n)
          Reset the current NodeSet
 void setContextPosition(int position)
          Reset the current context resolution position
 void setLibrary(Lib lib)
          Reset the library for XPath functions
 void setNavigator(Navigator nav)
          Set a specific navigator for retreiving nodes
 void setPredicateMode(boolean predicateMode)
          Particular case for predicate evaluation
 void setVariable(java.lang.String name, java.lang.Object value)
          Reset a variable with this value.
 java.util.Enumeration variablesEnum()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathContext

public XPathContext(java.lang.Object refNode,
                    XPathKit kit)
Set this XPathContext with the following node. If no node are needed because the XPath resolution is made from the root, then you have to include the root node of your XML document.

Parameters:
refNode - refNode for resolving XPath. If none is available, it muse be the root node of the current XML tree
kit - The specific context resolver depending on Node type like FastParser lightweight node, JDOM, DOM...
Method Detail

setContextNode

public void setContextNode(java.lang.Object contextNode)
Reset the current NodeSet with this node


setContextNodeSet

public void setContextNodeSet(NodeSet n)
Reset the current NodeSet


getContextNodeSet

public NodeSet getContextNodeSet()
Returns:
the current nodeSet

setContextPosition

public void setContextPosition(int position)
Reset the current context resolution position


getContextPosition

public int getContextPosition()
Returns:
the current context position

getNodeFromContext

public java.lang.Object getNodeFromContext()
Returns:
the current node from the current nodeSet and the current context location

getFirstNodeFromContext

public java.lang.Object getFirstNodeFromContext()
Returns:
the first node from the curent nodeSet

getContextSize

public int getContextSize()
Returns:
the current NodeSet size

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value)
Reset a variable with this value. Primitives values must be wrapped with java.lang.Double or java.lang.Boolean...


removeVariable

public void removeVariable(java.lang.String name)
Remove a variable


addNamespace

public void addNamespace(java.lang.String prefix,
                         java.lang.String uri)
Add a namespace, linking a prefix to its namespace URI


removeNamespace

public void removeNamespace(java.lang.String prefix)
Remove a namespace declaration : a prefix


hasNamespaceDeclaration

public boolean hasNamespaceDeclaration(java.lang.String prefix)
Check if the prefix has namespace URI declaration with the addNamespace method


getVariable

public java.lang.Object getVariable(java.lang.String name)
Returns:
a variable value for its name. Primitives types are wrapped with standard java.lang.Double or java.lang.Boolean

variablesEnum

public java.util.Enumeration variablesEnum()

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Returns:
a namespace URI for this prefix. Such prefix appears in Qualified Name

hasVariable

public boolean hasVariable(java.lang.String name)

getStringValue

public java.lang.String getStringValue(java.lang.Object node)
string-value is part of the node; for other types of node, the string-value is computed from the string-value of descendant nodes


getNodeForId

public java.lang.Object getNodeForId(java.lang.String id)
Returns:
a node matching the unique id

getFullDocumentNodes

public NodeSet getFullDocumentNodes(java.lang.Object refNode)
Returns:
all nodes from the current document

getLocalName

public java.lang.String getLocalName(java.lang.Object node)
Returns:
the local name of the node

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.Object node)
Returns:
the namaespace URI for this node

getName

public java.lang.String getName(java.lang.Object node)
Returns:
the qualified node name

getLang

public java.lang.String getLang(java.lang.Object node)
Returns:
the language for the node

setLibrary

public void setLibrary(Lib lib)
Reset the library for XPath functions


getLibrary

public Lib getLibrary()
Returns:
the current library for XPath functions

setNavigator

public void setNavigator(Navigator nav)
Set a specific navigator for retreiving nodes


getNavigator

public Navigator getNavigator()
Returns:
the current navigator

setPredicateMode

public void setPredicateMode(boolean predicateMode)
Particular case for predicate evaluation


isPredicateMode

public boolean isPredicateMode()
Particular case for predicate evaluation