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: 5df270efc2f4d7fa55c288ce94476903b866f9da $
- 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 voidbeginDefinitionDescription()This method is used to notify about a definition description.voidbeginDefinitionTerm()A definition term.voidbeginFormat(WikiFormat format)This method is called at the beginning of a sequence of in-line elements having the specified formatting parameters.voidbeginHeader(int headerLevel, WikiParameters params)This method is called to notify about a new section header found in the document.voidbeginList(WikiParameters params, boolean ordered)This method is used to notify about a new list.voidbeginListItem()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).voidbeginListItem(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).voidbeginTable(WikiParameters params)This method notifies about the beginning of a new table in the document.voidbeginTableCell(boolean tableHead, WikiParameters params)This method is used to notify about the beginning of a new table cell.voidbeginTableRow(WikiParameters params)This method is used to notify about the beginning of a new table row.static StringclearName(String name)Clears the name of files; used while uploading attachments within XWiki RECOMMENDED FOR NAMES OF UPLOADED FILES.static StringclearName(String name, boolean stripDots, boolean ascii)protected voidendBlock()This method is called at the end of each block element.voidendDefinitionDescription()This method is used to notify about the end of a definition description.voidendDefinitionTerm()The end of a definition term.voidendFormat(WikiFormat format)This method is called to notify about the end of a sequence of in-line elements having common formatting parameters.voidendHeader(int headerLevel, WikiParameters params)This method is called to notify about the end of a section-level header.voidendList(WikiParameters params, boolean ordered)This method is used to notify about the end of a list.voidendListItem()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).voidendListItem(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).voidendParagraph(WikiParameters params)End of a simple paragraph.voidendTable(WikiParameters params)This method notifies about the end of a table in the document.voidendTableCell(boolean tableHead, WikiParameters params)This method is used to notify about the end of a table cell.voidendTableRow(WikiParameters params)This method is used to notify about the end of a table row.protected StringgetEol()protected StringgetImageThumbwidth()LoggergetLogger()protected ReferenceHandlernewReferenceHandler()voidonImage(String ref)This method is called to notify that an free standing image was found in the parsed wiki document.voidonImage(WikiReference ref)This method is called to notify that a structured reference was found in the textprotected voidonImageThumbnail(WikiReference ref)Special case when detected, that there are image thumbnail.voidonLineBreak()This method is called to notify about a forced line break found in the text.voidonNewLine()This method is called to notify that the parsed block contains a new line sequence ("\r\n"or"\r"or"\n"character sequence).voidonSpecialSymbol(String str)This method is called to notify about a sequence of special characters.voidonTableCaption(String str)Notifies the table caption.voidonVerbatimBlock(String str, WikiParameters params)This method notifies about a verbatim (pre-formatted) block defined in the textvoidonVerbatimInline(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 voidprint(String str)protected voidprintln()protected voidprintln(String str)voidsetLogger(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:IWemListenerDocumentThis method is called to notify about a new section header found in the document.- Specified by:
beginHeaderin interfaceIWemListenerDocument- Overrides:
beginHeaderin 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:IWemListenerDocumentThis method is called to notify about the end of a section-level header.- Specified by:
endHeaderin interfaceIWemListenerDocument- Overrides:
endHeaderin 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:IWemListenerListThis 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:
beginListin interfaceIWemListenerList- Overrides:
beginListin classPrintTextListener- Parameters:
params- parameters of the listordered- if this flag istruethen 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:IWemListenerListThis method is used to notify about the end of a list.- Specified by:
endListin interfaceIWemListenerList- Overrides:
endListin classPrintTextListener- Parameters:
params- parameters of the listordered- if this flag istruethen 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:IWemListenerListThis 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:
beginListItemin interfaceIWemListenerList- Overrides:
beginListItemin classPrintTextListener- See Also:
IWemListenerList.beginListItem()
-
beginListItem
public void beginListItem(WikiParameters params)
Description copied from interface:IWemListenerListThis 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:
beginListItemin interfaceIWemListenerList- Overrides:
beginListItemin classPrintTextListener- See Also:
IWemListenerList.endListItem(WikiParameters)
-
endListItem
public void endListItem()
Description copied from interface:IWemListenerListThis 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:
endListItemin interfaceIWemListenerList- Overrides:
endListItemin classPrintTextListener- See Also:
IWemListenerList.endListItem()
-
endListItem
public void endListItem(WikiParameters params)
Description copied from interface:IWemListenerListThis 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:
endListItemin interfaceIWemListenerList- Overrides:
endListItemin classPrintTextListener- See Also:
IWemListenerList.beginListItem(WikiParameters)
-
onImage
public void onImage(String ref)
Description copied from interface:IWemListenerInlineThis method is called to notify that an free standing image was found in the parsed wiki document.- Specified by:
onImagein interfaceIWemListenerInline- Overrides:
onImagein classPrintTextListener- Parameters:
ref- the reference the reference
-
onImage
public void onImage(WikiReference ref)
Description copied from interface:IWemListenerInlineThis method is called to notify that a structured reference was found in the text- Specified by:
onImagein interfaceIWemListenerInline- Overrides:
onImagein 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:IWemListenerSimpleBlocksThis method notifies about a verbatim (pre-formatted) block defined in the text- Specified by:
onVerbatimBlockin interfaceIWemListenerSimpleBlocks- Overrides:
onVerbatimBlockin 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:IWemListenerInlineThis 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:
onVerbatimInlinein interfaceIWemListenerInline- Overrides:
onVerbatimInlinein 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:IWemListenerTableNotifies the table caption.- Specified by:
onTableCaptionin interfaceIWemListenerTable- Overrides:
onTableCaptionin 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:IWemListenerTableThis method notifies about the beginning of a new table in the document.- Specified by:
beginTablein interfaceIWemListenerTable- Overrides:
beginTablein classPrintTextListener- Parameters:
params- table parameters- See Also:
IWemListenerTable.beginTable(WikiParameters)
-
endTable
public void endTable(WikiParameters params)
Description copied from interface:IWemListenerTableThis method notifies about the end of a table in the document.- Specified by:
endTablein interfaceIWemListenerTable- Overrides:
endTablein classPrintTextListener- Parameters:
params- table parameters- See Also:
IWemListenerTable.endTable(WikiParameters)
-
beginTableCell
public void beginTableCell(boolean tableHead, WikiParameters params)Description copied from interface:IWemListenerTableThis method is used to notify about the beginning of a new table cell.- Specified by:
beginTableCellin interfaceIWemListenerTable- Overrides:
beginTableCellin classPrintTextListener- Parameters:
tableHead- if this flag istruethen 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:IWemListenerTableThis method is used to notify about the end of a table cell.- Specified by:
endTableCellin interfaceIWemListenerTable- Overrides:
endTableCellin classPrintTextListener- Parameters:
tableHead- if this flag istruethen 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:IWemListenerTableThis method is used to notify about the beginning of a new table row.- Specified by:
beginTableRowin interfaceIWemListenerTable- Overrides:
beginTableRowin classPrintTextListener- Parameters:
params- parameters of the row.- See Also:
IWemListenerTable.beginTableRow(WikiParameters)
-
endTableRow
public void endTableRow(WikiParameters params)
Description copied from interface:IWemListenerTableThis method is used to notify about the end of a table row.- Specified by:
endTableRowin interfaceIWemListenerTable- Overrides:
endTableRowin classPrintTextListener- Parameters:
params- parameters of the row.- See Also:
IWemListenerTable.endTableRow(WikiParameters)
-
beginFormat
public void beginFormat(WikiFormat format)
Description copied from interface:IWemListenerInlineThis method is called at the beginning of a sequence of in-line elements having the specified formatting parameters.- Specified by:
beginFormatin interfaceIWemListenerInline- Overrides:
beginFormatin 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:IWemListenerInlineThis method is called to notify about the end of a sequence of in-line elements having common formatting parameters.- Specified by:
endFormatin interfaceIWemListenerInline- Overrides:
endFormatin 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:IWemListenerSimpleBlocksEnd of a simple paragraph.- Specified by:
endParagraphin interfaceIWemListenerSimpleBlocks- Overrides:
endParagraphin classPrintTextListener- Parameters:
params- paragraph parameters- See Also:
IWemListenerSimpleBlocks.endParagraph(WikiParameters)
-
endBlock
protected void endBlock()
Description copied from class:PrintTextListenerThis method is called at the end of each block element. It can be overloaded in subclasses.- Overrides:
endBlockin classPrintTextListener
-
getEol
protected String getEol()
-
onLineBreak
public void onLineBreak()
Description copied from interface:IWemListenerInlineThis 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:
onLineBreakin interfaceIWemListenerInline- Overrides:
onLineBreakin classPrintTextListener- See Also:
IWemListenerInline.onLineBreak()
-
onNewLine
public void onNewLine()
Description copied from interface:IWemListenerInlineThis 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:
onNewLinein interfaceIWemListenerInline- Overrides:
onNewLinein classPrintTextListener- See Also:
IWemListenerInline.onNewLine()
-
onSpecialSymbol
public void onSpecialSymbol(String str)
Description copied from interface:IWemListenerInlineThis 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:
onSpecialSymbolin interfaceIWemListenerInline- Overrides:
onSpecialSymbolin classPrintTextListener- Parameters:
str- the sequence of special symbols- See Also:
IWemListenerInline.onSpecialSymbol(java.lang.String)
-
beginDefinitionTerm
public void beginDefinitionTerm()
Description copied from interface:IWemListenerListA 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:
beginDefinitionTermin interfaceIWemListenerList- Overrides:
beginDefinitionTermin classPrintTextListener- See Also:
IWemListenerList.beginDefinitionTerm()
-
endDefinitionTerm
public void endDefinitionTerm()
Description copied from interface:IWemListenerListThe end of a definition term.- Specified by:
endDefinitionTermin interfaceIWemListenerList- Overrides:
endDefinitionTermin classPrintTextListener- See Also:
IWemListenerList.endDefinitionTerm()
-
beginDefinitionDescription
public void beginDefinitionDescription()
Description copied from interface:IWemListenerListThis 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:
beginDefinitionDescriptionin interfaceIWemListenerList- Overrides:
beginDefinitionDescriptionin classPrintTextListener- See Also:
IWemListenerList.beginDefinitionDescription()
-
endDefinitionDescription
public void endDefinitionDescription()
Description copied from interface:IWemListenerListThis method is used to notify about the end of a definition description.- Specified by:
endDefinitionDescriptionin interfaceIWemListenerList- Overrides:
endDefinitionDescriptionin classPrintTextListener- See Also:
IWemListenerList.endDefinitionDescription()
-
getImageThumbwidth
protected String getImageThumbwidth()
- Returns:
- The wisth information for a thumbnail image
-
print
protected void print(String str)
- Overrides:
printin classPrintTextListener
-
println
protected void println()
- Overrides:
printlnin classPrintTextListener
-
println
protected void println(String str)
- Overrides:
printlnin classPrintTextListener
-
newReferenceHandler
protected ReferenceHandler newReferenceHandler()
- Overrides:
newReferenceHandlerin 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)
-
-