/** File: ProcessLoadIndexMapData.java */ /** * Class ProcessLoadIndexMapDatais used to create a data processing Thread to * load the IndexMap database. *
* List of Methods*
* =================== * ProcessLoadIndexMapData() - Constructor * run() - Process data specified by the GUI state * *
* This code is available at the HTMLtools project on SourceForge at * http://htmltools.sourceforge.net/ * under the "Common Public License Version 1.0" * * http://www.opensource.org/licenses/cpl1.0.php.
** It was derived and refactored from the open source * MAExplorer (http://maexplorer.sourceforge.net/), and * Open2Dprot (http://Open2Dprot.sourceforge.net/) Table modules. *
* $Date: 2009/07/22 11:45:56 $ $Revision: 1.28 $
*
* Copyright 2008, 2009 by Peter Lemkin
* E-Mail: lemkin@users.sourceforge.net
* http://lemkingroup.com/
*
*/
public class ProcessLoadIndexMapData extends Thread
{ /* ProcessLoadIndexMapData*/
public final static long
serialVersionUID= 0;
/** Note all GUI global variables are in SearchGUI.java instance. */
private SearchGUI
sGui= null;
/** Is the file path for the Index Map file.*/
private String
indexMapPath= null;
/** FileTable for the IndexMap.*/
public FileTable
ftIM= null;
/**
* ProcessLoadIndexMapData() - Constructor
* @param gui is an instance of the SearchGUI class
* @param indexMapPath - is Index Map file path
* @param ftIM - is FileTable for the IndexMap
*/
public ProcessLoadIndexMapData(SearchGUI sGui, String indexMapPath,
FileTable ftIM)
{ /* ProcessLoadIndexMapData */
this.setName("ProcessLoadIndexMapData"); /* Set the Thread name */
this.sGui= sGui;
this.ftIM= ftIM;
this.indexMapPath= indexMapPath;
this.ftIM= ftIM;
sGui.indexMapReadyFlag= false;
sGui.indexMapProblemFlag= false;
if(indexMapPath==null || ftIM==null)
{ /* No job to run */
UtilCM.logMsg("\nCan't read Index Map file - no path specified.\n");
sGui.indexMapReadyFlag= false;
sGui.indexMapProblemFlag= true;
}
} /* ProcessLoadIndexMapData */
/**
* run() - Process data specified by the GUI state
*/
public void run()
{ /* run */
/* [1] Get the Index Map FileTable that we will use to verify search terms.
* We get this from '-flipTableByIndexMap:{dataSet.txt,dataSet.idx}'.
*/
ftIM.setHasTableHeaderFlag(true);
ftIM.setRmvTrailingBlankLinesFlag(true);
ftIM.setRmvTrailingEmptyColumnsFlag(true);
/* [2] Read the table */
UtilCM.logMsg("Reading the Index Map database file...\n");
if(!ftIM.readAndParseTable(indexMapPath))
{ /* failed*/
UtilCM.logMsg("Problem reading Index Map file '" +
indexMapPath+"'\n"+ ftIM.errMsgLog+"\n");
sGui.indexMapReadyFlag= true;
sGui.indexMapProblemFlag= true;
return;
}
/* [3] Check if table is ok */
UtilCM.logMsg("Finished reading the Index Map database file.\n");
if(ftIM.tRows==0 || ftIM.tCols<3)
{ /* failed - bad table */
UtilCM.logMsg("Problem Index Map file '" +
indexMapPath+"' - #rows="+ftIM.tRows+
" or #columns="+ftIM.tCols+
" in Table NEQ 2 required.\n");
sGui.indexMapReadyFlag= true;
sGui.indexMapProblemFlag= true;
return;
}
/* [4] Kills pd thread when return from run() */
sGui.indexMapReadyFlag= true;
sGui.indexMapProblemFlag= false;
return;
} /* run */
} /* end of class ProcessLoadIndexMapData */