com.caucho.xpath.pattern
Class FromPrevious

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

public class FromPrevious
extends AbstractPattern

Matches nodes preceding the current node, not counting descendants.


Field Summary
 
Fields inherited from class com.caucho.xpath.pattern.AbstractPattern
_child, _parent, log, XMLNS
 
Constructor Summary
FromPrevious(AbstractPattern parent)
           
 
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)
          counts matching nodes preceding the axis context.
 NodeIterator createNodeIterator(org.w3c.dom.Node node, ExprEnvironment env, AbstractPattern match)
          Creates a new node iterator.
 org.w3c.dom.Node firstNode(org.w3c.dom.Node node, ExprEnvironment env)
          Returns the first node in the selection order.
 boolean isAscending()
          The iterator is in reverse document order.
 boolean isStrictlyAscending()
          Returns true if the pattern is strictly ascending.
 boolean isUnique()
          Returns true if the pattern is strictly ascending.
 org.w3c.dom.Node lastNode(org.w3c.dom.Node node)
          Returns the last node in the selection order.
 boolean match(org.w3c.dom.Node node, ExprEnvironment env)
          matches if we can find a following node matching the parent pattern.
 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)
          Calculates position by counting next nodes matching the pattern.
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.xpath.pattern.AbstractPattern
findAny, getNodeName, getParent, getPrefix, getPriority, select, selectUnique, toPatternString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FromPrevious

public FromPrevious(AbstractPattern parent)
Method Detail

match

public boolean match(org.w3c.dom.Node node,
                     ExprEnvironment env)
              throws XPathException
matches if we can find a following node matching the parent pattern.

Specified by:
match in class AbstractPattern
Parameters:
node - the node to test
env - the variable environment.
Returns:
true if the node matches the pattern.
Throws:
XPathException

isAscending

public boolean isAscending()
The iterator is in reverse document order.

Overrides:
isAscending in class AbstractPattern

position

public int position(org.w3c.dom.Node node,
                    Env env,
                    AbstractPattern pattern)
             throws XPathException
Calculates position by counting next nodes matching the pattern. The axis is a previous node matching the parent pattern.

Parameters:
node - the current node
env - the variable environment
pattern - the position pattern
Returns:
the node's position.
Throws:
XPathException

count

public int count(org.w3c.dom.Node node,
                 Env env,
                 AbstractPattern pattern)
          throws XPathException
counts matching nodes preceding the axis context. count() walks backwards from the axis context.

Parameters:
node - the current node
env - the variable environment
pattern - the position pattern
Returns:
the count of the node list.
Throws:
XPathException

isUnique

public boolean isUnique()
Returns true if the pattern is strictly ascending.


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
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 original node (for checking ancestors)
Returns:
the next node

lastNode

public org.w3c.dom.Node lastNode(org.w3c.dom.Node node)
Returns the last node in the selection order.

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

toString

public java.lang.String toString()
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

isStrictlyAscending

public boolean isStrictlyAscending()
Returns true if the pattern is strictly ascending.

Overrides:
isStrictlyAscending in class AbstractPattern