net.sf.filePiper.model
Class OneToOneByteFileProcessor

java.lang.Object
  extended by net.sf.filePiper.model.OneToOneByteFileProcessor
All Implemented Interfaces:
FileProcessor
Direct Known Subclasses:
CopyProcessor, HeadProcessor, ImageSizerProcessor, OneToOneTextFileProcessor, TailProcessor

public abstract class OneToOneByteFileProcessor
extends Object
implements FileProcessor

Base implementation for FileProcessor with ONE to ONE cardinality and processing byte streams.
There is only 3 remaining abstract methods very simple to implement.

Author:
BEROL

Field Summary
 
Fields inherited from interface net.sf.filePiper.model.FileProcessor
MANY, NONE, ONE
 
Constructor Summary
OneToOneByteFileProcessor()
           
 
Method Summary
 void bytesProcessed(int nbrByteProcessed)
           
 void endBatch(FileProcessorEnvironment env)
          Notification that the current batch is finished.
protected  InputFileInfo getCurrentInputFileInfo()
           
 net.sf.sfac.gui.editor.ObjectEditor getEditor()
          Get a GUI editor for this object.
 int getOutputCardinality(int inputCardinality)
          Get the number of output streams generated for the given number of input streams.
 String getProcessorDescription()
           
abstract  String getProcessorName()
           
protected  String getProposedExtension(InputFileInfo info)
           
abstract  String getProposedNameSuffix()
           
protected  net.sf.sfac.setting.Settings getSettings()
           
 String getStatusMessage()
          Get the status of this processor to display in the status bar of the GUI during file processing.
 void init(net.sf.sfac.setting.Settings sett)
          Initialize this file processor just after instantiation (called only once).
 void inputFileStarted()
           
 void linesProcessed(int nbrLineProcessed)
           
 void process(InputStream is, InputFileInfo info, FileProcessorEnvironment env)
          Request to process the given input stream.
abstract  void process(InputStream is, OutputStream os, FileProcessorEnvironment env)
           
protected  void setCurrentInputFileInfo(InputFileInfo info)
           
protected  void setProposedFilePath(InputFileInfo info)
           
 void startBatch(FileProcessorEnvironment env)
          Notification that the processing of a batch of file is starting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OneToOneByteFileProcessor

public OneToOneByteFileProcessor()
Method Detail

init

public void init(net.sf.sfac.setting.Settings sett)
Description copied from interface: FileProcessor
Initialize this file processor just after instantiation (called only once).
The settings passed here should be use to store all persistent data.

Specified by:
init in interface FileProcessor
Parameters:
sett - Settings for this FileProcessor instance.

getSettings

protected net.sf.sfac.setting.Settings getSettings()

getCurrentInputFileInfo

protected InputFileInfo getCurrentInputFileInfo()

setCurrentInputFileInfo

protected void setCurrentInputFileInfo(InputFileInfo info)

startBatch

public void startBatch(FileProcessorEnvironment env)
Description copied from interface: FileProcessor
Notification that the processing of a batch of file is starting.
This method allows to initialize this FileProcessor before each file batch processing.

Specified by:
startBatch in interface FileProcessor

endBatch

public void endBatch(FileProcessorEnvironment env)
Description copied from interface: FileProcessor
Notification that the current batch is finished.

Specified by:
endBatch in interface FileProcessor

getOutputCardinality

public int getOutputCardinality(int inputCardinality)
Description copied from interface: FileProcessor
Get the number of output streams generated for the given number of input streams.
possible values are:

Specified by:
getOutputCardinality in interface FileProcessor
Parameters:
inputCardinality - ONE or MANY.

process

public void process(InputStream is,
                    InputFileInfo info,
                    FileProcessorEnvironment env)
             throws IOException
Description copied from interface: FileProcessor
Request to process the given input stream.
The output stream to use for output should be requested to the FileProcessorEnvironment.

Specified by:
process in interface FileProcessor
Parameters:
is - the InputStream to process
info - Information about the input file to process
env - object used by this FileProcessor to interact with its environment.
Throws:
IOException - if something goes wrong.

setProposedFilePath

protected void setProposedFilePath(InputFileInfo info)

getProposedExtension

protected String getProposedExtension(InputFileInfo info)

getEditor

public net.sf.sfac.gui.editor.ObjectEditor getEditor()
Description copied from interface: FileProcessor
Get a GUI editor for this object.

Specified by:
getEditor in interface FileProcessor

getProcessorDescription

public String getProcessorDescription()

getStatusMessage

public String getStatusMessage()
Description copied from interface: FileProcessor
Get the status of this processor to display in the status bar of the GUI during file processing.

Warning: this method is called in a different Thread from the processing Thread (the Thread calling the process(..) method). It is usually called from the swing EventDispatchThread. So, be aware of possible threading synchronization problems while accessing the instance variables of your class.

Specified by:
getStatusMessage in interface FileProcessor
Returns:
the status of this processor.

inputFileStarted

public void inputFileStarted()

linesProcessed

public void linesProcessed(int nbrLineProcessed)

bytesProcessed

public void bytesProcessed(int nbrByteProcessed)

getProcessorName

public abstract String getProcessorName()
Specified by:
getProcessorName in interface FileProcessor
Returns:
A displayable name for this processor.

getProposedNameSuffix

public abstract String getProposedNameSuffix()

process

public abstract void process(InputStream is,
                             OutputStream os,
                             FileProcessorEnvironment env)
                      throws Exception
Throws:
Exception


Copyright © 2011. All Rights Reserved.