net.sf.filePiper.processors
Class ChunkProcessor

java.lang.Object
  extended by net.sf.filePiper.processors.ChunkProcessor
All Implemented Interfaces:
FileProcessor, SizeAndUnit

public class ChunkProcessor
extends Object
implements FileProcessor, SizeAndUnit

Processor chunking an input file in a set of output files of fixed size (calculated in lines or bytes).

Author:
BEROL

Field Summary
 
Fields inherited from interface net.sf.filePiper.model.FileProcessor
MANY, NONE, ONE
 
Fields inherited from interface net.sf.filePiper.processors.SizeAndUnit
UNIT_BYTE, UNIT_LINE
 
Constructor Summary
ChunkProcessor()
           
 
Method Summary
 void chunkInBytes(InputStream is, InputFileInfo info, FileProcessorEnvironment env)
           
 void chunkInLines(InputStream is, InputFileInfo info, FileProcessorEnvironment env)
           
 void endBatch(FileProcessorEnvironment env)
          Notification that the current batch is finished.
 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 getProcessorName()
           
 int getSize()
           
 String getStatusMessage()
          Get the status of this processor to display in the status bar of the GUI during file processing.
 int getUnits()
           
 void init(net.sf.sfac.setting.Settings settngs)
          Initialize this file processor just after instantiation (called only once).
 void process(InputStream is, InputFileInfo info, FileProcessorEnvironment env)
          Request to process the given input stream.
 void setSize(int newSize)
           
 void setUnits(int newUnits)
           
 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

ChunkProcessor

public ChunkProcessor()
Method Detail

getProcessorName

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

getSize

public int getSize()
Specified by:
getSize in interface SizeAndUnit

setSize

public void setSize(int newSize)
Specified by:
setSize in interface SizeAndUnit

getUnits

public int getUnits()
Specified by:
getUnits in interface SizeAndUnit

setUnits

public void setUnits(int newUnits)
Specified by:
setUnits in interface SizeAndUnit

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

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.

init

public void init(net.sf.sfac.setting.Settings settngs)
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:
settngs - Settings for this FileProcessor instance.

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.

chunkInLines

public void chunkInLines(InputStream is,
                         InputFileInfo info,
                         FileProcessorEnvironment env)
                  throws IOException
Throws:
IOException

chunkInBytes

public void chunkInBytes(InputStream is,
                         InputFileInfo info,
                         FileProcessorEnvironment env)
                  throws IOException
Throws:
IOException

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

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.


Copyright © 2011. All Rights Reserved.