congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
PrecedingAxisIterator
Code IndexAdd Tabnine to your IDE (free)

How to use
PrecedingAxisIterator
in
org.jaxen.util

Best Java code snippets using org.jaxen.util.PrecedingAxisIterator (Showing top 4 results out of 315)

origin: jaxen/jaxen

public Iterator getPrecedingAxisIterator(Object contextNode) throws UnsupportedAxisException
{
  return new PrecedingAxisIterator( contextNode,
                   this );
  // throw new UnsupportedAxisException("preceding");
}
origin: jaxen/jaxen

/**
 * Returns the next preceding node.
 * 
 * @return the next preceding node
 * 
 * @throws NoSuchElementException if no preceding nodes remain
 * 
 * @see java.util.Iterator#next()
 */
public Object next() throws NoSuchElementException
{
  if (!hasNext())
  {
    throw new NoSuchElementException();
  }
  while (true)
  {
    Object result = childrenOrSelf.previous();
    if (childrenOrSelf.hasPrevious())
    {
      // if this isn't 'self' construct 'descendant-or-self'
      stack.add(childrenOrSelf);
      childrenOrSelf = childrenOrSelf(result);
      continue;
    }
    return result;
  }
}
origin: jaxen/jaxen

childrenOrSelf = childrenOrSelf(node);
origin: se.ugli.durian/durian-java-dom

@Override
public Iterator<?> getPrecedingAxisIterator(final Object contextNode) throws UnsupportedAxisException {
  return new PrecedingAxisIterator(contextNode, this);
}
org.jaxen.utilPrecedingAxisIterator

Javadoc

Represents the XPath preceding axis. The "preceding axis contains all nodes in the same document as the context node that are before the context node in document order, excluding any ancestors and excluding attribute nodes and namespace nodes."

This implementation of 'preceding' works like so: the preceding axis includes preceding siblings of this node and their descendants. Also, for each ancestor node of this node, it includes all preceding siblings of that ancestor, and their descendants. Finally, it includes the ancestor nodes themselves.

The reversed descendant-or-self axes that are required are calculated using a stack of reversed 'child-or-self' axes. When asked for a node, it is always taken from a child-or-self axis. If it was the last node on that axis, the node is returned. Otherwise, this axis is pushed on the stack, and the process is repeated with the child-or-self of the node. Eventually this recurses down to the last descendant of any node, then works back up to the root.

Most object models could provide a faster implementation of the reversed 'children-or-self' used here.

Most used methods

  • <init>
    Create a new preceding axis iterator.
  • childrenOrSelf
  • hasNext
    Returns true if there are any preceding nodes remaining; false otherwise.

Popular in Java

  • Updating database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • setScale (BigDecimal)
  • getSupportFragmentManager (FragmentActivity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now