1
2
3
4
5
6
7 package net.sf.gumshoe.indexer;
8
9 import java.io.File;
10 import java.io.FileReader;
11 import java.util.List;
12 import java.util.Vector;
13
14
15 import org.apache.lucene.document.Document;
16 import org.apache.lucene.document.Field;
17
18 /***
19 * @author Gabor
20 *
21 * TODO To change the template for this generated type comment go to
22 * Window - Preferences - Java - Code Style - Code Templates
23 */
24 public class XMLContentReader extends ContentReader {
25 /***
26 *
27 */
28 public XMLContentReader() {
29 super();
30 }
31
32 /*** Default category is none
33 * @see net.sf.gumshoe.indexer.ContentReader#getCategory()
34 */
35 public String getCategory() {
36 return "";
37 }
38
39
40
41
42 public List getSupportedExtensions() {
43 List extensions=new Vector();
44 extensions.add("xml");
45 extensions.add("html");
46 extensions.add("htm");
47 extensions.add("xhtml");
48 extensions.add("xsd");
49 return extensions;
50 }
51
52
53
54
55 public Document getDocument(File f) throws Exception {
56 Document doc = new Document();
57 addDefaultFields(f, doc, "");
58 doc.add(Field.Text(CONTENTS, getContentFromXML(new FileReader(f))));
59 return doc;
60 }
61 }