filetools.fileconverttools
Class SimpleFileConverter

java.lang.Object
  extended by filetools.fileconverttools.SimpleFileConverter
All Implemented Interfaces:
IFileConverter
Direct Known Subclasses:
MatlabHelpfileConverter

public abstract class SimpleFileConverter
extends java.lang.Object
implements IFileConverter

Abstract base class for a simple file conversion in a specified directory and its subdirectories. Each found file can be converted or copied. The converted and copied files are either stored in the same directory or in a second one, so that the original keeps untouched. Derivied classes need to define concrete algorithms, which (sub-)directories should be converted and which files should be converted/copied.

Author:
osiris

Field Summary
protected static int BLOCKSIZE
           
 
Constructor Summary
SimpleFileConverter()
           
 
Method Summary
protected abstract  void convertFile(java.io.File inputFile, java.io.File outputFile)
          Converts a single file.
 int convertInDir(java.io.File inputDir, java.io.File outputDir)
          searches the specified directory and its subdirectories for files and stores a converted (and partially copied) version in another one.
protected  void copyFile(java.io.File inputFile, java.io.File outputFile)
          Copies a File by transfering its contents from a filestream to another one block by block Subclasses may override this method to specifiy another copy-algortithm to use.
protected abstract  boolean isDirToConvert(java.lang.String dir)
          Specifies if the contents of the given directory should be converted.
protected abstract  boolean isFileToConvert(java.lang.String filename)
          Specifies if the given file should be converted.
protected abstract  boolean isFileToCopy(java.lang.String filename)
          Specifies if the given file should be copied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCKSIZE

protected static final int BLOCKSIZE
See Also:
Constant Field Values
Constructor Detail

SimpleFileConverter

public SimpleFileConverter()
Method Detail

convertInDir

public int convertInDir(java.io.File inputDir,
                        java.io.File outputDir)
Description copied from interface: IFileConverter
searches the specified directory and its subdirectories for files and stores a converted (and partially copied) version in another one.

Specified by:
convertInDir in interface IFileConverter
Parameters:
inputDir - directory to convert
outputDir - directory where converted files are stored
Returns:
number of files converted
See Also:
IFileConverter.convertInDir(File, File)

copyFile

protected void copyFile(java.io.File inputFile,
                        java.io.File outputFile)
Copies a File by transfering its contents from a filestream to another one block by block Subclasses may override this method to specifiy another copy-algortithm to use.

Parameters:
inputFile - source for the copy-process
outputFile - new copy of the file

convertFile

protected abstract void convertFile(java.io.File inputFile,
                                    java.io.File outputFile)
Converts a single file. Subclasses must implement this method to define a concrete conversion.

Parameters:
inputFile - file to convert
outputFile - converted file

isDirToConvert

protected abstract boolean isDirToConvert(java.lang.String dir)
Specifies if the contents of the given directory should be converted. Subclasses must implement this method to specifiy which directories will be converted.

Parameters:
dir - path of the directory (relative or absolute)
Returns:
true if this directory should be converted

isFileToConvert

protected abstract boolean isFileToConvert(java.lang.String filename)
Specifies if the given file should be converted. Subclasses must implement this method to specifiy which files will be converted.

Parameters:
filename - path of the file
Returns:
true if this file should be converted

isFileToCopy

protected abstract boolean isFileToCopy(java.lang.String filename)
Specifies if the given file should be copied. Subclasses must implement this method to specifiy which files will be copied.

Parameters:
filename - path of the file
Returns:
true if this file should be copied