org.xwiki.annotation.internal.renderer
Class PlainTextNormalizingChainingRenderer

java.lang.Object
  extended by org.xwiki.rendering.listener.chaining.AbstractChainingListener
      extended by org.xwiki.rendering.renderer.AbstractChainingPrintRenderer
          extended by org.xwiki.annotation.internal.renderer.PlainTextNormalizingChainingRenderer
All Implemented Interfaces:
ChainingListener, ImageListener, LinkListener, Listener, PrintRenderer, Renderer

public class PlainTextNormalizingChainingRenderer
extends AbstractChainingPrintRenderer

Plain text renderer that normalizes spaces in the printed text.

Since:
2.3M1

Field Summary
 
Fields inherited from interface org.xwiki.rendering.listener.Listener
EMPTY_PARAMETERS
 
Constructor Summary
PlainTextNormalizingChainingRenderer(ContentAlterer textCleaner, ListenerChain listenerChain)
          Builds an abstract plain text normalizing renderer with the passed text cleaner.
 
Method Summary
 void beginDefinitionDescription()
          Start of a definition list description.
 void beginDefinitionList(Map<String,String> parameters)
          Start of a definition list.
 void beginDefinitionTerm()
          Start of a definition list term.
 void beginGroup(Map<String,String> parameters)
          Start a group of elements.
 void beginHeader(HeaderLevel level, String id, Map<String,String> parameters)
          Start of a header.
 void beginList(ListType listType, Map<String,String> parameters)
          Start of a list.
 void beginListItem()
          Start of a list item.
 void beginParagraph(Map<String,String> parameters)
          Start of a paragraph.
 void beginQuotation(Map<String,String> parameters)
          Start of a quotation.
 void beginQuotationLine()
          Start of a quotation line.
 void beginTable(Map<String,String> parameters)
          Start of a table.
 void beginTableCell(Map<String,String> parameters)
          Start of a table cell.
 void beginTableHeadCell(Map<String,String> parameters)
          Start of a table head cell.
 void beginTableRow(Map<String,String> parameters)
          Start of a table row.
 void endDefinitionDescription()
          End of a definition list description.
 void endDefinitionList(Map<String,String> parameters)
          End of a definition list.
 void endDefinitionTerm()
          End of a definition list term.
 void endGroup(Map<String,String> parameters)
          End of the group.
 void endHeader(HeaderLevel level, String id, Map<String,String> parameters)
          End of a header.
 void endList(ListType listType, Map<String,String> parameters)
          End of a list.
 void endListItem()
          End of a list item.
 void endParagraph(Map<String,String> parameters)
          End of a paragraph.
 void endQuotation(Map<String,String> parameters)
          End of a quotation.
 void endQuotationLine()
          End of a quotation line.
 void endTable(Map<String,String> parameters)
          End of a table.
 void endTableCell(Map<String,String> parameters)
          End of a table cell.
 void endTableHeadCell(Map<String,String> parameters)
          End of a table head cell.
 void endTableRow(Map<String,String> parameters)
          End of a table row.
 void onEmptyLines(int count)
          Represents an empty line between 2 standalone Blocks.
 void onHorizontalLine(Map<String,String> parameters)
          Represents an horizontal line.
 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).
 void onRawText(String text, Syntax syntax)
          Some text to inject directly into the listener output without parsing it.
 void onSpace()
          A space.
 void onSpecialSymbol(char symbol)
          A special symbol ("*", "<", ">", "=", quote, etc).
 void onVerbatim(String protectedString, boolean isInline, Map<String,String> parameters)
          A portion of text.
 void onWord(String word)
          A word.
protected  void printSpace()
          Print a space to the renderer's printer.
protected  void printText(String text)
          Prints a text to the renderer's printer.
 
Methods inherited from class org.xwiki.rendering.renderer.AbstractChainingPrintRenderer
getMainPrinter, getPrinter, popPrinter, pushPrinter, setPrinter
 
Methods inherited from class org.xwiki.rendering.listener.chaining.AbstractChainingListener
beginDocument, beginFormat, beginLink, beginMacroMarker, beginMetaData, beginSection, endDocument, endFormat, endLink, endMacroMarker, endMetaData, endSection, getListenerChain, onId, onImage, onMacro, setListenerChain
 
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.listener.Listener
beginDocument, beginFormat, beginMacroMarker, beginMetaData, beginSection, endDocument, endFormat, endMacroMarker, endMetaData, endSection, onId, onMacro
 
Methods inherited from interface org.xwiki.rendering.listener.LinkListener
beginLink, endLink
 
Methods inherited from interface org.xwiki.rendering.listener.ImageListener
onImage
 

Constructor Detail

PlainTextNormalizingChainingRenderer

public PlainTextNormalizingChainingRenderer(ContentAlterer textCleaner,
                                            ListenerChain listenerChain)
Builds an abstract plain text normalizing renderer with the passed text cleaner.

