adams.core.io
Class AbstractPdfProclet

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.core.io.AbstractPdfProclet
All Implemented Interfaces:
Debuggable, Destroyable, OptionHandler, SizeOfHandler, Serializable
Direct Known Subclasses:
CsvPdfProclet, HeadlinePdfProclet, ImagePdfProclet, PlainTextPdfProclet

public abstract class AbstractPdfProclet
extends AbstractOptionHandler

Abstract ancestor for processors that add the content of files to a PDF document. Derived classes only require to implement the doProcess(Document,File) method.

Version:
$Revision: 4584 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Nested Class Summary
static class AbstractPdfProclet.DocumentState
          Container class for storing state information about the document currently being processed.
 
Field Summary
protected  boolean m_AddFilename
          add the filename as header.
protected  Color m_ColorFilename
          the color for the filename header.
protected  PdfFont m_FontFilename
          the font for the filename header.
protected  int m_NumFilesPerPage
          the number of files per page.
protected  boolean m_PageBreakAfter
          whether to add a page-break after adding the file.
protected  boolean m_PageBreakBefore
          whether to add a page-break before adding the file.
static String MATCH_ALL_EXTENSION
          the "match-all" file extension.
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
AbstractPdfProclet()
           
 
Method Summary
protected  boolean addFilename(com.itextpdf.text.Document doc, AbstractPdfProclet.DocumentState state, File file)
          Adds the filename to the page as header, if necessary.
 String addFilenameTipText()
          Returns the tip text for this property.
 boolean canProcess(AbstractPdfProclet.DocumentState state, File file)
          Whether the processor can handle this particular file.
 String colorFilenameTipText()
          Returns the tip text for this property.
 void defineOptions()
          Adds options to the internal list of options.
protected abstract  boolean doProcess(com.itextpdf.text.Document doc, AbstractPdfProclet.DocumentState state, File file)
          The actual processing of the document.
 String fontFilenameTipText()
          Returns the tip text for this property.
 boolean getAddFilename()
          Returns whether to output the filename as well.
 Color getColorFilename()
          Returns the color to use for adding the filename header.
abstract  BaseString[] getExtensions()
          Returns the extensions that the processor can process.
 PdfFont getFontFilename()
          Returns the font to use for adding the filename header.
 int getNumFilesPerPage()
          Returns the number of files to put on a single page.
 boolean getPageBreakAfter()
          Returns whether a page break is added after the file is inserted.
 boolean getPageBreakBefore()
          Returns whether a page break is added before the file is inserted.
 String numFilesPerPageTipText()
          Returns the tip text for this property.
 String pageBreakAfterTipText()
          Returns the tip text for this property.
 String pageBreakBeforeTipText()
          Returns the tip text for this property.
protected  boolean postProcess(com.itextpdf.text.Document doc, AbstractPdfProclet.DocumentState state, File file)
          For post-processing the document.
protected  boolean preProcess(com.itextpdf.text.Document doc, AbstractPdfProclet.DocumentState state, File file)
          For pre-processing the document.
 boolean process(com.itextpdf.text.Document doc, AbstractPdfProclet.DocumentState state, File file)
          Processes the given file.
 void setAddFilename(boolean value)
          Sets whether to output the filename as well.
 void setColorFilename(Color value)
          Sets the color to use for adding the filename header.
 void setFontFilename(PdfFont value)
          Sets the font to use for adding the filename header.
 void setNumFilesPerPage(int value)
          Sets the number of files per page.
 void setPageBreakAfter(boolean value)
          Whether to add a page break after the file is inserted.
 void setPageBreakBefore(boolean value)
          Whether to add a page break before the file is inserted.
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debug, debugLevelTipText, destroy, finishInit, getDebugLevel, getOptionManager, globalInfo, initialize, isDebugOn, newOptionManager, reset, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MATCH_ALL_EXTENSION

public static final String MATCH_ALL_EXTENSION
the "match-all" file extension.

See Also:
Constant Field Values

m_PageBreakBefore

protected boolean m_PageBreakBefore
whether to add a page-break before adding the file.


m_PageBreakAfter

protected boolean m_PageBreakAfter
whether to add a page-break after adding the file.


m_NumFilesPerPage

protected int m_NumFilesPerPage
the number of files per page.


m_AddFilename

protected boolean m_AddFilename
add the filename as header.


