KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > lucene > index > DefaultDocumentCreator


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: DefaultDocumentCreator.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.lucene.index;
21
22 import java.io.File JavaDoc;
23
24 import org.apache.lenya.lucene.parser.HTMLParser;
25 import org.apache.lenya.lucene.parser.HTMLParserFactory;
26 import org.apache.lucene.document.Document;
27 import org.apache.lucene.document.Field;
28
29 public class DefaultDocumentCreator extends AbstractDocumentCreator {
30
31     /**
32      * Creates a new instance of DefaultDocumentCreator
33      */

34     public DefaultDocumentCreator() {
35     }
36
37     /**
38      * DOCUMENT ME!
39      *
40      * @param file DOCUMENT ME!
41      * @param htdocsDumpDir DOCUMENT ME!
42      *
43      * @return DOCUMENT ME!
44      *
45      * @throws Exception DOCUMENT ME!
46      */

47     public Document getDocument(File JavaDoc file, File JavaDoc htdocsDumpDir) throws Exception JavaDoc {
48         Document document = super.getDocument(file, htdocsDumpDir);
49
50         HTMLParser parser = HTMLParserFactory.newInstance(file);
51         parser.parse(file);
52
53         document.add(Field.Text("title", parser.getTitle()));
54         document.add(Field.Text("keywords", parser.getKeywords()));
55         document.add(Field.Text("contents", parser.getReader()));
56
57         return document;
58     }
59 }
60
Popular Tags