filetools.filesearchtools
Class MatlabHelpfileIndexer

java.lang.Object
  extended by filetools.filesearchtools.SimpleFileSearch
      extended by filetools.filesearchtools.MatlabHelpfileIndexer
All Implemented Interfaces:
IFileSearch

public class MatlabHelpfileIndexer
extends SimpleFileSearch

Concrete implementation of IFileSearch which searches for Matlab-helpfiles (html), collects information about them and writes all together in a database.

Author:
osiris

Nested Class Summary
protected  class MatlabHelpfileIndexer.FileInfo
          Helper class which keeps all collected information about a matlab-helpfile
 
Field Summary
private static java.lang.String CHAPNAME_STR
           
private static java.lang.String CHUNKNAME_STR
           
private static java.lang.String DB_DBNAME_DEF
           
private static java.lang.String DB_DBNAME_KEY
          db connection data property names
private static java.lang.String DB_DRIVER
          db connection data
private static java.lang.String DB_HOSTNAME_DEF
          db connection data default values
private static java.lang.String DB_HOSTNAME_KEY
           
private static java.lang.String DB_TABLENAME
           
private static java.lang.String DB_USERNAME_DEF
           
private static java.lang.String DB_USERNAME_KEY
           
private static java.lang.String DB_USERPWD_DEF
           
private static java.lang.String DB_USERPWD_KEY
           
static java.lang.String DBPROPERTYFILE
          name of the property file which contains data for the db-connection
private  java.sql.Statement dbStatement
          variable for the DB-connection
private static java.lang.String DOCNAME_STR
           
private static java.lang.String END_STR
           
private static java.lang.String FD_ENDTAG
           
private static java.lang.String FD_STARTTAG
           
private static java.lang.String FRAMEPAGE_STR
           
private  boolean getFuncDescription
          helper variable for searching
private static java.lang.String INDEX_STR
           
private static java.lang.String NAVPAGE_STR_1
           
private static java.lang.String NAVPAGE_STR_2
           
private static java.lang.String REFDIR_STR
           
private static java.lang.String START_STR
          some definitions for searching
private static java.lang.String TITLE_END_STR
           
private static java.lang.String TITLE_START_STR
           
private static java.lang.String TOC_STR
           
 
Fields inherited from class filetools.filesearchtools.SimpleFileSearch
outputFileWriter
 
Constructor Summary
MatlabHelpfileIndexer()
          Constructor, establishes a db-connection and empties the table
 
Method Summary
 boolean isConnectedToDB()
           
protected  boolean isDirToSearch(java.lang.String dir)
          Search all directories
protected  boolean isSearchedFileName(java.lang.String filename)
          All htm and html files are searched.
static void main(java.lang.String[] args)
           
protected  void processFile(java.io.File file)
          scans the filename for information about the filename, then the file is searched line by line until all nessesary information is collected
private  void processLine(java.lang.String line, MatlabHelpfileIndexer.FileInfo fileInfo)
          Processes a single line of the investigated file.
static boolean writeDefaultProperties(java.lang.String filename)
          Creates a new XML file which can be used as property-file for the db-connection data.
private  void writeToDB(MatlabHelpfileIndexer.FileInfo fileInfo)
          Writes the given information into a database by inserting a new entry.
 
Methods inherited from class filetools.filesearchtools.SimpleFileSearch
searchDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START_STR

private static final java.lang.String START_STR
some definitions for searching

See Also:
Constant Field Values

DOCNAME_STR

private static final java.lang.String DOCNAME_STR
See Also:
Constant Field Values

CHUNKNAME_STR

private static final java.lang.String CHUNKNAME_STR
See Also:
Constant Field Values

CHAPNAME_STR

private static final java.lang.String CHAPNAME_STR
See Also:
Constant Field Values

END_STR

private static final java.lang.String END_STR
See Also:
Constant Field Values

FRAMEPAGE_STR

private static final java.lang.String FRAMEPAGE_STR
See Also:
Constant Field Values

TITLE_START_STR

private static final java.lang.String TITLE_START_STR
See Also:
Constant Field Values

TITLE_END_STR

private static final java.lang.String TITLE_END_STR
See Also:
Constant Field Values

INDEX_STR

