Package net.sf.saxon.trace

## Class ContextStackIterator

- java.lang.Object
- - net.sf.saxon.trace.ContextStackIterator

- All Implemented Interfaces:
    `java.util.Iterator<ContextStackFrame>`

      public class ContextStackIterator
      extends java.lang.Object
      implements java.util.Iterator<ContextStackFrame>

  This class provides a representation of the current runtime call stack, as represented by the stack of XPathContext objects.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ContextStackIterator​(XPathContext context)` | Create an iterator over the stack of XPath dynamic context objects, starting with the top-most stackframe and working down.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `hasNext()` | Returns `true` if the iteration has more elements.
    `ContextStackFrame` | `next()` | Returns the next element in the iteration.
    `void` | `remove()` | Removes from the underlying collection the last element returned by the iterator (optional operation).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.util.Iterator

      `forEachRemaining`

- - ### Constructor Detail

    - #### ContextStackIterator

          public ContextStackIterator​(XPathContext context)

      Create an iterator over the stack of XPath dynamic context objects, starting with the top-most stackframe and working down. The objects returned by this iterator will be of class `ContextStackFrame`. Note that only "major" context objects are considered - those that have a stack frame of their own.
      Parameters:
        `context` - the current context

  - ### Method Detail

    - #### hasNext

          public boolean hasNext()

      Returns `true` if the iteration has more elements. (In other words, returns `true` if `next` would return an element rather than throwing an exception.)
      Specified by:
        `hasNext` in interface `java.util.Iterator<ContextStackFrame>`
      Returns:
        `true` if the iterator has more elements.

    - #### next

          public ContextStackFrame next()

      Returns the next element in the iteration. Calling this method repeatedly until the `hasNext()` method returns false will return each element in the underlying collection exactly once.
      Specified by:
        `next` in interface `java.util.Iterator<ContextStackFrame>`
      Returns:
        the next element in the iteration, which will always be an instance of `ContextStackFrame`
      Throws:
        `java.util.NoSuchElementException` - iteration has no more elements.

    - #### remove

          public void remove()

      Removes from the underlying collection the last element returned by the iterator (optional operation).
      Specified by:
        `remove` in interface `java.util.Iterator<ContextStackFrame>`
      Throws:
        `java.lang.UnsupportedOperationException` - as the `remove` operation is not supported by this Iterator.