|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Block
Represents an element of a XWiki Document's content. For example there are Blocks for Paragraphs, Bold parts, Sections, Links, etc. A block has a parent and can have children too for Blocks which are wrapper around other blocks (e.g. Paragraph blocks, List blocks, Bold blocks).
| Nested Class Summary | |
|---|---|
static class |
Block.Axes
Search axes used in searching methods. |
| Method Summary | ||
|---|---|---|
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(java.util.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. |
|
java.util.List<Block> |
getBlocks(BlockMatcher matcher,
Block.Axes axes)
Get all blocks following provided BlockMatcher and Block.Axes. |
|
java.util.List<Block> |
getChildren()
Gets all children blocks. |
|
|
getChildrenByType(java.lang.Class<T> blockClass,
boolean recurse)
Deprecated. since 3.0M3 use getBlocks(BlockMatcher, Axes) instead |
|
Block |
getFirstBlock(BlockMatcher matcher,
Block.Axes axes)
Get the first matched block in the provided Block.Axes. |
|
Block |
getNextSibling()
|
|
java.lang.String |
getParameter(java.lang.String name)
A Parameter is a generic key/value which can be used to add metadata to a block. |
|
java.util.Map<java.lang.String,java.lang.String> |
getParameters()
|
|
Block |
getParent()
Get the parent block. |
|
|
getParentBlockByType(java.lang.Class<T> blockClass)
Deprecated. since 3.0M3 use getBlocks(BlockMatcher, Axes) instead |
|
|
getPreviousBlockByType(java.lang.Class<T> blockClass,
boolean recurse)
Deprecated. since 3.0M3 use getBlocks(BlockMatcher, Axes) instead |
|
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(java.util.List<Block> newBlocks,
Block oldBlock)
Replaces an existing children block with the passed new blocks. |
|
void |
setChildren(java.util.List<? extends Block> children)
Replace current children by the provided list of Blocks. |
|
void |
setNextSiblingBlock(Block nextSiblingBlock)
|
|
void |
setParameter(java.lang.String name,
java.lang.String value)
Set a parameter on the current block. |
|
void |
setParameters(java.util.Map<java.lang.String,java.lang.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. |
|
| Method Detail |
|---|
void traverse(Listener listener)
Listener events corresponding to its content. For example a Paragraph block will send
the Listener.beginParagraph(java.util.Map) and
Listener.endParagraph(java.util.Map) 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(java.util.List<? extends Block> blocksToAdd)
blocksToAdd - the children blocks to addvoid setChildren(java.util.List<? extends Block> children)
Blocks.
children - the new children
void 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 block
void 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 block
void replaceChild(Block newBlock,
Block oldBlock)
newBlock - the new block to replace the old block witholdBlock - the block to replace with the new block
void replaceChild(java.util.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 blockjava.util.List<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()java.util.Map<java.lang.String,java.lang.String> getParameters()
java.lang.String getParameter(java.lang.String name)
name - the name of the parameter to return
void setParameter(java.lang.String name,
java.lang.String value)
getParameter(String) for more details.
name - the parameter's namevalue - the parameter's valuevoid setParameters(java.util.Map<java.lang.String,java.lang.String> parameters)
parameters - the parameters to setgetParameter(String)
java.util.List<Block> getBlocks(BlockMatcher matcher,
Block.Axes axes)
BlockMatcher and Block.Axes.
matcher - filter the blocks to returnaxes - indicate the search axes
Blocks, empty list of none was found
Block getFirstBlock(BlockMatcher matcher,
Block.Axes axes)
Block.Axes.
matcher - indicate which block to stop toaxes - indicate the search axes
Block, null if none was found
@Deprecated
<T extends Block> java.util.List<T> getChildrenByType(java.lang.Class<T> blockClass,
boolean recurse)
getBlocks(BlockMatcher, Axes) instead
T - the class of the Blocks to returnblockClass - the block class to look forrecurse - if true also search recursively children
@Deprecated
<T extends Block> T getPreviousBlockByType(java.lang.Class<T> blockClass,
boolean recurse)
getBlocks(BlockMatcher, Axes) instead
The difference with getParentBlockByType(Class) is that this one look also at previous block in the same
parent when getParentBlockByType(Class) only look at parents.
T - the class of the Blocks to returnblockClass - the block class to look forrecurse - if true also search in parents levels
@Deprecated <T extends Block> T getParentBlockByType(java.lang.Class<T> blockClass)
getBlocks(BlockMatcher, Axes) instead
The difference with getPreviousBlockByType(Class, boolean) is that this one only look at parent when
getPreviousBlockByType(Class, boolean) look at previous block in the same parent.
T - the class of the Blocks to returnblockClass - the block class to look for
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||