FileDocCategorySizeDatePackage
IndexLogReader.javaAPI DocApache Lucene 2.1.05765Wed Feb 14 10:46:06 GMT 2007org.apache.lucene.gdata.search.index

IndexLogReader

public class IndexLogReader extends Object
author
Simon Willnauer

Fields Summary
Constructors Summary
Methods Summary
static java.util.MapreadIndexLog(java.io.File indexLogFile, java.util.Map contentMap)

        XMLReader reader = XMLReaderFactory.createXMLReader();
        
        Map<String, IndexAction> logContent = contentMap;
        if(logContent == null)
            logContent = new HashMap<String,IndexAction>(64);
        
        reader.setContentHandler(new IndexLogContentHandler(logContent));
        InputSource source = new InputSource(new FileInputStream(indexLogFile));
        try{
        reader.parse(source);
        }catch (SAXException e) {
            /*
             * try to append the Root element end
             * this happens if the server crashes.
             * If it dies while writing an entry the log file has to be fixed manually
             */
            IndexLogWriter.tryCloseRoot(indexLogFile);
            source = new InputSource(new FileInputStream(indexLogFile));
            reader.parse(source);
        }
        return logContent;