com.caucho.xpath.pattern
Class FromContext

java.lang.Object
  extended by com.caucho.xpath.pattern.AbstractPattern
      extended by com.caucho.xpath.pattern.FromContext

public class FromContext
extends AbstractPattern

Matches the node context.


Field Summary
 
Fields inherited from class com.caucho.xpath.pattern.AbstractPattern
_child, _parent, log, XMLNS
 
Constructor Summary
FromContext()
           
FromContext(int ancestorCount)
          Creates a new context pattern.
 
Method Summary
 AbstractPattern copyAxis()
          Returns the node itself for the axis.
 AbstractPattern copyPosition()
          Returns null since the axis isn't part of the position pattern.
 int count(org.w3c.dom.Node node, Env env, AbstractPattern pattern)
          There is only a single node in the context axis.
 NodeIterator createNodeIterator(org.w3c.dom.Node node, ExprEnvironment env, AbstractPattern match)
          Creates a new node iterator.
 boolean equals(java.lang.Object b)
          Returns true if the two patterns are equal.
 org.w3c.dom.Node firstNode(org.w3c.dom.Node node, ExprEnvironment env)
          Returns the first node in the selection order.
 int getCount()
           
 boolean isStrictlyAscending()
          The context is strictly ascending.
 boolean isUnique()
          Returns true if the pattern's selector returns unique nodes.
 boolean match(org.w3c.dom.Node node, ExprEnvironment env)
          Matches the node context
 org.w3c.dom.Node nextNode(org.w3c.dom.Node node, org.w3c.dom.Node lastNode)
          Returns the next node in the selection order.
 int position(org.w3c.dom.Node node, Env env, AbstractPattern pattern)
          There is only a single node in the context axis.
 java.lang.String toString()
          Prints the pattern representing the context.
 
Methods inherited from class com.caucho.xpath.pattern.AbstractPattern
findAny, getNodeName, getParent, getPrefix, getPriority, isAscending, lastNode, select, selectUnique, toPatternString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FromContext

public FromContext()

FromContext

public FromContext(int ancestorCount)
Creates a new context pattern. Using the ancestorCount, FromContext collapses parent patterns into a single FromContext pattern. For example, context()/../.. is collapsed to FromContext(2).

Parameters:
ancestorCount - number of parents where the real context starts
Method Detail

getCount

public int getCount()

match

public boolean match(org.w3c.dom.Node node,
                     ExprEnvironment env)
Matches the node context

Specified by:
match in class AbstractPattern
Parameters:
node - the current node
env - the variable environment
Returns:
true if the node is the context node.

isStrictlyAscending

public boolean isStrictlyAscending()
The context is strictly ascending.


position

public int position(org.w3c.dom.Node node,
                    Env env,
                    AbstractPattern pattern)
There is only a single node in the context axis.

Parameters:
node - the current node
env - the variable environment
pattern - the position pattern
Returns:
1

count

public int count(org.w3c.dom.Node node,
                 Env env,
                 AbstractPattern pattern)
There is only a single node in the context axis.

Parameters:
node - the current node
env - the variable environment
pattern - the position pattern
Returns:
1

firstNode

public org.w3c.dom.Node firstNode(org.w3c.dom.Node node,
                                  ExprEnvironment env)
Returns the first node in the selection order.

Overrides:
firstNode in class AbstractPattern
Parameters:
node - the current node
env - the current environment
Returns:
the first node

nextNode

public org.w3c.dom.Node nextNode(org.w3c.dom.Node node,
                                 org.w3c.dom.Node lastNode)
Returns the next node in the selection order.

Overrides:
nextNode in class AbstractPattern
Parameters:
node - the current node
lastNode - the last node
Returns:
the next node

equals

public boolean equals(java.lang.Object b)
Returns true if the two patterns are equal.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Prints the pattern representing the context.

Overrides:
toString in class java.lang.Object

createNodeIterator

public NodeIterator createNodeIterator(org.w3c.dom.Node node,
                                       ExprEnvironment env,
                                       AbstractPattern match)
                                throws XPathException
Creates a new node iterator.

Overrides:
createNodeIterator in class AbstractPattern
Parameters:
node - the starting node
env - the variable environment
match - the axis match pattern
Returns:
the node iterator
Throws:
XPathException

copyAxis

public AbstractPattern copyAxis()
Returns the node itself for the axis.

Overrides:
copyAxis in class AbstractPattern

copyPosition

public AbstractPattern copyPosition()
Returns null since the axis isn't part of the position pattern.

Overrides:
copyPosition in class AbstractPattern

isUnique

public boolean isUnique()
Returns true if the pattern's selector returns unique nodes.

Overrides:
isUnique in class AbstractPattern