Parameters:
textCleaner - the text cleaner used to normalize the texts produced by the events
listenerChain - the listeners chain this listener is part of
Method Detail

onWord

public void onWord(String word)
Description copied from interface: Listener
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.

Specified by:
onWord in interface Listener
Overrides:
onWord in class AbstractChainingListener
Parameters:
word - the word encountered

onSpecialSymbol

public void onSpecialSymbol(char symbol)
Description copied from interface: Listener
A special symbol ("*", "<", ">", "=", quote, etc). Any non alpha numeric character is a special symbol.

Specified by:
onSpecialSymbol in interface Listener
Overrides:
onSpecialSymbol in class AbstractChainingListener
Parameters:
symbol - the symbol encountered

onVerbatim

public void onVerbatim(String protectedString,
                       boolean isInline,
                       Map<String,String> parameters)
Description copied from interface: Listener
A portion of text.

Specified by:
onVerbatim in interface Listener
Overrides:
onVerbatim in class AbstractChainingListener
Parameters:
protectedString - the string to protected from rendering
isInline - 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

public void onRawText(String text,
                      Syntax syntax)
Description copied from interface: Listener
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.

Specified by:
onRawText in interface Listener
Overrides:
onRawText in class AbstractChainingListener
Parameters:
text - the text to inject
syntax - 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

onSpace

public void onSpace()
Description copied from interface: Listener
A space.

Specified by:
onSpace in interface Listener
Overrides:
onSpace in class AbstractChainingListener

printSpace

protected void printSpace()
Print a space to the renderer's printer.


printText

protected void printText(String text)
Prints a text to the renderer's printer.

Parameters:
text - the text to print

onEmptyLines

public void onEmptyLines(int count)
Description copied from interface: Listener
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.

Specified by:
onEmptyLines in interface Listener
Overrides:
onEmptyLines in class AbstractChainingListener
Parameters:
count - the number of empty lines between 2 standalone Blocks

onNewLine

public void onNewLine()
Description copied from interface: Listener
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).

Specified by:
onNewLine in interface Listener
Overrides:
onNewLine in class AbstractChainingListener

onHorizontalLine

public void onHorizontalLine(Map<String,String> parameters)
Description copied from interface: Listener
Represents an horizontal line.

Specified by:
onHorizontalLine in interface Listener
Overrides:
onHorizontalLine in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters. Example: style="background-color: blue"

beginDefinitionDescription

public void beginDefinitionDescription()
Description copied from interface: Listener
Start of a definition list description. For example in HTML this is the equivalent of <dd>.

Specified by:
beginDefinitionDescription in interface Listener
Overrides:
beginDefinitionDescription in class AbstractChainingListener

endDefinitionDescription

public void endDefinitionDescription()
Description copied from interface: Listener
End of a definition list description. For example in HTML this is the equivalent of </dd>.

Specified by:
endDefinitionDescription in interface Listener
Overrides:
endDefinitionDescription in class AbstractChainingListener

beginDefinitionList

public void beginDefinitionList(Map<String,String> parameters)
Description copied from interface: Listener
Start of a definition list. For example in HTML this is the equivalent of <dl>.

Specified by:
beginDefinitionList in interface Listener
Overrides:
beginDefinitionList in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the list. Example: "style"/"background-color: blue"

endDefinitionList

public void endDefinitionList(Map<String,String> parameters)
Description copied from interface: Listener
End of a definition list. For example in HTML this is the equivalent of </dl>.

Specified by:
endDefinitionList in interface Listener
Overrides:
endDefinitionList in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the list. Example: "style"/"background-color: blue"

beginDefinitionTerm

public void beginDefinitionTerm()
Description copied from interface: Listener
Start of a definition list term. For example in HTML this is the equivalent of <dt>.

Specified by:
beginDefinitionTerm in interface Listener
Overrides:
beginDefinitionTerm in class AbstractChainingListener

endDefinitionTerm

public void endDefinitionTerm()
Description copied from interface: Listener
End of a definition list term. For example in HTML this is the equivalent of </dt>.

Specified by:
endDefinitionTerm in interface Listener
Overrides:
endDefinitionTerm in class AbstractChainingListener

beginGroup

public void beginGroup(Map<String,String> parameters)
Description copied from interface: Listener
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.

Specified by:
beginGroup in interface Listener
Overrides:
beginGroup in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters. Example: style="background-color: blue"

endGroup

public void endGroup(Map<String,String> parameters)
Description copied from interface: Listener
End of the group.

Specified by:
endGroup in interface Listener
Overrides:
endGroup in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters. Example: style="background-color: blue"

beginHeader

public void beginHeader(HeaderLevel level,
                        String id,
                        Map<String,String> parameters)
Description copied from interface: Listener
Start of a header.

Specified by:
beginHeader in interface Listener
Overrides:
beginHeader in class AbstractChainingListener
Parameters:
level - the header level (1, 2, 3, etc)
id - the header unique identifier
parameters - a generic list of parameters. Example: style="background-color: blue"
See Also:
HeaderLevel

