Class BlockNavigator

java.lang.Object
org.xwiki.rendering.block.match.BlockNavigator

public class BlockNavigator extends Object
Tool to navigate in a tree of blocks and extract them based on configurable criteria.
Since:
5.0M1
Version:
$Id: e26c8beac34b7eb222b6cb8b1274e0cf20c98223 $
  • Constructor Details

    • BlockNavigator

      public BlockNavigator()
      The default matcher does not filter anything.
    • BlockNavigator

      public BlockNavigator(BlockMatcher matcher)
      Parameters:
      matcher - used to filter the result of the various methods
  • Method Details

    • getBlocks

      public <T extends Block> List<T> getBlocks(Block currentBlock, Block.Axes currentAxes)
      Get all blocks following provided BlockMatcher and Block.Axes.
      Type Parameters:
      T - the class of the Blocks to return
      Parameters:
      currentBlock - the block to start searching from
      currentAxes - indicate the search axes
      Returns:
      the matched Blocks, empty list of none was found
    • getFirstBlock

      public <T extends Block> T getFirstBlock(Block currentBlock, Block.Axes currentAxes)
      Get the first matched block in the provided Block.Axes.
      Type Parameters:
      T - the class of the Block to return
      Parameters:
      currentBlock - the block to start searching from
      currentAxes - indicate the search axes
      Returns:
      the matched Block, null if none was found