Links
dtSearch Text Retrieval Engine -- Java API 7.70
IIndexStatusHandler Interface
Interfaces | Legend | Members | Methods | Send Feedback

IIndexStatusHandler provides an interface to obtain detailed information on the progress of an index update.

Class Hierarchy
public interface IIndexStatusHandler;
File

IIndexStatusHandler.java

Remarks

IIndexStatusHandler is designed for situations where it is important to have complete information, such as logging the names of documents indexed and how each file was indexed. Each time IIndexStatusHandler.onProgressUpdate is called, the IndexProgressInfo.updateType will indicate the reason for the notification. The updateType is a MessageCode value that indicates when, for example, a file was successfully indexed (dtsnIndexFileDone) or could not be indexed due to an error (dtsnIndexFileOpenFail, dtsnIndexFileEncrypted). 

To use IIndexStatusHandler, 

(1) Create an object that implements the IIndexStatusHandler interface, and 

(2) Attach it to an IndexJob prior to calling execute using setStatusHandler2(). 

Example:

    /*
    Demonstrates use of the IIndexStatusHandler API to monitor an IndexJob in Java
*/

package misc;
import java.util.*;
import com.dtsearch.engine.*;
public class IndexStatusHandlerDemo {
        //
        private  class MyIndexStatusHandler  implements IIndexStatusHandler {
            public void onProgressUpdate(IndexProgressInfo prog) {
                if (prog.updateType == MessageCode.dtsnIndexFileDone)
                    System.out.println("File: " + prog.file.name + " id=" + prog.file.docId + " type=" + prog.file.type + " \n");
                else if (prog.updateType == MessageCode.dtsnIndexFileEncrypted)
                    System.out.println("Encrypted: " + prog.file.name);
                else if (prog.updateType == MessageCode.dtsnIndexFileOpenFail)
                    System.out.println("Corrupt: " + prog.file.name + " " + prog.file.openFailMessage);


            }
            public int checkForAbort() {
                return AbortValue.Continue;
            }
        };
        public static void main(String[] args) {
            if (args.length == 0) {
                    System.out.println("Usage:  java IndexStatusHandler IndexPath DocPath\n");
                }
            else {
                IndexStatusHandlerDemo demo = new IndexStatusHandlerDemo(args[0], args[1]);
                demo.run();
            }
        }

        private IndexJob indexJob;
        private MyIndexStatusHandler statusHandler;

        public IndexStatusHandlerDemo(String path, String toIndex) {
                indexJob =  new IndexJob();
                statusHandler = new MyIndexStatusHandler();
                indexJob.setIndexPath(path);
                indexJob.setFoldersToIndex(toIndex);
                indexJob.setActionCreate(true);
                indexJob.setActionAdd(true);
                indexJob.setStatusHandler2(statusHandler);
                }

          void run() {
                indexJob.execute();
                System.out.println("Indexing complete");
            }
    }
Group
Methods
Method 
Description 
Called during IndexJob execution to give the calling process a chance to cancel the update.  
Called during an index update to provide details on the status of the indexer. 
Legend
 
Method 
Links
You are here: Interfaces > IIndexStatusHandler Interface
Copyright (c) 1998-2012 dtSearch Corp. All rights reserved.