Class XWikiSerializer2
- java.lang.Object
-
- org.xwiki.rendering.wikimodel.PrintTextListener
-
- org.xwiki.rendering.wikimodel.xwiki.xwiki20.XWikiSerializer2
-
- All Implemented Interfaces:
IWemListener
,IWemListenerDocument
,IWemListenerFigure
,IWemListenerInline
,IWemListenerList
,IWemListenerProgramming
,IWemListenerSemantic
,IWemListenerSimpleBlocks
,IWemListenerTable
public class XWikiSerializer2 extends PrintTextListener
Serializing XWiki 2.0 syntax ...
Implementation hints:- This serializer is only tested with transformed MediaWiki sources
- To support nested tables, we're using a stack of tables.
- To get the table caption in front of a table definition, we're using a simple model for, see nested Table class
- Nested definition lists are NOT supported
- Since:
- 4.0M1
- Version:
- $Id: 993e755ab684528bd875f5ea5360cbddd0db1b59 $
- See Also:
XWikiSerializer
-
-
Field Summary
-
Fields inherited from class org.xwiki.rendering.wikimodel.PrintTextListener
fRefHandler
-
-
Constructor Summary
Constructors Constructor Description XWikiSerializer2(IWikiPrinter printer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginDefinitionDescription()
This method is used to notify about a definition description.void
beginDefinitionTerm()
A definition term.void
beginFormat(WikiFormat format)
This method is called at the beginning of a sequence of in-line elements having the specified formatting parameters.void
beginHeader(int headerLevel, WikiParameters params)
This method is called to notify about a new section header found in the document.void
beginList(WikiParameters params, boolean ordered)
This method is used to notify about a new list.void
beginListItem()
This method is used to notify about the beginning of a new item of a simple list (seeIWemListenerList.beginList(WikiParameters, boolean)
/IWemListenerList.endList(WikiParameters, boolean)
methods).void
beginListItem(WikiParameters params)
This method is used to notify about the beginning of a new item of a simple list (seeIWemListenerList.beginList(WikiParameters, boolean)
/IWemListenerList.endList(WikiParameters, boolean)
methods).void
beginTable(WikiParameters params)
This method notifies about the beginning of a new table in the document.void
beginTableCell(boolean tableHead, WikiParameters params)
This method is used to notify about the beginning of a new table cell.void
beginTableRow(WikiParameters params)
This method is used to notify about the beginning of a new table row.static String
clearName(String name)
Clears the name of files; used while uploading attachments within XWiki RECOMMENDED FOR NAMES OF UPLOADED FILES.static String
clearName(String name, boolean stripDots, boolean ascii)
protected void
endBlock()
This method is called at the end of each block element.void
endDefinitionDescription()
This method is used to notify about the end of a definition description.void
endDefinitionTerm()
The end of a definition term.void
endFormat(WikiFormat format)
This method is called to notify about the end of a sequence of in-line elements having common formatting parameters.void
endHeader(int headerLevel, WikiParameters params)
This method is called to notify about the end of a section-level header.void
endList(WikiParameters params, boolean ordered)
This method is used to notify about the end of a list.void
endListItem()
This method is used to notify about the end of an item of a simple list (seeIWemListenerList.beginList(WikiParameters, boolean)
/IWemListenerList.endList(WikiParameters, boolean)
methods).void
endListItem(WikiParameters params)
This method is used to notify about the end of an item of a simple list (seeIWemListenerList.beginList(WikiParameters, boolean)
/IWemListenerList.endList(WikiParameters, boolean)
methods).void
endParagraph(WikiParameters params)
End of a simple paragraph.void
endTable(WikiParameters params)
This method notifies about the end of a table in the document.void
endTableCell(boolean tableHead, WikiParameters params)
This method is used to notify about the end of a table cell.void
endTableRow(WikiParameters params)
This method is used to notify about the end of a table row.protected String
getEol()
protected String
getImageThumbwidth()
Logger
getLogger()
protected ReferenceHandler
newReferenceHandler()
void
onImage(String ref)
This method is called to notify that an free standing image was found in the parsed wiki document.void
onImage(WikiReference ref)
This method is called to notify that a structured reference was found in the textprotected void
onImageThumbnail(WikiReference ref)
Special case when detected, that there are image thumbnail.void
onLineBreak()
This method is called to notify about a forced line break found in the text.void
onNewLine()
This method is called to notify that the parsed block contains a new line sequence ("\r\n"
or"\r"
or"\n"
character sequence).void
onSpecialSymbol(String str)
This method is called to notify about a sequence of special characters.void
onTableCaption(String str)
Notifies the table caption.void
onVerbatimBlock(String str, WikiParameters params)
This method notifies about a verbatim (pre-formatted) block defined in the textvoid
onVerbatimInline(String str, WikiParameters params)
This method is called to notify about not-interpreted in-line sequence of characters which should be represented in the final text "as is".protected void
print(String str)
protected void
println()
protected void
println(String str)
void
setLogger(Logger logger)
-
Methods inherited from class org.xwiki.rendering.wikimodel.PrintTextListener
beginDefinitionList, beginDocument, beginInfoBlock, beginParagraph, beginPropertyBlock, beginPropertyInline, beginQuotation, beginQuotationLine, beginSection, beginSectionContent, endDefinitionList, endDocument, endInfoBlock, endPropertyBlock, endPropertyInline, endQuotation, endQuotationLine, endSection, endSectionContent, isSupportDownload, isSupportImage, onEmptyLines, onEscape, onExtensionBlock, onExtensionInline, onHorizontalLine, onMacroBlock, onMacroInline, onReference, onReference, onSpace, onWord
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xwiki.rendering.wikimodel.IWemListenerFigure
beginFigure, beginFigureCaption, endFigure, endFigureCaption
-
-
-
-
Constructor Detail
-
XWikiSerializer2
public XWikiSerializer2(IWikiPrinter printer)
-
-
Method Detail
-
beginHeader
public void beginHeader(int headerLevel, WikiParameters params)
Description copied from interface:IWemListenerDocument
This method is called to notify about a new section header found in the document.- Specified by:
beginHeader
in interfaceIWemListenerDocument
- Overrides:
beginHeader
in classPrintTextListener
- Parameters:
headerLevel
- the level of the found header; valid values: 1-6params
- the list of parameters for this event- See Also:
IWemListenerDocument.beginHeader(int, WikiParameters)
-
endHeader
public void endHeader(int headerLevel, WikiParameters params)
Description copied from interface:IWemListenerDocument
This method is called to notify about the end of a section-level header.- Specified by:
endHeader
in interfaceIWemListenerDocument
- Overrides:
endHeader
in classPrintTextListener
- Parameters:
headerLevel
- the level of the headerparams
- the list of parameters for this event- See Also:
IWemListenerDocument.endHeader(int, WikiParameters)
-
beginList
public void beginList(WikiParameters params, boolean ordered)
Description copied from interface:IWemListenerList
This method is used to notify about a new list. Each list contain at least one list item. All list items are notified using theIWemListenerList.beginListItem()
/IWemListenerList.endListItem()
method pair. Items of lists of this type can contain the following sequence of elements:- formatted text - the text can be empty; in this case it is not notified
- Just after the text the list item can have:
- an embedded list - in this way it is possible to build hierarchical structures
- an embedded document - it should be defined explicitly and it can have all valid elements of the top-level document
- Specified by:
beginList
in interfaceIWemListenerList
- Overrides:
beginList
in classPrintTextListener
- Parameters:
params
- parameters of the listordered
- if this flag istrue
then this method corresponds to a new ordered list ("ol"); otherwise this method notifies a beginning of an unordered list ("ul")- See Also:
IWemListenerList.beginList(WikiParameters, boolean)
-
endList
public void endList(WikiParameters params, boolean ordered)
Description copied from interface:IWemListenerList
This method is used to notify about the end of a list.- Specified by:
endList
in interfaceIWemListenerList
- Overrides:
endList
in classPrintTextListener
- Parameters:
params
- parameters of the listordered
- if this flag istrue
then this method corresponds to a new ordered list ("ol"); otherwise this method notifies a beginning of an unordered list ("ul")- See Also:
IWemListenerList.endList(WikiParameters, boolean)
-
beginListItem
public void beginListItem()
Description copied from interface:IWemListenerList
This method is used to notify about the beginning of a new item of a simple list (seeIWemListenerList.beginList(WikiParameters, boolean)
/IWemListenerList.endList(WikiParameters, boolean)
methods).- Specified by:
beginListItem
in interfaceIWemListenerList
- Overrides:
beginListItem
in classPrintTextListener
- See Also:
IWemListenerList.beginListItem()
-
beginListItem
public void beginListItem(WikiParameters params)
Description copied from interface:IWemListenerList
This method is used to notify about the beginning of a new item of a simple list (seeIWemListenerList.beginList(WikiParameters, boolean)
/IWemListenerList.endList(WikiParameters, boolean)
methods).- Specified by:
beginListItem
in interfaceIWemListenerList
- Overrides:
beginListItem
in classPrintTextListener
- See Also:
IWemListenerList.endListItem(WikiParameters)
-
endListItem
public void endListItem()
Description copied from interface:IWemListenerList
This method is used to notify about the end of an item of a simple list (seeIWemListenerList.beginList(WikiParameters, boolean)
/IWemListenerList.endList(WikiParameters, boolean)
methods).- Specified by:
endListItem
in interfaceIWemListenerList
- Overrides:
endListItem
in classPrintTextListener
- See Also:
IWemListenerList.endListItem()
-
endListItem
public void endListItem(WikiParameters params)
Description copied from interface:IWemListenerList
This method is used to notify about the end of an item of a simple list (seeIWemListenerList.beginList(WikiParameters, boolean)
/IWemListenerList.endList(WikiParameters, boolean)
methods).- Specified by:
endListItem
in interfaceIWemListenerList
- Overrides:
endListItem
in classPrintTextListener
- See Also:
IWemListenerList.beginListItem(WikiParameters)
-
onImage
public void onImage(String ref)
Description copied from interface:IWemListenerInline
This method is called to notify that an free standing image was found in the parsed wiki document.- Specified by:
onImage
in interfaceIWemListenerInline
- Overrides:
onImage
in classPrintTextListener
- Parameters:
ref
- the reference the reference
-
onImage
public void onImage(WikiReference ref)
Description copied from interface:IWemListenerInline
This method is called to notify that a structured reference was found in the text- Specified by:
onImage
in interfaceIWemListenerInline
- Overrides:
onImage
in classPrintTextListener
- Parameters:
ref
- the reference the reference
-
onImageThumbnail
protected void onImageThumbnail(WikiReference ref)
Special case when detected, that there are image thumbnail. Thus it's possible to insert something like XWiki "LightBox" macro. (Default implementation will set "width:200px")
-
onVerbatimBlock
public void onVerbatimBlock(String str, WikiParameters params)
Description copied from interface:IWemListenerSimpleBlocks
This method notifies about a verbatim (pre-formatted) block defined in the text- Specified by:
onVerbatimBlock
in interfaceIWemListenerSimpleBlocks
- Overrides:
onVerbatimBlock
in classPrintTextListener
- Parameters:
str
- the content of the verbatim (pre-formatted) blockparams
- parameters of the verbatim block- See Also:
IWemListenerSimpleBlocks.onVerbatimBlock(String, WikiParameters)
-
onVerbatimInline
public void onVerbatimInline(String str, WikiParameters params)
Description copied from interface:IWemListenerInline
This method is called to notify about not-interpreted in-line sequence of characters which should be represented in the final text "as is".- Specified by:
onVerbatimInline
in interfaceIWemListenerInline
- Overrides:
onVerbatimInline
in classPrintTextListener
- Parameters:
str
- the sequence of non-interpreted charactersparams
- the list of parameters for this event- See Also:
IWemListenerInline.onVerbatimInline(java.lang.String, WikiParameters)
-
onTableCaption
public void onTableCaption(String str)
Description copied from interface:IWemListenerTable
Notifies the table caption.- Specified by:
onTableCaption
in interfaceIWemListenerTable
- Overrides:
onTableCaption
in classPrintTextListener
- Parameters:
str
- the content of the table caption- See Also:
IWemListenerTable.onTableCaption(java.lang.String)
-
beginTable
public void beginTable(WikiParameters params)
Description copied from interface:IWemListenerTable
This method notifies about the beginning of a new table in the document.- Specified by:
beginTable
in interfaceIWemListenerTable
- Overrides:
beginTable
in classPrintTextListener
- Parameters:
params
- table parameters- See Also:
IWemListenerTable.beginTable(WikiParameters)
-
endTable
public void endTable(WikiParameters params)
Description copied from interface:IWemListenerTable
This method notifies about the end of a table in the document.- Specified by:
endTable
in interfaceIWemListenerTable
- Overrides:
endTable
in classPrintTextListener
- Parameters:
params
- table parameters- See Also:
IWemListenerTable.endTable(WikiParameters)
-
beginTableCell
public void beginTableCell(boolean tableHead, WikiParameters params)
Description copied from interface:IWemListenerTable
This method is used to notify about the beginning of a new table cell.- Specified by:
beginTableCell
in interfaceIWemListenerTable
- Overrides:
beginTableCell
in classPrintTextListener
- Parameters:
tableHead
- if this flag istrue
then the reported cell corresponds to the table head ("th" element); otherwise it should be considered as a normal table cell ("td" element).params
- parameters of this cell- See Also:
IWemListenerTable.beginTableCell(boolean, WikiParameters)
-
endTableCell
public void endTableCell(boolean tableHead, WikiParameters params)
Description copied from interface:IWemListenerTable
This method is used to notify about the end of a table cell.- Specified by:
endTableCell
in interfaceIWemListenerTable
- Overrides:
endTableCell
in classPrintTextListener
- Parameters:
tableHead
- if this flag istrue
then the reported cell corresponds to the table head ("th" element); otherwise it should be considered as a normal table cell ("td" element).params
- parameters of this cell- See Also:
IWemListenerTable.endTableCell(boolean, WikiParameters)
-
beginTableRow
public void beginTableRow(WikiParameters params)
Description copied from interface:IWemListenerTable
This method is used to notify about the beginning of a new table row.- Specified by:
beginTableRow
in interfaceIWemListenerTable
- Overrides:
beginTableRow
in classPrintTextListener
- Parameters:
params
- parameters of the row.- See Also:
IWemListenerTable.beginTableRow(WikiParameters)
-
endTableRow
public void endTableRow(WikiParameters params)
Description copied from interface:IWemListenerTable
This method is used to notify about the end of a table row.- Specified by:
endTableRow
in interfaceIWemListenerTable
- Overrides:
endTableRow
in classPrintTextListener
- Parameters:
params
- parameters of the row.- See Also:
IWemListenerTable.endTableRow(WikiParameters)
-
beginFormat
public void beginFormat(WikiFormat format)
Description copied from interface:IWemListenerInline
This method is called at the beginning of a sequence of in-line elements having the specified formatting parameters.- Specified by:
beginFormat
in interfaceIWemListenerInline
- Overrides:
beginFormat
in classPrintTextListener
- Parameters:
format
- the object defining formatting parameters of in-line elements.- See Also:
IWemListenerInline.beginFormat(WikiFormat)
-
endFormat
public void endFormat(WikiFormat format)
Description copied from interface:IWemListenerInline
This method is called to notify about the end of a sequence of in-line elements having common formatting parameters.- Specified by:
endFormat
in interfaceIWemListenerInline
- Overrides:
endFormat
in classPrintTextListener
- Parameters:
format
- the formatting object defining how contained in-line elements should be formatted- See Also:
IWemListenerInline.endFormat(WikiFormat)
-
endParagraph
public void endParagraph(WikiParameters params)
Description copied from interface:IWemListenerSimpleBlocks
End of a simple paragraph.- Specified by:
endParagraph
in interfaceIWemListenerSimpleBlocks
- Overrides:
endParagraph
in classPrintTextListener
- Parameters:
params
- paragraph parameters- See Also:
IWemListenerSimpleBlocks.endParagraph(WikiParameters)
-
endBlock
protected void endBlock()
Description copied from class:PrintTextListener
This method is called at the end of each block element. It can be overloaded in subclasses.- Overrides:
endBlock
in classPrintTextListener
-
getEol
protected String getEol()
-
onLineBreak
public void onLineBreak()
Description copied from interface:IWemListenerInline
This method is called to notify about a forced line break found in the text. Note that the line break symbol can be found in the middle of a "physical" line so this event is not equals to theIWemListenerInline.onNewLine()
notification.- Specified by:
onLineBreak
in interfaceIWemListenerInline
- Overrides:
onLineBreak
in classPrintTextListener
- See Also:
IWemListenerInline.onLineBreak()
-
onNewLine
public void onNewLine()
Description copied from interface:IWemListenerInline
This method is called to notify that the parsed block contains a new line sequence ("\r\n"
or"\r"
or"\n"
character sequence). Note that the new line symbols are not the same as a forced line break sequence notified by theIWemListenerInline.onLineBreak()
event.- Specified by:
onNewLine
in interfaceIWemListenerInline
- Overrides:
onNewLine
in classPrintTextListener
- See Also:
IWemListenerInline.onNewLine()
-
onSpecialSymbol
public void onSpecialSymbol(String str)
Description copied from interface:IWemListenerInline
This method is called to notify about a sequence of special characters. Special symbols are characters which are not interpreted as a part of a word (letters or digits) or as a space. Note that the handling of these symbols requires special attention because these symbols most frequently used to define text formatting. Various wiki syntaxes use combinations of these sequences to define structural elements in wiki documents.The full list of possible special symbols:
"!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "@", "[", "\\", "]", "^", "_", "`", "{", "|", "}", "~"
- Specified by:
onSpecialSymbol
in interfaceIWemListenerInline
- Overrides:
onSpecialSymbol
in classPrintTextListener
- Parameters:
str
- the sequence of special symbols- See Also:
IWemListenerInline.onSpecialSymbol(java.lang.String)
-
beginDefinitionTerm
public void beginDefinitionTerm()
Description copied from interface:IWemListenerList
A definition term. Definition terms can contain only formatted texts. Note that it is impossible to have an embedded list or a document inside of definition terms.- Specified by:
beginDefinitionTerm
in interfaceIWemListenerList
- Overrides:
beginDefinitionTerm
in classPrintTextListener
- See Also:
IWemListenerList.beginDefinitionTerm()
-
endDefinitionTerm
public void endDefinitionTerm()
Description copied from interface:IWemListenerList
The end of a definition term.- Specified by:
endDefinitionTerm
in interfaceIWemListenerList
- Overrides:
endDefinitionTerm
in classPrintTextListener
- See Also:
IWemListenerList.endDefinitionTerm()
-
beginDefinitionDescription
public void beginDefinitionDescription()
Description copied from interface:IWemListenerList
This method is used to notify about a definition description. All definition descriptions are contained in definition lists and can contain text, embedded lists or an embedded document.- Specified by:
beginDefinitionDescription
in interfaceIWemListenerList
- Overrides:
beginDefinitionDescription
in classPrintTextListener
- See Also:
IWemListenerList.beginDefinitionDescription()
-
endDefinitionDescription
public void endDefinitionDescription()
Description copied from interface:IWemListenerList
This method is used to notify about the end of a definition description.- Specified by:
endDefinitionDescription
in interfaceIWemListenerList
- Overrides:
endDefinitionDescription
in classPrintTextListener
- See Also:
IWemListenerList.endDefinitionDescription()
-
getImageThumbwidth
protected String getImageThumbwidth()
- Returns:
- The wisth information for a thumbnail image
-
print
protected void print(String str)
- Overrides:
print
in classPrintTextListener
-
println
protected void println()
- Overrides:
println
in classPrintTextListener
-
println
protected void println(String str)
- Overrides:
println
in classPrintTextListener
-
newReferenceHandler
protected ReferenceHandler newReferenceHandler()
- Overrides:
newReferenceHandler
in classPrintTextListener
-
getLogger
public Logger getLogger()
- Returns:
- the logger
-
setLogger
public void setLogger(Logger logger)
- Parameters:
logger
- the logger to set
-
clearName
public static final String clearName(String name, boolean stripDots, boolean ascii)
- See Also:
clearName(String)
-
-