net.jot.search.simpleindexer
Class JOTIndexHandler

java.lang.Object
  extended by net.jot.search.simpleindexer.JOTIndexHandler

public class JOTIndexHandler
extends java.lang.Object

Helper to JOTSimpleSearchEngine to handle the index files. The master file: index.txt and the index files ex: 0A/EF.txt

Author:
thibautc

Constructor Summary
JOTIndexHandler(java.io.File rootFolder)
           
 
Method Summary
 void addMasterEntry(int id, java.lang.String key, long lastModified)
          Adds a new entry to index.txt
 java.lang.String findKeywordIndexLine(java.lang.String keyword)
          Return the index file line for a specific keyword or empty string if none found.
 long getEntryStamp(java.lang.String key)
          Get the timestamp of last indexing of an entry
 java.lang.String getMasterIdByKey(java.lang.String key)
           
 java.lang.String getMasterKeyById(java.lang.String id)
           
 boolean indexKeyword(java.lang.String id, java.lang.String word, java.util.Vector lines)
          Add a keyword to the index id: id of the key in index.txt word: the keyword to be indexed lines: vector of line numbers return: wether it was a new keyword or not
 boolean isNewKey(java.lang.String key)
          wether the key is new or already indexed
protected  void loadMasterFile()
          Called from constructor loads existing index.txt
 void removeEntries(java.lang.String key)
          Remove an entry keywords from indexes Does not remove the entry itself(ie: file) from the index master itself, call removeMasterEntry for that.
 void removeMasterEntry(java.lang.String key)
          Remove the file/key from the master index (ie: deleted file)
 void saveMasterFile()
          saves index.txt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JOTIndexHandler

public JOTIndexHandler(java.io.File rootFolder)
                throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

loadMasterFile

protected void loadMasterFile()
                       throws java.lang.Exception
Called from constructor loads existing index.txt

Throws:
java.lang.Exception

saveMasterFile

public void saveMasterFile()
                    throws java.lang.Exception
saves index.txt

Throws:
java.lang.Exception

getEntryStamp

public long getEntryStamp(java.lang.String key)
Get the timestamp of last indexing of an entry

Parameters:
key -
Returns:

isNewKey

public boolean isNewKey(java.lang.String key)
wether the key is new or already indexed

Parameters:
key -
Returns:

addMasterEntry

public void addMasterEntry(int id,
                           java.lang.String key,
                           long lastModified)
                    throws java.lang.Exception
Adds a new entry to index.txt

Parameters:
id -
key -
lastModified -
Throws:
java.lang.Exception

getMasterKeyById

public java.lang.String getMasterKeyById(java.lang.String id)

getMasterIdByKey

public java.lang.String getMasterIdByKey(java.lang.String key)

removeEntries

public void removeEntries(java.lang.String key)
                   throws java.lang.Exception
Remove an entry keywords from indexes Does not remove the entry itself(ie: file) from the index master itself, call removeMasterEntry for that.

Parameters:
id -
Throws:
java.lang.Exception

removeMasterEntry

public void removeMasterEntry(java.lang.String key)
                       throws java.lang.Exception
Remove the file/key from the master index (ie: deleted file)

Parameters:
id -
Throws:
java.lang.Exception

indexKeyword

public boolean indexKeyword(java.lang.String id,
                            java.lang.String word,
                            java.util.Vector lines)
                     throws java.lang.Exception
Add a keyword to the index id: id of the key in index.txt word: the keyword to be indexed lines: vector of line numbers return: wether it was a new keyword or not

Throws:
java.lang.Exception

findKeywordIndexLine

public java.lang.String findKeywordIndexLine(java.lang.String keyword)
                                      throws java.lang.Exception
Return the index file line for a specific keyword or empty string if none found.

Throws:
java.lang.Exception