filetools.fileconverttools
Class MatlabHelpfileConverter

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

public class MatlabHelpfileConverter
extends SimpleFileConverter

Implementation of IFileConverter which converts a helpfile line by line. Each "file:" in a link is replaced by "" by searching the regex 'href\s*=\s*"file:'

Author:
osiris

Field Summary
private static java.lang.String[] TO_CONVERT
          keeps the searched regex and its replacement - very simple in this application
 
Fields inherited from class filetools.fileconverttools.SimpleFileConverter
BLOCKSIZE
 
Constructor Summary
MatlabHelpfileConverter()
           
 
Method Summary
protected  void convertFile(java.io.File fileToConvert)
          Converts a file by reading, converting and storing its contents line by line.
protected  void convertFile(java.io.File inputFile, java.io.File outputFile)
          Converts a file line by line.
private  java.lang.String convertString(java.lang.String stringToConvert)
          Converts a given String by searching for an regex and replacing each of its occurrences by a given expression
protected  boolean isDirToConvert(java.lang.String dir)
          The contents of all subdirs should be converted
protected  boolean isFileToConvert(java.lang.String filename)
          htm and html files will be converted
protected  boolean isFileToCopy(java.lang.String filename)
          All files should be copied
static void main(java.lang.String[] args)
           
 
Methods inherited from class filetools.fileconverttools.SimpleFileConverter
convertInDir, copyFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TO_CONVERT

private static final java.lang.String[] TO_CONVERT
keeps the searched regex and its replacement - very simple in this application

Constructor Detail

MatlabHelpfileConverter

public MatlabHelpfileConverter()
Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args - should contain the base directory

isDirToConvert

protected boolean isDirToConvert(java.lang.String dir)
The contents of all subdirs should be converted

Specified by:
isDirToConvert in class SimpleFileConverter
Parameters:
dir - path of the directory (relative or absolute)
Returns:
true if this directory should be converted
See Also:
SimpleFileConverter.isDirToConvert(String)

isFileToConvert

protected boolean isFileToConvert(java.lang.String filename)
htm and html files will be converted

Specified by:
isFileToConvert in class SimpleFileConverter
Parameters:
filename - path of the file
Returns:
true if this file should be converted
See Also:
SimpleFileConverter.isFileToConvert(String)

isFileToCopy

protected boolean isFileToCopy(java.lang.String filename)
All files should be copied

Specified by:
isFileToCopy in class SimpleFileConverter
Parameters:
filename - path of the file
Returns:
true if this file should be copied
See Also:
SimpleFileConverter.isFileToCopy(String)

convertFile

protected void convertFile(java.io.File inputFile,
                           java.io.File outputFile)
Converts a file line by line. If only one file is used as input and output another algorithm is used by calling convertFile(File)

Specified by:
convertFile in class SimpleFileConverter
Parameters:
inputFile - file to convert
outputFile - converted file
See Also:
SimpleFileConverter.convertFile(File, File)

convertString

private java.lang.String convertString(java.lang.String stringToConvert)
Converts a given String by searching for an regex and replacing each of its occurrences by a given expression

Parameters:
stringToConvert - String before conversion
Returns:
converted String

convertFile

protected void convertFile(java.io.File fileToConvert)
Converts a file by reading, converting and storing its contents line by line. After that the stored data is written into the same file.

Parameters:
fileToConvert - File which is used as input and output.