public abstract class AbstractBlock extends Object implements Block
getParameter(String) for more details.Block.AxesLIST_BLOCK_TYPE| Constructor and Description |
|---|
AbstractBlock()
Empty constructor to construct an empty block.
|
AbstractBlock(Block childBlock)
Constructs a block with a child block.
|
AbstractBlock(Block childBlock,
Map<String,String> parameters)
Construct a block with a child block and parameters.
|
AbstractBlock(List<? extends Block> childrenBlocks)
Constructs a block with children blocks.
|
AbstractBlock(List<? extends Block> childrenBlocks,
Map<String,String> parameters)
Construct a block with children blocks and parameters.
|
AbstractBlock(Map<String,String> parameters)
Construct a block with parameters.
|
| 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.
|
void |
after(Listener listener)
Send
Listener events corresponding to the end of the block. |
void |
before(Listener listener)
Send
Listener events corresponding to the start of the block. |
Block |
clone() |
Block |
clone(BlockFilter blockFilter)
Return a copy of the block with filtered children.
|
boolean |
equals(Object obj) |
<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.
|
int |
hashCode() |
long |
indexOf(Block child)
Find the index of the block in the tree.
|
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
Blocks. |
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. |
public AbstractBlock()
public AbstractBlock(Map<String,String> parameters)
parameters - the parameters to setpublic AbstractBlock(Block childBlock)
childBlock - the child block of this blockpublic AbstractBlock(List<? extends Block> childrenBlocks)
childrenBlocks - the list of children blocks of the block to constructpublic AbstractBlock(Block childBlock, Map<String,String> parameters)
childBlock - the child block of this blockparameters - the parameters to setpublic void addChild(Block blockToAdd)
BlockBlock.addChildren(java.util.List).public void addChildren(List<? extends Block> blocksToAdd)
BlockaddChildren in interface BlockblocksToAdd - the children blocks to addpublic void setChildren(List<? extends Block> children)
BlockBlocks.setChildren in interface Blockchildren - the new childrenpublic void setNextSiblingBlock(Block nextSiblingBlock)
setNextSiblingBlock in interface BlocknextSiblingBlock - see Block.getNextSibling()public void setPreviousSiblingBlock(Block previousSiblingBlock)
setPreviousSiblingBlock in interface BlockpreviousSiblingBlock - see Block.getPreviousSibling() ()}public void insertChildBefore(Block blockToInsert, Block nextBlock)
BlockBlock.addChildren(java.util.List).insertChildBefore in interface BlockblockToInsert - the child block to addnextBlock - the child block that will be just after the added blockpublic void insertChildAfter(Block blockToInsert, Block previousBlock)
BlockBlock.addChildren(java.util.List).insertChildAfter in interface BlockblockToInsert - the child block to addpreviousBlock - the child block that will be just before the added blockpublic void replaceChild(Block newBlock, Block oldBlock)
BlockreplaceChild in interface BlocknewBlock - the new block to replace the old block witholdBlock - the block to replace with the new blockpublic void replaceChild(List<Block> newBlocks, Block oldBlock)
BlockreplaceChild in interface BlocknewBlocks - the new blocks to replace the old block witholdBlock - the block to replace with the new blockspublic long indexOf(Block child)
child - the block for which to find the indexpublic List<Block> getChildren()
BlockgetChildren in interface BlockBlock.addChildren(java.util.List)public Block getParent()
BlockXDOM object.public Map<String,String> getParameters()
getParameters in interface Blockpublic String getParameter(String name)
BlockgetParameter in interface Blockname - the name of the parameter to returnpublic void setParameter(String name, String value)
BlockBlock.getParameter(String) for more details.setParameter in interface Blockname - the parameter's namevalue - the parameter's valuepublic void setParameters(Map<String,String> parameters)
BlocksetParameters in interface Blockparameters - the parameters to setBlock.getParameter(String)public void setParent(Block parentBlock)
Blockpublic Block getRoot()
Blockpublic Block getNextSibling()
getNextSibling in interface Blockpublic Block getPreviousSibling()
getPreviousSibling in interface Blockpublic void removeBlock(Block childBlockToRemove)
BlockremoveBlock in interface BlockchildBlockToRemove - the child block to removepublic Block clone()
clone in interface Blockclone in class ObjectObject.clone()public Block clone(BlockFilter blockFilter)
public void traverse(Listener listener)
BlockListener 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.public void before(Listener listener)
Listener events corresponding to the start of the block. For example
for a Bold block, this allows an XHTML Listener (aka a Renderer) to output <b>.listener - the listener that will receive the events sent by this block before its children blocks have
emitted their own events.public void after(Listener listener)
Listener events corresponding to the end of the block. For example for a Bold block, this allows an
XHTML Listener (aka a Renderer) to output </b>.listener - the listener that will receive the events sent by this block before its children blocks have
emitted their own events.public <T extends Block> List<T> getBlocks(BlockMatcher matcher, Block.Axes axes)
BlockBlockMatcher and Block.Axes.public <T extends Block> T getFirstBlock(BlockMatcher matcher, Block.Axes axes)
BlockBlock.Axes.getFirstBlock in interface BlockT - 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.