Package org.xwiki.rendering.listener
Interface Listener
- All Superinterfaces:
ImageListener,LinkListener
- All Known Subinterfaces:
ChainingListener,ContentHandlerStreamRenderer,PrintRenderer,Renderer,StackableChainingListener
- All Known Implementing Classes:
AbstractChainingListener,AbstractChainingPrintRenderer,BlockStateChainingListener,CompositeListener,ConsecutiveNewLineStateChainingListener,EmptyBlockChainingListener,GroupStateChainingListener,InlineFilterListener,LookaheadChainingListener,MetaDataStateChainingListener,QueueListener,SectionGeneratorListener,VoidListener,WrappingListener
Contains callback events called when a document has been parsed and when it needs to be modified or rendered. More
specifically when a document is parsed it generates an
XDOM object. That object has
a AbstractBlock.traverse(Listener) method that accepts a Listener object. For each
Block element found in the document its
Block.traverse(org.xwiki.rendering.listener.Listener) method is called leading to the generation of events from this
interface.
Here's an example of usage:
<code> XDOM dom = parser.parse(source); MyListener listener = new MyListener(...); dom.traverse(listener); // At this stage all events have been sent to MyListener. </code>
- Since:
- 1.5M2
- Version:
- $Id: a18ac6cb453fc36f33223cd64cad4f8c514f5474 $
-
Field Summary
FieldsModifier and TypeFieldDescriptionTo use when there is no parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidStart of a definition list description.voidbeginDefinitionList(Map<String, String> parameters) Start of a definition list.voidStart of a definition list term.voidbeginDocument(MetaData metadata) Start of the document.default voidbeginFigure(Map<String, String> parameters) Start of a figure.default voidbeginFigureCaption(Map<String, String> parameters) Start of a figure caption.voidbeginFormat(Format format, Map<String, String> parameters) End of a text formatting block.voidbeginGroup(Map<String, String> parameters) Start a group of elements.voidbeginHeader(HeaderLevel level, String id, Map<String, String> parameters) Start of a header.voidStart of a list.voidStart of a list item.default voidbeginListItem(Map<String, String> parameters) Start of a list item.voidStart of marker containing a macro definition.voidbeginMetaData(MetaData metadata) Start of MetaData (eg saving source from where the content is coming from).voidbeginParagraph(Map<String, String> parameters) Start of a paragraph.voidbeginQuotation(Map<String, String> parameters) Start of a quotation.voidStart of a quotation line.voidbeginSection(Map<String, String> parameters) Start of a section.voidbeginTable(Map<String, String> parameters) Start of a table.voidbeginTableCell(Map<String, String> parameters) Start of a table cell.voidbeginTableHeadCell(Map<String, String> parameters) Start of a table head cell.voidbeginTableRow(Map<String, String> parameters) Start of a table row.voidEnd of a definition list description.voidendDefinitionList(Map<String, String> parameters) End of a definition list.voidEnd of a definition list term.voidendDocument(MetaData metadata) End of the document.default voidEnd of a figure.default voidendFigureCaption(Map<String, String> parameters) End of a figure caption.voidEnd of a text formatting block.voidEnd of the group.voidEnd of a header.voidEnd of a list.voidEnd of a list item.default voidendListItem(Map<String, String> parameters) End of a list item.voidEnd of marker containing a macro definition.voidendMetaData(MetaData metadata) End of MetaData.voidendParagraph(Map<String, String> parameters) End of a paragraph.voidendQuotation(Map<String, String> parameters) End of a quotation.voidEnd of a quotation line.voidendSection(Map<String, String> parameters) End of a section.voidEnd of a table.voidendTableCell(Map<String, String> parameters) End of a table cell.voidendTableHeadCell(Map<String, String> parameters) End of a table head cell.voidendTableRow(Map<String, String> parameters) End of a table row.voidonEmptyLines(int count) Represents an empty line between 2 standalone Blocks.voidonHorizontalLine(Map<String, String> parameters) Represents an horizontal line.voidA reference/location in a page.voidA Macro.voidA new line or line break (it's up to the renderers to decide if it should be outputted as a new line or as a line break in the given syntax).voidSome text to inject directly into the listener output without parsing it.voidonSpace()A space.voidonSpecialSymbol(char symbol) A special symbol (*,<,>,=, quote, etc).voidonVerbatim(String content, boolean inline, Map<String, String> parameters) A portion of text.voidA word.Methods inherited from interface org.xwiki.rendering.listener.ImageListener
onImage, onImageMethods inherited from interface org.xwiki.rendering.listener.LinkListener
beginLink, endLink
-
Field Details
-
EMPTY_PARAMETERS
To use when there is no parameters.
-
-
Method Details
-
beginDocument
Start of the document.- Parameters:
metadata- the meta data to associate to the following events, seeMetaData- Since:
- 3.0M2
-
endDocument
End of the document.- Parameters:
metadata- the meta data associated with the previous events, seeMetaData- Since:
- 3.0M2
-
beginMetaData
Start of MetaData (eg saving source from where the content is coming from).- Parameters:
metadata- the metadata- Since:
- 3.0M2
-
endMetaData
End of MetaData.- Parameters:
metadata- the metadata- Since:
- 3.0M2
-
beginGroup
Start a group of elements. Groups are used to allow using standalone elements in list items, table cells, etc. They can also be used to set parameters on a group of standalone elements.- Parameters:
parameters- a generic list of parameters. Example: style="background-color: blue"- Since:
- 1.8.3
-
endGroup
End of the group.- Parameters:
parameters- a generic list of parameters. Example: style="background-color: blue"- Since:
- 1.8.3
-
beginFormat
End of a text formatting block.- Parameters:
format- the formatting type (bold, italic, etc)parameters- a generic list of parameters. Example: style="background-color: blue"- See Also:
-
endFormat
End of a text formatting block.- Parameters:
format- the formatting type (bold, italic, etc)parameters- a generic list of parameters. Example: style="background-color: blue"- See Also:
-
beginParagraph
Start of a paragraph.- Parameters:
parameters- a generic list of parameters. Example: style="background-color: blue"
-
endParagraph
End of a paragraph.- Parameters:
parameters- a generic list of parameters. Example: style="background-color: blue"
-
beginList
Start of a list.- Parameters:
type- the type of list (bulleted, numbered, etc)parameters- a generic list of parameters for the list. Example: "style"/"background-color: blue"- See Also:
-
beginDefinitionList
Start of a definition list. For example in HTML this is the equivalent of <dl>.- Parameters:
parameters- a generic list of parameters for the list. Example: "style"/"background-color: blue"- Since:
- 2.0RC1
-
endList
End of a list.- Parameters:
type- the type of list (bulleted, numbered, etc)parameters- a generic list of parameters for the list. Example: "style"/"background-color: blue"- See Also:
-
endDefinitionList
End of a definition list. For example in HTML this is the equivalent of </dl>.- Parameters:
parameters- a generic list of parameters for the list. Example: "style"/"background-color: blue"- Since:
- 2.0RC1
-
beginListItem
void beginListItem()Start of a list item. -
beginListItem
Start of a list item.- Parameters:
parameters- a generic list of parameters for the list item. Example: "style"/"background-color: blue"- Since:
- 10.0
-
beginDefinitionTerm
void beginDefinitionTerm()Start of a definition list term. For example in HTML this is the equivalent of <dt>.- Since:
- 1.6M2
-
beginDefinitionDescription
void beginDefinitionDescription()Start of a definition list description. For example in HTML this is the equivalent of <dd>.- Since:
- 1.6M2
-
endListItem
void endListItem()End of a list item. -
endListItem
End of a list item.- Parameters:
parameters- a generic list of parameters for the list item. Example: "style"/"background-color: blue"- Since:
- 10.0
-
endDefinitionTerm
void endDefinitionTerm()End of a definition list term. For example in HTML this is the equivalent of </dt>.- Since:
- 1.6M2
-
endDefinitionDescription
void endDefinitionDescription()End of a definition list description. For example in HTML this is the equivalent of </dd>.- Since:
- 1.6M2
-
beginTable
Start of a table.- Parameters:
parameters- a generic list of parameters for the table.- Since:
- 1.6M2
-
beginTableRow
Start of a table row.- Parameters:
parameters- a generic list of parameters for the table row.- Since:
- 1.6M2
-
beginTableCell
Start of a table cell.- Parameters:
parameters- a generic list of parameters for the table cell.- Since:
- 1.6M2
-
beginTableHeadCell
Start of a table head cell.- Parameters:
parameters- a generic list of parameters for the table head cell.- Since:
- 1.6M2
-
endTable
End of a table.- Parameters:
parameters- a generic list of parameters for the table.- Since:
- 1.6M2
-
endTableRow
End of a table row.- Parameters:
parameters- a generic list of parameters for the table row.- Since:
- 1.6M2
-
endTableCell
End of a table cell.- Parameters:
parameters- a generic list of parameters for the table cell.- Since:
- 1.6M2
-
endTableHeadCell
End of a table head cell.- Parameters:
parameters- a generic list of parameters for the table head cell.- Since:
- 1.6M2
-
beginSection
Start of a section.- Parameters:
parameters- a generic list of parameters. Example: style="background-color: blue"- See Also:
-
endSection
End of a section.- Parameters:
parameters- a generic list of parameters. Example: style="background-color: blue"- See Also:
-
beginHeader
void beginHeader(@Default("1") HeaderLevel level, String id, @Default("") Map<String, String> parameters) Start of a header.- Parameters:
level- the header level (1, 2, 3, etc)id- the header unique identifierparameters- a generic list of parameters. Example: style="background-color: blue"- Since:
- 1.9M1
- See Also:
-
endHeader
void endHeader(@Default("1") HeaderLevel level, String id, @Default("") Map<String, String> parameters) End of a header.- Parameters:
level- the header level (1, 2, 3, etc)id- the header unique identifierparameters- a generic list of parameters. Example: style="background-color: blue"- Since:
- 1.9M1
- See Also:
-
beginMacroMarker
void beginMacroMarker(String name, @Default("") Map<String, String> parameters, String content, boolean inline) Start of marker containing a macro definition. This is a special that Macro Blocks emits when they are executed so that it's possible to reconstruct the initial macro syntax even after Macros have been executed. This is used for exemple by the WYSIWYG editor to let use see the result of executing a macro and still let them modify the macro definition.- Parameters:
name- the macro nameparameters- the macro parameterscontent- the macro contentinline- if true the macro is located in a inline content (like paragraph, etc.)- See Also:
-
endMacroMarker
void endMacroMarker(String name, @Default("") Map<String, String> parameters, String content, boolean inline) End of marker containing a macro definition.- Parameters:
name- the macro nameparameters- the macro parameterscontent- the macro contentinline- if true the macro is located in a inline content (like paragraph, etc.)- See Also:
-
beginQuotation
Start of a quotation. There are one or several quotation lines inside a quotation block.- Parameters:
parameters- a generic list of parameters for the quotation. Example: "style"/"background-color: blue"
-
endQuotation
End of a quotation.- Parameters:
parameters- a generic list of parameters for the quotation. Example: "style"/"background-color: blue"
-
beginQuotationLine
void beginQuotationLine()Start of a quotation line. There can be several quotation lines in a quotation block. -
endQuotationLine
void endQuotationLine()End of a quotation line. -
beginFigure
Start of a figure.- Parameters:
parameters- a generic list of parameters for the figure- Since:
- 10.2
-
endFigure
End of a figure.- Parameters:
parameters- a generic list of parameters for the figure- Since:
- 10.2
-
beginFigureCaption
Start of a figure caption.- Parameters:
parameters- a generic list of parameters for the figure- Since:
- 10.2
-
endFigureCaption
End of a figure caption.- Parameters:
parameters- a generic list of parameters for the figure- Since:
- 10.2
-
onNewLine
void onNewLine()A new line or line break (it's up to the renderers to decide if it should be outputted as a new line or as a line break in the given syntax). -
onMacro
void onMacro(String id, @Default("") Map<String, String> parameters, String content, @Name("inline") boolean inline) A Macro.- Parameters:
id- the macro id (eg "toc" for the TOC macro)parameters- the macro parameterscontent- the macro contentinline- if true the macro is located in a inline content (like paragraph, etc.)- Since:
- 1.6M2
-
onWord
A word. Note that sentences ar broken into different events: word events, special symbols events, space events, etc. This allows fine-grained actions for listeners.- Parameters:
word- the word encountered
-
onSpace
void onSpace()A space. -
onSpecialSymbol
void onSpecialSymbol(char symbol) A special symbol (*,<,>,=, quote, etc). Any non alpha numeric character is a special symbol.- Parameters:
symbol- the symbol encountered
-
onId
A reference/location in a page. In HTML for example this is called an Anchor. It allows pointing to that location, for example in links. Note that there is no wiki syntax for this in general and it's often generated by Macros (such as the TOC Macro).- Parameters:
name- the location name.- Since:
- 1.6M1
-
onHorizontalLine
Represents an horizontal line.- Parameters:
parameters- a generic list of parameters. Example: style="background-color: blue"- Since:
- 1.6M1
-
onEmptyLines
void onEmptyLines(@Default("1") int count) Represents an empty line between 2 standalone Blocks. A standalone block is block that is not included in another block. Standalone blocks are Paragraph, Standalone Macro, Lists, Table, etc.- Parameters:
count- the number of empty lines between 2 standalone Blocks
-
onVerbatim
void onVerbatim(@Name("content") String content, boolean inline, @Default("") Map<String, String> parameters) A portion of text.- Parameters:
content- the string to protected from renderinginline- if true the text content is located in a inline content (like paragraph, etc.)parameters- a generic list of parameters. Example: style="background-color: blue"
-
onRawText
Some text to inject directly into the listener output without parsing it. For example a HTML macro could inject directly some HTML entered by the user into the rendered HTML output. Note that it's not recommended to use this event in most cases since it can lead to invalid content being generated and in addition most listener implementations will not understand the injected text and will just ignore it.- Parameters:
content- the text to injectsyntax- the syntax in which the text is written. This is useful so that listener implementations can decide whether they can handle direct inject for that syntax
-