m_FontFilename

protected PdfFont m_FontFilename
the font for the filename header.


m_ColorFilename

protected Color m_ColorFilename
the color for the filename header.

Constructor Detail

AbstractPdfProclet

public AbstractPdfProclet()
Method Detail

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class AbstractOptionHandler

getExtensions

public abstract BaseString[] getExtensions()
Returns the extensions that the processor can process.

Returns:
the extensions (no dot)

setPageBreakBefore

public void setPageBreakBefore(boolean value)
Whether to add a page break before the file is inserted.

Parameters:
value - if true then a page-break is added before the file is inserted

getPageBreakBefore

public boolean getPageBreakBefore()
Returns whether a page break is added before the file is inserted.

Returns:
true if a page break is added before the file is inserted

pageBreakBeforeTipText

public String pageBreakBeforeTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setPageBreakAfter

public void setPageBreakAfter(boolean value)
Whether to add a page break after the file is inserted.

Parameters:
value - if true then a page-break is added after the file is inserted

getPageBreakAfter

public boolean getPageBreakAfter()
Returns whether a page break is added after the file is inserted.

Returns:
true if a page break is added after the file is inserted

pageBreakAfterTipText

public String pageBreakAfterTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setNumFilesPerPage

public void setNumFilesPerPage(int value)
Sets the number of files per page.

Parameters:
value - the number of files

getNumFilesPerPage

public int getNumFilesPerPage()
Returns the number of files to put on a single page.

Returns:
the number of files

numFilesPerPageTipText

public String numFilesPerPageTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setAddFilename

public void setAddFilename(boolean value)
Sets whether to output the filename as well.

Parameters:
value - if true then the filename gets added as well

getAddFilename

public boolean getAddFilename()
Returns whether to output the filename as well.

Returns:
true if the filename gets added as well

addFilenameTipText

public String addFilenameTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setFontFilename

public void setFontFilename(PdfFont value)
Sets the font to use for adding the filename header.

Parameters:
value - the font

getFontFilename

public PdfFont getFontFilename()
Returns the font to use for adding the filename header.

Returns:
the font

fontFilenameTipText

public String fontFilenameTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setColorFilename

public void setColorFilename(Color value)
Sets the color to use for adding the filename header.

Parameters:
value - the color

getColorFilename

public Color getColorFilename()
Returns the color to use for adding the filename header.

Returns:
the color

colorFilenameTipText

public String colorFilenameTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

addFilename

protected boolean addFilename(com.itextpdf.text.Document doc,
                              AbstractPdfProclet.DocumentState state,
                              File file)
                       throws Exception
Adds the filename to the page as header, if necessary.

Parameters:
doc - the document to process
state - the current document state
file - the plain text file
Returns:
true if sucessfully added
Throws:
Exception - if something goes wrong

preProcess

protected boolean preProcess(com.itextpdf.text.Document doc,
                             AbstractPdfProclet.DocumentState state,
                             File file)
                      throws Exception
For pre-processing the document.

Parameters:
doc - the PDF document to add the file content to
state - the current document state
file - the file to add
Returns:
true if successfully added
Throws:
Exception - if something goes wrong

doProcess

protected abstract boolean doProcess(com.itextpdf.text.Document doc,
                                     AbstractPdfProclet.DocumentState state,
                                     File file)
                              throws Exception
The actual processing of the document.

Parameters:
doc - the PDF document to add the file content to
state - the current document state
file - the file to add
Returns:
true if successfully added
Throws:
Exception - if something goes wrong

postProcess

protected boolean postProcess(com.itextpdf.text.Document doc,
                              AbstractPdfProclet.DocumentState state,
                              File file)
                       throws Exception
For post-processing the document.

Parameters:
doc - the PDF document to add the file content to
state - the current document state
file - the file to add
Returns:
true if successfully added
Throws:
Exception - if something goes wrong

canProcess

public boolean canProcess(AbstractPdfProclet.DocumentState state,
                          File file)
Whether the processor can handle this particular file.

Parameters:
state - the document state
file - the file to check
Returns:
true if the file can be handled

process

public boolean process(com.itextpdf.text.Document doc,
                       AbstractPdfProclet.DocumentState state,
                       File file)
Processes the given file.

Parameters:
doc - the PDF document to add the file content to
state - the current document state
file - the file to add
Returns:
true if successfully added


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.