public interface Block extends Cloneable
Modifier and Type | Interface and Description |
---|---|
static class |
Block.Axes
Search axes used in searching methods.
|
Modifier and Type | Field and Description |
---|---|
static Type |
LIST_BLOCK_TYPE
Helper to represent the Type for each List<Block>.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(Block blockToAdd)
Helper method to add a single child block to the end of the children list of the current block.
|
void |
addChildren(List<? extends Block> blocksToAdd)
Adds several children blocks to the end of the children list of the current block.
|
Block |
clone() |
Block |
clone(BlockFilter blockFilter)
Return a copy of the block with filtered children.
|
<T extends Block> |
getBlocks(BlockMatcher matcher,
Block.Axes axes)
Get all blocks following provided
BlockMatcher and Block.Axes . |
List<Block> |
getChildren()
Gets all children blocks.
|
<T extends Block> |
getFirstBlock(BlockMatcher matcher,
Block.Axes axes)
Get the first matched block in the provided
Block.Axes . |
Block |
getNextSibling() |
String |
getParameter(String name)
A Parameter is a generic key/value which can be used to add metadata to a block.
|
Map<String,String> |
getParameters() |
Block |
getParent()
Get the parent block.
|
Block |
getPreviousSibling() |
Block |
getRoot()
Gets the top level Block.
|
void |
insertChildAfter(Block blockToInsert,
Block previousBlock)
Helper method to add a single child block to the current block after the provided existing child block.
|
void |
insertChildBefore(Block blockToInsert,
Block nextBlock)
Helper method to add a single child block to the current block before the provided existing child block.
|
void |
removeBlock(Block childBlockToRemove)
Removes a Block.
|
void |
replaceChild(Block newBlock,
Block oldBlock)
Replaces an existing children block with the passed new block.
|
void |
replaceChild(List<Block> newBlocks,
Block oldBlock)
Replaces an existing children block with the passed new blocks.
|
void |
setChildren(List<? extends Block> children)
Replace current children by the provided list of
Block s. |
void |
setNextSiblingBlock(Block nextSiblingBlock) |
void |
setParameter(String name,
String value)
Set a parameter on the current block.
|
void |
setParameters(Map<String,String> parameters)
Set several parameters at once.
|
void |
setParent(Block parentBlock)
Sets the parent block.
|
void |
setPreviousSiblingBlock(Block previousSiblingBlock) |
void |
traverse(Listener listener)
Let the block send
Listener events corresponding to its content. |
static final Type LIST_BLOCK_TYPE
void traverse(Listener listener)
Listener
events corresponding to its content. For example a Paragraph block will send
the Listener.beginParagraph(java.util.Map<java.lang.String, java.lang.String>)
and
Listener.endParagraph(java.util.Map<java.lang.String, java.lang.String>)
events when this method is called.listener
- the listener to which to send the events to.void addChild(Block blockToAdd)
addChildren(java.util.List)
.blockToAdd
- the child block to addvoid addChildren(List<? extends Block> blocksToAdd)
blocksToAdd
- the children blocks to addvoid setChildren(List<? extends Block> children)
Block
s.children
- the new childrenvoid insertChildBefore(Block blockToInsert, Block nextBlock)
addChildren(java.util.List)
.blockToInsert
- the child block to addnextBlock
- the child block that will be just after the added blockvoid insertChildAfter(Block blockToInsert, Block previousBlock)
addChildren(java.util.List)
.blockToInsert
- the child block to addpreviousBlock
- the child block that will be just before the added blockvoid replaceChild(Block newBlock, Block oldBlock)
newBlock
- the new block to replace the old block witholdBlock
- the block to replace with the new blockvoid replaceChild(List<Block> newBlocks, Block oldBlock)
newBlocks
- the new blocks to replace the old block witholdBlock
- the block to replace with the new blocksBlock getParent()
XDOM
object.void setParent(Block parentBlock)
parentBlock
- the parent blockList<Block> getChildren()
addChildren(java.util.List)
Block getRoot()
void removeBlock(Block childBlockToRemove)
childBlockToRemove
- the child block to removeBlock getNextSibling()
void setNextSiblingBlock(Block nextSiblingBlock)
nextSiblingBlock
- see getNextSibling()
Block getPreviousSibling()
void setPreviousSiblingBlock(Block previousSiblingBlock)
previousSiblingBlock
- see getPreviousSibling()
()}Block clone(BlockFilter blockFilter)
blockFilter
- the Block filter.Block clone()
Object.clone()
String getParameter(String name)
name
- the name of the parameter to returnvoid setParameter(String name, String value)
getParameter(String)
for more details.name
- the parameter's namevalue
- the parameter's valuevoid setParameters(Map<String,String> parameters)
parameters
- the parameters to setgetParameter(String)
<T extends Block> List<T> getBlocks(BlockMatcher matcher, Block.Axes axes)
BlockMatcher
and Block.Axes
.T
- the class of the Blocks to returnmatcher
- filter the blocks to returnaxes
- indicate the search axesBlock
s, empty list of none was found<T extends Block> T getFirstBlock(BlockMatcher matcher, Block.Axes axes)
Block.Axes
.T
- the class of the Block to returnmatcher
- indicate which block to stop toaxes
- indicate the search axesBlock
, null if none was foundCopyright © 2004–2021 XWiki. All rights reserved.