PositionIterator (Apache FOP Core 2.11 API)
Date: 2025-04-24

org.apache.fop.layoutmgr

## Class PositionIterator

- java.lang.Object
- - org.apache.fop.layoutmgr.PositionIterator

- All Implemented Interfaces:
    Iterator<Position>
  Direct Known Subclasses:
    KnuthPossPosIter

      public class PositionIterator
      extends Object
      implements Iterator<Position>

  An iterator over `Position` instances, that is wrapped around another 'parent' `Iterator`. The parent can be either another `PositionIterator`, or an iterator over `KnuthElement`s, for example.
  The `next()` method always returns a `Position`. The `getPos(Object)` method can be overridden in subclasses to take care of obtaining the `LayoutManager` or `Position` from the object returned by the parent iterator's `next()` method.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PositionIterator(Iterator parentIter)` Construct position iterator.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `checkNext()`
    `protected void` | `endIter()` end (reset) iterator
    `protected LayoutManager` | `getLM(Object nextObj)`
    `LayoutManager` | `getNextChildLM()`
    `protected Position` | `getPos(Object nextObj)` Default implementation assumes that the passed `nextObj` is itself a `Position`, and just returns it.
    `boolean` | `hasNext()`
    `Position` | `next()`
    `Object` | `peekNext()`
    `void` | `remove()`

    - ### 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

    - #### PositionIterator

          public PositionIterator(Iterator parentIter)

      Construct position iterator.
      Parameters:
        `parentIter` - an iterator to use as parent

  - ### Method Detail

    - #### getNextChildLM

          public LayoutManager getNextChildLM()

      Returns:
        layout manager of next child layout manager or null

    - #### getLM

          protected LayoutManager getLM(Object nextObj)

      Parameters:
        `nextObj` - next object from which to obtain position
      Returns:
        layout manager

    - #### getPos

          protected Position getPos(Object nextObj)

      Default implementation assumes that the passed `nextObj` is itself a `Position`, and just returns it. Subclasses for which this is not the case, must provide a suitable override this method.
      Parameters:
        `nextObj` - next object from which to obtain position
      Returns:
        position of next object.

    - #### checkNext

          protected boolean checkNext()

      Returns:
        true if not at end of sub-sequence with same child layout manager

    - #### endIter

          protected void endIter()

      end (reset) iterator

    - #### hasNext

          public boolean hasNext()

      Specified by:
        `hasNext` in interface `Iterator<Position>`

    - #### next

          public Position next()
                        throws NoSuchElementException

      Specified by:
        `next` in interface `Iterator<Position>`
      Throws:
        `NoSuchElementException`

    - #### peekNext

          public Object peekNext()

      Returns:
        peek at next object

    - #### remove

          public void remove()
                      throws UnsupportedOperationException

      Specified by:
        `remove` in interface `Iterator<Position>`
      Throws:
        `UnsupportedOperationException`

Copyright © 2025 Apache Software Foundation. All rights reserved.