source: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/extractor/ExtractorManager.java@ 5800

Last change on this file since 5800 was 5800, checked in by cs025, 21 years ago

Adding gs3build

  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1package org.greenstone.gsdl3.gs3build.extractor;
2
3import org.greenstone.gsdl3.gs3build.doctypes.DocumentID;
4import org.greenstone.gsdl3.gs3build.doctypes.DocumentInterface;
5import org.greenstone.gsdl3.gs3build.doctypes.DocumentList;
6
7public class ExtractorManager
8{
9 DocumentList documents;
10 ExtractorInterface [] list;
11 int size;
12 int used;
13
14 public ExtractorManager(DocumentList documentList)
15 { this.list = new ExtractorInterface[10];
16 this.size = 10;
17 this.used = 0;
18 this.documents = documentList;
19 }
20
21 public void addExtractor(ExtractorInterface extractor)
22 { this.ensureSize(this.used + 1);
23 this.list[this.used] = extractor;
24 this.used ++;
25 }
26
27 public void extractDocument(DocumentID docId, DocumentInterface document)
28 { for (int i = 0; i < this.used; i ++)
29 { this.list[i].extractDocument(docId, document);
30 }
31 }
32
33 public void extractDocuments()
34 { for (int i = 0; i < this.used; i ++)
35 { for (int p = 0; p < this.list[i].getNumberOfPasses(); p ++)
36 { this.list[i].startPass(p);
37 for (int d = 0; d < this.documents.size(); d ++)
38 { this.list[i].extractDocument(null, documents.getDocument(d));
39 }
40 this.list[i].endPass(p);
41 }
42 }
43 }
44
45 public void ensureSize(int size)
46 { while (size >= this.size)
47 { ExtractorInterface newList [] = new ExtractorInterface[this.size*2];
48 this.size *= 2;
49 System.arraycopy(this.list, 0, newList, 0, this.size);
50 this.list = newList;
51 }
52 }
53}
Note: See TracBrowser for help on using the repository browser.