Package org.xwiki.rendering.block.match
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 Summary
Constructors Constructor Description BlockNavigator()
The default matcher does not filter anything.BlockNavigator(BlockMatcher matcher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Block>
List<T>getBlocks(Block currentBlock, Block.Axes currentAxes)
Get all blocks following providedBlockMatcher
andBlock.Axes
.<T extends Block>
TgetFirstBlock(Block currentBlock, Block.Axes currentAxes)
Get the first matched block in the providedBlock.Axes
.
-
-
-
Constructor Detail
-
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 Detail
-
getBlocks
public <T extends Block> List<T> getBlocks(Block currentBlock, Block.Axes currentAxes)
Get all blocks following providedBlockMatcher
andBlock.Axes
.- Type Parameters:
T
- the class of the Blocks to return- Parameters:
currentBlock
- the block to start searching fromcurrentAxes
- indicate the search axes- Returns:
- the matched
Block
s, 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 providedBlock.Axes
.- Type Parameters:
T
- the class of the Block to return- Parameters:
currentBlock
- the block to start searching fromcurrentAxes
- indicate the search axes- Returns:
- the matched
Block
, null if none was found
-
-