Last change
on this file was 5956, checked in by kjdon, 21 years ago |
new files for making a simple lucene collection from xml documents
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
866 bytes
|
Line | |
---|
1 |
|
---|
2 | /**
|
---|
3 | *
|
---|
4 | * @author [email protected]
|
---|
5 | * @version
|
---|
6 | */
|
---|
7 |
|
---|
8 | import java.io.File;
|
---|
9 |
|
---|
10 | public class IndexXML extends Object {
|
---|
11 |
|
---|
12 | File out_dir = null;
|
---|
13 | Indexer indexer = null;
|
---|
14 |
|
---|
15 | public void setOutDir(File out_dir) {
|
---|
16 | this.out_dir = out_dir;
|
---|
17 | }
|
---|
18 |
|
---|
19 | public void init() {
|
---|
20 | indexer = new Indexer(out_dir, true);
|
---|
21 | }
|
---|
22 | public void finish() {
|
---|
23 | indexer.finish();
|
---|
24 | }
|
---|
25 | public void indexFile(File file) {
|
---|
26 |
|
---|
27 | if (file.isDirectory()) {
|
---|
28 | File[] files = file.listFiles();
|
---|
29 | for (int i=0; i<files.length; i++) {
|
---|
30 | if (files[i].isDirectory() || files[i].getName().endsWith(".xml")) {
|
---|
31 | indexFile(files[i]);
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | } else {
|
---|
36 | String name = file.getName();
|
---|
37 | name = name.substring(0, name.lastIndexOf('.'));
|
---|
38 | System.out.println("Indexing "+file.getPath()+" with id "+name);
|
---|
39 | this.indexer.index(name, file);
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.