net.sourceforge.rssowl.util.document
Class DocumentGenerator

java.lang.Object
  extended bynet.sourceforge.rssowl.util.document.DocumentGenerator

public class DocumentGenerator
extends Object

Class to generate PDF / RTF / HTML from a Newsfeed

Version:
1.1.3
Author:
Benjamin Pasero

Field Summary
(package private)  Hashtable chapters
          Store Chapters for each newsfeed that is generated to document
private  com.lowagie.text.Document document
          Document to write
private  DocumentConfig documentConfig
          The config for the document containing Fonts
private  int format
          Chosen format (PDF, RTF or HTML)
static int HTML_FORMAT
          Constant to indicate a HTML formatted document
private static int MAX_CHARS_PER_PAGE
          Value to decide wether a Table fits a page or not
static int PDF_FORMAT
          Constant to indicate a PDF formatted document
private  Channel rssChannel
          The Channel to generate the PDF / RTF / HTML from
static int RTF_FORMAT
          Constant to indicate a RTF formatted document
private static String TOKENIZER
          Tokeniter to split Feed Title and News Title
 
Constructor Summary
DocumentGenerator(Channel rssChannel, FileOutputStream fileOS, int format)
          Instantiate a new DocumentGenerator
 
Method Summary
 void createDocument(ArrayList newsItemOrder)
          Write header and a single news to the document
static String formatToString(int format)
          Get a suitable file format name for the given format.
private  void initDocument(FileOutputStream file)
          Init the document to PDF, HTML or RTF and with the given file
private  void writeFooter()
          Write footer into document
private  void writeMetaInfos()
          Write some meta informations to the document
private  void writeNews(ArrayList newsItemsOrder)
          Write all news to the document
private  void writeNews(NewsItem rssNewsItem, String newsTitle)
          Write a newsitem to the document
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTML_FORMAT

public static final int HTML_FORMAT
Constant to indicate a HTML formatted document

See Also:
Constant Field Values

PDF_FORMAT

public static final int PDF_FORMAT
Constant to indicate a PDF formatted document

See Also:
Constant Field Values

RTF_FORMAT

public static final int RTF_FORMAT
Constant to indicate a RTF formatted document

See Also:
Constant Field Values

MAX_CHARS_PER_PAGE

private static final int MAX_CHARS_PER_PAGE
Value to decide wether a Table fits a page or not

See Also:
Constant Field Values

TOKENIZER

private static final String TOKENIZER
Tokeniter to split Feed Title and News Title

See Also:
Constant Field Values

document

private com.lowagie.text.Document document
Document to write


documentConfig

private DocumentConfig documentConfig
The config for the document containing Fonts


format

private int format
Chosen format (PDF, RTF or HTML)


rssChannel

private Channel rssChannel
The Channel to generate the PDF / RTF / HTML from


chapters

Hashtable chapters
Store Chapters for each newsfeed that is generated to document

Constructor Detail

DocumentGenerator

public DocumentGenerator(Channel rssChannel,
                         FileOutputStream fileOS,
                         int format)
                  throws com.lowagie.text.DocumentException
Instantiate a new DocumentGenerator

Parameters:
rssChannel - The selected Channel
fileOS - File to write document into
format - PDF, RTF or HTML
Throws:
com.lowagie.text.DocumentException - If an error occurs
Method Detail

formatToString

public static String formatToString(int format)
Get a suitable file format name for the given format.

Parameters:
format - Any of the allowed formats PDF, RTF or HTML
Returns:
String The format as file name

createDocument

public void createDocument(ArrayList newsItemOrder)
                    throws com.lowagie.text.DocumentException
Write header and a single news to the document

Parameters:
newsItemOrder - The sort order of the selected newsfeed
Throws:
com.lowagie.text.DocumentException - If an warning occurs

initDocument

private void initDocument(FileOutputStream file)
                   throws com.lowagie.text.DocumentException
Init the document to PDF, HTML or RTF and with the given file

Parameters:
file - The path to the file where to save the document after generation
Throws:
com.lowagie.text.DocumentException - If an error occurs

writeFooter

private void writeFooter()
Write footer into document


writeMetaInfos

private void writeMetaInfos()
Write some meta informations to the document


writeNews

private void writeNews(ArrayList newsItemsOrder)
                throws com.lowagie.text.DocumentException
Write all news to the document

Parameters:
newsItemsOrder - The sort order of the newsitems
Throws:
com.lowagie.text.DocumentException - If an error occurs

writeNews

private void writeNews(NewsItem rssNewsItem,
                       String newsTitle)
                throws com.lowagie.text.DocumentException
Write a newsitem to the document

Parameters:
rssNewsItem - NewsItem to write
newsTitle - Title of the newsitem
Throws:
com.lowagie.text.DocumentException - if an error occurs


RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo