org.pdfsam.console.business.pdf.handlers.interfaces
Class AbstractCmdExecutor

java.lang.Object
  extended by java.util.Observable
      extended by org.pdfsam.console.business.pdf.handlers.interfaces.AbstractCmdExecutor
All Implemented Interfaces:
CmdExecutor
Direct Known Subclasses:
AlternateMixCmdExecutor, ConcatCmdExecutor, DecryptCmdExecutor, DocumentInfoCmdExecutor, EncryptCmdExecutor, PageLabelsCmdExecutor, RotateCmdExecutor, SetViewerCmdExecutor, SlideShowCmdExecutor, SplitCmdExecutor, UnpackCmdExecutor

public abstract class AbstractCmdExecutor
extends java.util.Observable
implements CmdExecutor

Abstract command executor

Author:
Andrea Vacondio

Constructor Summary
AbstractCmdExecutor()
           
 
Method Summary
protected  PdfFile[] arraysConcat(PdfFile[] first, PdfFile[] second)
          concat the two arrays
protected  void closePdfReader(com.lowagie.text.pdf.PdfReader pdfReader)
          Close the @lonk PdfReader if not null.
protected  void closePdfStamper(com.lowagie.text.pdf.PdfStamper pdfStamper)
          Close the @link PdfStamper if not null.
protected  void closePdfWriter(com.lowagie.text.pdf.PdfWriter pdfWriter)
          Close the @lonk PdfWriter if not null.
abstract  void execute(AbstractParsedCommand parsedCommand)
          Execute the tool command.
protected  PdfFile[] getPdfFiles(java.io.File directory)
          get an array of PdfFile in the input directory alphabetically ordered
protected  void resetPercentageOfWorkDone()
          reset the percentage of work done
protected  void setCompressionSettingOnStamper(AbstractParsedCommand inputCommand, com.lowagie.text.pdf.PdfStamper pdfStamper)
          Sets the compression settings on the pdf stamper depending on the inputCommand
protected  void setCompressionSettingOnWriter(AbstractParsedCommand inputCommand, com.lowagie.text.pdf.PdfWriter pdfWriter)
          Sets the compression settings on the pdf writer depending on the inputCommand
protected  void setPdfVersionSettingOnWriter(AbstractParsedCommand inputCommand, com.lowagie.text.pdf.PdfWriter pdfWriter)
          Convenience method to set the pdf version settings on the writer without a default version
protected  void setPdfVersionSettingOnWriter(AbstractParsedCommand inputCommand, com.lowagie.text.pdf.PdfWriter pdfWriter, java.lang.Character defaultVersion)
          Sets the pdf version setting on the pdf writer depending on the inputCommand
protected  void setPercentageOfWorkDone(int percentage)
          set the percentage of work done for the current execution and notify the observers
protected  void setWorkCompleted()
          set the work completed for the current execution and notify the observers
protected  void setWorkIndeterminate()
          set the percentage of work done to indeterminate for the current execution and notify the observers
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pdfsam.console.business.pdf.handlers.interfaces.CmdExecutor
clean
 

Constructor Detail

AbstractCmdExecutor

public AbstractCmdExecutor()
Method Detail

setPercentageOfWorkDone

protected final void setPercentageOfWorkDone(int percentage)
set the percentage of work done for the current execution and notify the observers

Parameters:
percentage -

setWorkIndeterminate

protected final void setWorkIndeterminate()
set the percentage of work done to indeterminate for the current execution and notify the observers


setWorkCompleted

protected final void setWorkCompleted()
set the work completed for the current execution and notify the observers


resetPercentageOfWorkDone

protected final void resetPercentageOfWorkDone()
reset the percentage of work done


execute

public abstract void execute(AbstractParsedCommand parsedCommand)
                      throws ConsoleException
Description copied from interface: CmdExecutor
Execute the tool command. On error an exception is thrown.

Specified by:
execute in interface CmdExecutor
Parameters:
parsedCommand - command to be executed
Throws:
ConsoleException

getPdfFiles

protected PdfFile[] getPdfFiles(java.io.File directory)
get an array of PdfFile in the input directory alphabetically ordered

Parameters:
directory -
Returns:
PdfFile array from the input directory

arraysConcat

protected PdfFile[] arraysConcat(PdfFile[] first,
                                 PdfFile[] second)
concat the two arrays

Parameters:
first -
second -
Returns:
concatenated array

setCompressionSettingOnWriter

protected void setCompressionSettingOnWriter(AbstractParsedCommand inputCommand,
                                             com.lowagie.text.pdf.PdfWriter pdfWriter)
Sets the compression settings on the pdf writer depending on the inputCommand

Parameters:
inputCommand -
pdfWriter -

setCompressionSettingOnStamper

protected void setCompressionSettingOnStamper(AbstractParsedCommand inputCommand,
                                              com.lowagie.text.pdf.PdfStamper pdfStamper)
Sets the compression settings on the pdf stamper depending on the inputCommand

Parameters:
inputCommand -
pdfWriter -

setPdfVersionSettingOnWriter

protected void setPdfVersionSettingOnWriter(AbstractParsedCommand inputCommand,
                                            com.lowagie.text.pdf.PdfWriter pdfWriter,
                                            java.lang.Character defaultVersion)
Sets the pdf version setting on the pdf writer depending on the inputCommand

Parameters:
inputCommand -
pdfWriter -
defaultVersion - default version to apply if the inputCommand version is null

setPdfVersionSettingOnWriter

protected void setPdfVersionSettingOnWriter(AbstractParsedCommand inputCommand,
                                            com.lowagie.text.pdf.PdfWriter pdfWriter)
Convenience method to set the pdf version settings on the writer without a default version

Parameters:
inputCommand -
pdfWriter -
See Also:
setPdfVersionSettingOnWriter(AbstractParsedCommand, PdfWriter, Character)

closePdfReader

protected void closePdfReader(com.lowagie.text.pdf.PdfReader pdfReader)
Close the @lonk PdfReader if not null.

Parameters:
pdfReader -

closePdfStamper

protected void closePdfStamper(com.lowagie.text.pdf.PdfStamper pdfStamper)
Close the @link PdfStamper if not null.

Parameters:
pdfStamper -

closePdfWriter

protected void closePdfWriter(com.lowagie.text.pdf.PdfWriter pdfWriter)
Close the @lonk PdfWriter if not null.

Parameters:
pdfWriter -