org.xwiki.rendering.wikimodel.tex
Class TexSerializer

java.lang.Object
  extended by org.xwiki.rendering.wikimodel.PrintTextListener
      extended by org.xwiki.rendering.wikimodel.tex.TexSerializer
All Implemented Interfaces:
IWemListener, IWemListenerDocument, IWemListenerInline, IWemListenerList, IWemListenerProgramming, IWemListenerSemantic, IWemListenerSimpleBlocks, IWemListenerTable

public class TexSerializer
extends PrintTextListener

Since:
4.0M1
Version:
$Id$

Field Summary
 
Fields inherited from class org.xwiki.rendering.wikimodel.PrintTextListener
fRefHandler
 
Constructor Summary
TexSerializer(IWikiPrinter printer, String documentName, String wikiFileDownloadBaseUrl, String imageTargetFolderPath)
           
 
Method Summary
 void beginDocument(WikiParameters params)
          This method is called to notify about the beginning of the top-level parsed document or about the beginning of an embedded document (contained in the main one).
 void beginHeader(int headerLevel, WikiParameters params)
          This method is called to notify about a new section header found in the document.
 void beginList(WikiParameters parameters, 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 (see IWemListenerList.beginList(WikiParameters, boolean)/ IWemListenerList.endList(WikiParameters, boolean) methods).
 void beginParagraph(WikiParameters params)
          Begin of a simple paragraph.
 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.
 void endDocument(WikiParameters params)
          This method is used to notify about the end of a top-level or an internal document.
 void endHeader(int headerLevel, WikiParameters params)
          This method is called to notify about the end of a section-level header.
 void endList(WikiParameters parameters, 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 (see IWemListenerList.beginList(WikiParameters, boolean)/ IWemListenerList.endList(WikiParameters, boolean) methods).
 void endParagraph(WikiParameters params)
          End of a simple paragraph.
 void endQuotationLine()
          This method is used to notify about the end of a quotation line.
 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  InputStream getImageInput(String ref)
          Returns an input stream with an image corresponding to the specified reference.
protected  int[] getImageSize(String ref)
          Returns a two-value array with the size of the image defined by the given url
protected  int getMaxImageHeight()
          Returns maximal possible image height.
protected  int getMaxImageWidth()
          Returns maximal possible image width.
protected  ReferenceHandler newReferenceHandler()
           
 void onEscape(String str)
          Escaped symbols.
 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 onSpace(String str)
          This method is called to notify about a sequence of space symbols (like " " or "\t" symbols).
 void onSpecialSymbol(String str)
          This method is called to notify about a sequence of special characters.
 void onWord(String str)
          This method is called to notify about a "word" found in the document.
static String processString(String g, boolean flag)
           
 String texClean(String str)
           
 
Methods inherited from class org.xwiki.rendering.wikimodel.PrintTextListener
beginDefinitionDescription, beginDefinitionList, beginDefinitionTerm, beginFormat, beginInfoBlock, beginPropertyBlock, beginPropertyInline, beginQuotation, beginQuotationLine, beginSection, beginSectionContent, endBlock, endDefinitionDescription, endDefinitionList, endDefinitionTerm, endFormat, endInfoBlock, endPropertyBlock, endPropertyInline, endQuotation, endSection, endSectionContent, isSupportDownload, isSupportImage, onEmptyLines, onExtensionBlock, onExtensionInline, onHorizontalLine, onImage, onImage, onMacroBlock, onMacroInline, onReference, onReference, onTableCaption, onVerbatimBlock, onVerbatimInline, print, println, println
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TexSerializer

public TexSerializer(IWikiPrinter printer,
                     String documentName,
                     String wikiFileDownloadBaseUrl,
                     String imageTargetFolderPath)
Parameters:
printer -
Method Detail

processString

public static String processString(String g,
                                   boolean flag)

beginDocument

public void beginDocument(WikiParameters params)
Description copied from interface: IWemListenerDocument
This method is called to notify about the beginning of the top-level parsed document or about the beginning of an embedded document (contained in the main one).

Specified by:
beginDocument in interface IWemListenerDocument
Overrides:
beginDocument in class PrintTextListener
See Also:
IWemListenerDocument.beginDocument(WikiParameters)

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 interface IWemListenerDocument
Overrides:
beginHeader in class PrintTextListener
Parameters:
headerLevel - the level of the found header; valid values: 1-6
params - wiki parameters associated with the
See Also:
IWemListenerDocument.beginHeader(int, WikiParameters)

beginList

public void beginList(WikiParameters parameters,
                      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 the IWemListenerList.beginListItem()/IWemListenerList.endListItem() method pair. Items of lists of this type can contain the following sequence of elements:
  1. formatted text - the text can be empty; in this case it is not notified
  2. 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 interface IWemListenerList
Overrides:
beginList in class PrintTextListener
Parameters:
parameters - parameters of the list
ordered - if this flag is true 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)

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 (see IWemListenerList.beginList(WikiParameters, boolean)/ IWemListenerList.endList(WikiParameters, boolean) methods).

Specified by:
beginListItem in interface IWemListenerList
Overrides:
beginListItem in class PrintTextListener
See Also:
IWemListenerList.beginListItem()

beginParagraph

public void beginParagraph(WikiParameters params)
Description copied from interface: IWemListenerSimpleBlocks
Begin of a simple paragraph. Paragraphs can contain only formatted inline elements.

Specified by:
beginParagraph in interface IWemListenerSimpleBlocks
Overrides:
beginParagraph in class PrintTextListener
Parameters:
params - paragraph parameters
See Also:
IWemListenerSimpleBlocks.beginParagraph(WikiParameters)

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 interface IWemListenerTable
Overrides:
beginTable in class PrintTextListener
Parameters:
params - table parameters
See Also:
IWemListenerTable.beginTable(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 interface IWemListenerTable
Overrides:
beginTableCell in class PrintTextListener
Parameters:
tableHead - if this flag is true 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)

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 interface IWemListenerTable
Overrides:
beginTableRow in class PrintTextListener
Parameters:
params - parameters of the row.
See Also:
IWemListenerTable.beginTableRow(WikiParameters)

endDocument

public void endDocument(WikiParameters params)
Description copied from interface: IWemListenerDocument
This method is used to notify about the end of a top-level or an internal document.

Specified by:
endDocument in interface IWemListenerDocument
Overrides:
endDocument in class PrintTextListener
See Also:
IWemListenerDocument.endDocument(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 interface IWemListenerDocument
Overrides:
endHeader in class PrintTextListener
Parameters:
headerLevel - the level of the header
params - wiki parameters of the header
See Also:
IWemListenerDocument.endHeader(int, WikiParameters)

endList

public void endList(WikiParameters parameters,
                    boolean ordered)
Description copied from interface: IWemListenerList
This method is used to notify about the end of a list.

Specified by:
endList in interface IWemListenerList
Overrides:
endList in class PrintTextListener
Parameters:
parameters - parameters of the list
ordered - if this flag is true 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)

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 (see IWemListenerList.beginList(WikiParameters, boolean)/ IWemListenerList.endList(WikiParameters, boolean) methods).

Specified by:
endListItem in interface IWemListenerList
Overrides:
endListItem in class PrintTextListener
See Also:
IWemListenerList.endListItem()

endParagraph

public void endParagraph(WikiParameters params)
Description copied from interface: IWemListenerSimpleBlocks
End of a simple paragraph.

Specified by:
endParagraph in interface IWemListenerSimpleBlocks
Overrides:
endParagraph in class PrintTextListener
Parameters:
params - paragraph parameters
See Also:
IWemListenerSimpleBlocks.endParagraph(WikiParameters)

endQuotationLine

public void endQuotationLine()
Description copied from interface: IWemListenerList
This method is used to notify about the end of a quotation line.

Specified by:
endQuotationLine in interface IWemListenerList
Overrides:
endQuotationLine in class PrintTextListener
See Also:
IWemListenerList.endQuotationLine()

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 interface IWemListenerTable
Overrides:
endTable in class PrintTextListener
Parameters:
params - table parameters
See Also:
IWemListenerTable.endTable(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 interface IWemListenerTable
Overrides:
endTableCell in class PrintTextListener
Parameters:
tableHead - if this flag is true 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)

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 interface IWemListenerTable
Overrides:
endTableRow in class PrintTextListener
Parameters:
params - parameters of the row.
See Also:
IWemListenerTable.endTableRow(WikiParameters)

getImageInput

protected InputStream getImageInput(String ref)
                             throws IOException
Returns an input stream with an image corresponding to the specified reference. If there is no image was found then this method should return null. This method is used to define dimensions of images used in the output. Sould be overloaded in sublcasses.

Parameters:
ref - the image reference
Returns:
the input stream with an image
Throws:
IOException

getImageSize

protected int[] getImageSize(String ref)
Returns a two-value array with the size of the image defined by the given url

Parameters:
ref - the reference to the image
Returns:
a size of an image with the specified url;

getMaxImageHeight

protected int getMaxImageHeight()
Returns maximal possible image height. This method can be overloaded in subclasses.

Returns:
the maximal possible image height

getMaxImageWidth

protected int getMaxImageWidth()
Returns maximal possible image width. This method can be overloaded in subclasses.

Returns:
the maximal possible image width

newReferenceHandler

protected ReferenceHandler newReferenceHandler()
Overrides:
newReferenceHandler in class PrintTextListener

onEscape

public void onEscape(String str)
Description copied from interface: IWemListenerInline
Escaped symbols. More frequently the given string has just one symbol.

Specified by:
onEscape in interface IWemListenerInline
Overrides:
onEscape in class PrintTextListener
Parameters:
str - the escaped sequence of characters
See Also:
IWemListenerInline.onEscape(java.lang.String)

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 the IWemListenerInline.onNewLine() notification.

Specified by:
onLineBreak in interface IWemListenerInline
Overrides:
onLineBreak in class PrintTextListener
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 the IWemListenerInline.onLineBreak() event.

Specified by:
onNewLine in interface IWemListenerInline
Overrides:
onNewLine in class PrintTextListener
See Also:
IWemListenerInline.onNewLine()

onSpace

public void onSpace(String str)
Description copied from interface: IWemListenerInline
This method is called to notify about a sequence of space symbols (like " " or "\t" symbols).

Specified by:
onSpace in interface IWemListenerInline
Overrides:
onSpace in class PrintTextListener
Parameters:
str - the sequence of space characters
See Also:
IWemListenerInline.onSpace(java.lang.String)

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 interface IWemListenerInline
Overrides:
onSpecialSymbol in class PrintTextListener
Parameters:
str - the sequence of special symbols
See Also:
IWemListenerInline.onSpecialSymbol(java.lang.String)

onWord

public void onWord(String str)
Description copied from interface: IWemListenerInline
This method is called to notify about a "word" found in the document. Words are formed by all characters which are not considered as spaces or special symbols.
 Words are formed by the all characters excluding the following ones:

  "\t",    "\n",     "\r",    " ",
  "!",     "\"",     "#",     "$",     "%",     "&",     "'",     "(",
  ")",     "*",      "+",     ",",     "-",     ".",     "/",     ":",
  ";",     "<",      "=",     ">",     "?",     "@",     "[",     "\\",
  "]",     "^",      "_",     "`",     "{",     "|",     "}",     "~"
 

Specified by:
onWord in interface IWemListenerInline
Overrides:
onWord in class PrintTextListener
Parameters:
str - the sequence of characters forming a word
See Also:
IWemListenerInline.onWord(java.lang.String)

texClean

public String texClean(String str)


Copyright © 2004-2012 XWiki. All Rights Reserved.