org.xwiki.rendering.block.match
Class BlockNavigator

java.lang.Object
  extended by 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: 53b9977f911089f7915c98a9ffb8a5663f57973b $

Constructor Summary
BlockNavigator()
          The default matcher does not filter anything.
BlockNavigator(BlockMatcher matcher)
           
 
Method Summary
<T extends Block>
List<T>
getBlocks(Block currentBlock, Block.Axes currentAxes)
          Get all blocks following provided BlockMatcher and Block.Axes.
<T extends Block>
T
getFirstBlock(Block currentBlock, Block.Axes currentAxes)
          Get the first matched block in the provided Block.Axes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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


Copyright © 2004-2013 XWiki. All Rights Reserved.