endHeader

public void endHeader(HeaderLevel level,
                      String id,
                      Map<String,String> parameters)
Description copied from interface: Listener
End of a header.

Specified by:
endHeader in interface Listener
Overrides:
endHeader in class AbstractChainingListener
Parameters:
level - the header level (1, 2, 3, etc)
id - the header unique identifier
parameters - a generic list of parameters. Example: style="background-color: blue"
See Also:
HeaderLevel

beginList

public void beginList(ListType listType,
                      Map<String,String> parameters)
Description copied from interface: Listener
Start of a list.

Specified by:
beginList in interface Listener
Overrides:
beginList in class AbstractChainingListener
Parameters:
listType - the type of list (bulleted, numbered, etc)
parameters - a generic list of parameters for the list. Example: "style"/"background-color: blue"
See Also:
ListType

endList

public void endList(ListType listType,
                    Map<String,String> parameters)
Description copied from interface: Listener
End of a list.

Specified by:
endList in interface Listener
Overrides:
endList in class AbstractChainingListener
Parameters:
listType - the type of list (bulleted, numbered, etc)
parameters - a generic list of parameters for the list. Example: "style"/"background-color: blue"
See Also:
ListType

beginListItem

public void beginListItem()
Description copied from interface: Listener
Start of a list item.

Specified by:
beginListItem in interface Listener
Overrides:
beginListItem in class AbstractChainingListener

endListItem

public void endListItem()
Description copied from interface: Listener
End of a list item.

Specified by:
endListItem in interface Listener
Overrides:
endListItem in class AbstractChainingListener

beginParagraph

public void beginParagraph(Map<String,String> parameters)
Description copied from interface: Listener
Start of a paragraph.

Specified by:
beginParagraph in interface Listener
Overrides:
beginParagraph in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters. Example: style="background-color: blue"

endParagraph

public void endParagraph(Map<String,String> parameters)
Description copied from interface: Listener
End of a paragraph.

Specified by:
endParagraph in interface Listener
Overrides:
endParagraph in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters. Example: style="background-color: blue"

beginQuotation

public void beginQuotation(Map<String,String> parameters)
Description copied from interface: Listener
Start of a quotation. There are one or several quotation lines inside a quotation block.

Specified by:
beginQuotation in interface Listener
Overrides:
beginQuotation in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the quotation. Example: "style"/"background-color: blue"

endQuotation

public void endQuotation(Map<String,String> parameters)
Description copied from interface: Listener
End of a quotation.

Specified by:
endQuotation in interface Listener
Overrides:
endQuotation in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the quotation. Example: "style"/"background-color: blue"

beginQuotationLine

public void beginQuotationLine()
Description copied from interface: Listener
Start of a quotation line. There can be several quotation lines in a quotation block.

Specified by:
beginQuotationLine in interface Listener
Overrides:
beginQuotationLine in class AbstractChainingListener

endQuotationLine

public void endQuotationLine()
Description copied from interface: Listener
End of a quotation line.

Specified by:
endQuotationLine in interface Listener
Overrides:
endQuotationLine in class AbstractChainingListener

beginTable

public void beginTable(Map<String,String> parameters)
Description copied from interface: Listener
Start of a table.

Specified by:
beginTable in interface Listener
Overrides:
beginTable in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the table.

endTable

public void endTable(Map<String,String> parameters)
Description copied from interface: Listener
End of a table.

Specified by:
endTable in interface Listener
Overrides:
endTable in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the table.

beginTableRow

public void beginTableRow(Map<String,String> parameters)
Description copied from interface: Listener
Start of a table row.

Specified by:
beginTableRow in interface Listener
Overrides:
beginTableRow in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the table row.

endTableRow

public void endTableRow(Map<String,String> parameters)
Description copied from interface: Listener
End of a table row.

Specified by:
endTableRow in interface Listener
Overrides:
endTableRow in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the table row.

beginTableHeadCell

public void beginTableHeadCell(Map<String,String> parameters)
Description copied from interface: Listener
Start of a table head cell.

Specified by:
beginTableHeadCell in interface Listener
Overrides:
beginTableHeadCell in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the table head cell.

endTableHeadCell

public void endTableHeadCell(Map<String,String> parameters)
Description copied from interface: Listener
End of a table head cell.

Specified by:
endTableHeadCell in interface Listener
Overrides:
endTableHeadCell in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the table head cell.

beginTableCell

public void beginTableCell(Map<String,String> parameters)
Description copied from interface: Listener
Start of a table cell.

Specified by:
beginTableCell in interface Listener
Overrides:
beginTableCell in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the table cell.

endTableCell

public void endTableCell(Map<String,String> parameters)
Description copied from interface: Listener
End of a table cell.

Specified by:
endTableCell in interface Listener
Overrides:
endTableCell in class AbstractChainingListener
Parameters:
parameters - a generic list of parameters for the table cell.