private static final java.lang.String INDEX_STR
See Also:
Constant Field Values

TOC_STR

private static final java.lang.String TOC_STR
See Also:
Constant Field Values

NAVPAGE_STR_1

private static final java.lang.String NAVPAGE_STR_1
See Also:
Constant Field Values

NAVPAGE_STR_2

private static final java.lang.String NAVPAGE_STR_2
See Also:
Constant Field Values

REFDIR_STR

private static final java.lang.String REFDIR_STR
See Also:
Constant Field Values

FD_STARTTAG

private static final java.lang.String FD_STARTTAG
See Also:
Constant Field Values

FD_ENDTAG

private static final java.lang.String FD_ENDTAG
See Also:
Constant Field Values

DBPROPERTYFILE

public static final java.lang.String DBPROPERTYFILE
name of the property file which contains data for the db-connection

See Also:
Constant Field Values

DB_DRIVER

private static final java.lang.String DB_DRIVER
db connection data

See Also:
Constant Field Values

DB_TABLENAME

private static final java.lang.String DB_TABLENAME
See Also:
Constant Field Values

DB_HOSTNAME_DEF

private static final java.lang.String DB_HOSTNAME_DEF
db connection data default values

See Also:
Constant Field Values

DB_DBNAME_DEF

private static final java.lang.String DB_DBNAME_DEF
See Also:
Constant Field Values

DB_USERNAME_DEF

private static final java.lang.String DB_USERNAME_DEF
See Also:
Constant Field Values

DB_USERPWD_DEF

private static final java.lang.String DB_USERPWD_DEF
See Also:
Constant Field Values

DB_DBNAME_KEY

private static final java.lang.String DB_DBNAME_KEY
db connection data property names

See Also:
Constant Field Values

DB_USERNAME_KEY

private static final java.lang.String DB_USERNAME_KEY
See Also:
Constant Field Values

DB_USERPWD_KEY

private static final java.lang.String DB_USERPWD_KEY
See Also:
Constant Field Values

DB_HOSTNAME_KEY

private static final java.lang.String DB_HOSTNAME_KEY
See Also:
Constant Field Values

dbStatement

private java.sql.Statement dbStatement
variable for the DB-connection


getFuncDescription

private boolean getFuncDescription
helper variable for searching

Constructor Detail

MatlabHelpfileIndexer

public MatlabHelpfileIndexer()
Constructor, establishes a db-connection and empties the table

Method Detail

processFile

protected void processFile(java.io.File file)
scans the filename for information about the filename, then the file is searched line by line until all nessesary information is collected

Specified by:
processFile in class SimpleFileSearch
Parameters:
file - File object which represents the found file
See Also:
SimpleFileSearch.processFile(java.io.File)

processLine

private void processLine(java.lang.String line,
                         MatlabHelpfileIndexer.FileInfo fileInfo)
Processes a single line of the investigated file.

Parameters:
line - Content of the line to process
fileInfo - Object which is manipulated to store the found information

isDirToSearch

protected boolean isDirToSearch(java.lang.String dir)
Search all directories

Specified by:
isDirToSearch in class SimpleFileSearch
Parameters:
dir - Name of the directory, not the whole path!
Returns:
true if this directory should be searched
See Also:
SimpleFileSearch.isDirToSearch(java.lang.String)

isSearchedFileName

protected boolean isSearchedFileName(java.lang.String filename)
All htm and html files are searched.

Specified by:
isSearchedFileName in class SimpleFileSearch
Parameters:
filename - Name of the file, not its path!
Returns:
true if this is a searched file
See Also:
SimpleFileSearch.isSearchedFileName(java.lang.String)

main

public static void main(java.lang.String[] args)
Parameters:
args - contains a list of directories to search

writeToDB

private void writeToDB(MatlabHelpfileIndexer.FileInfo fileInfo)
Writes the given information into a database by inserting a new entry.

Parameters:
fileInfo -

writeDefaultProperties

public static boolean writeDefaultProperties(java.lang.String filename)
Creates a new XML file which can be used as property-file for the db-connection data. It contains the default data.

Parameters:
filename - Name of the file to create.
Returns:
true if file was successfully created, false otherwise

isConnectedToDB

public boolean isConnectedToDB()