FileDocCategorySizeDatePackage
FileExtensionDocumentHandler.javaAPI DocApache Lucene 1.91943Mon Feb 20 09:17:56 GMT 2006org.apache.lucene.ant

FileExtensionDocumentHandler

public class FileExtensionDocumentHandler extends Object implements DocumentHandler
A DocumentHandler implementation to delegate responsibility to based on a files extension. Currently only .html and .txt files are handled, other extensions ignored.
author
Erik Hatcher
created
October 28, 2001
todo
Implement dynamic document type lookup

Fields Summary
Constructors Summary
Methods Summary
public org.apache.lucene.document.DocumentgetDocument(java.io.File file)
Gets the document attribute of the FileExtensionDocumentHandler object

param
file Description of Parameter
return
The document value
exception
DocumentHandlerException Description of Exception

        Document doc = null;

        String name = file.getName();

        try {
            if (name.endsWith(".txt")) {
                doc = TextDocument.Document(file);
            }

            if (name.endsWith(".html")) {
                doc = HtmlDocument.Document(file);
            }
        } catch (java.io.IOException e) {
            throw new DocumentHandlerException(e);
        }

        return doc;