Last change
on this file since 5944 was 5944, checked in by cs025, 20 years ago |
Index document type, metadata extensions
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.2 KB
|
Line | |
---|
1 | package org.greenstone.gsdl3.gs3build.doctypes;
|
---|
2 |
|
---|
3 | import org.greenstone.gsdl3.gs3build.FileCrawlObserver;
|
---|
4 |
|
---|
5 | import java.io.File;
|
---|
6 | import java.net.URL;
|
---|
7 |
|
---|
8 | public class RecogniserManager implements FileCrawlObserver
|
---|
9 | {
|
---|
10 | RecogniserInterface list[];
|
---|
11 | int used;
|
---|
12 | int size;
|
---|
13 |
|
---|
14 | public RecogniserManager()
|
---|
15 | { this.list = new RecogniserInterface[10];
|
---|
16 | this.used = 0;
|
---|
17 | this.size = 10;
|
---|
18 | }
|
---|
19 |
|
---|
20 | public void addRecogniser(RecogniserInterface recogniser)
|
---|
21 | { this.ensureCapacity(this.used + 1);
|
---|
22 |
|
---|
23 | this.list[this.used] = recogniser;
|
---|
24 | this.used ++;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public void processFile(URL url)
|
---|
28 | { boolean result;
|
---|
29 |
|
---|
30 | for (int r = 0; r < this.used; r ++)
|
---|
31 | { if (list[r].parseDocument(url)) {
|
---|
32 | break;
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public void processFile(File file)
|
---|
38 | { try {
|
---|
39 | URL url = new URL("file://"+file.toString());
|
---|
40 |
|
---|
41 | this.processFile(url);
|
---|
42 | }
|
---|
43 | catch (java.net.MalformedURLException ex)
|
---|
44 | {
|
---|
45 | System.out.println(ex);
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | private void ensureCapacity(int size)
|
---|
50 | { while (size >= this.size)
|
---|
51 | { RecogniserInterface newList [] = new RecogniserInterface[this.size*2];
|
---|
52 | this.size *= 2;
|
---|
53 | System.arraycopy(this.list, 0, newList, 0, this.size);
|
---|
54 | this.list = newList;
|
---|
55 | }
|
---|
56 | }
|
---|
57 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.