Changeset 5944 for trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/RecogniserManager.java
- Timestamp:
- 2003-11-24T14:26:35+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/RecogniserManager.java
r5800 r5944 8 8 public class RecogniserManager implements FileCrawlObserver 9 9 { 10 11 12 10 RecogniserInterface list[]; 11 int used; 12 int size; 13 13 14 15 {this.list = new RecogniserInterface[10];16 17 18 14 public RecogniserManager() 15 { this.list = new RecogniserInterface[10]; 16 this.used = 0; 17 this.size = 10; 18 } 19 19 20 21 {this.ensureCapacity(this.used + 1);20 public void addRecogniser(RecogniserInterface recogniser) 21 { this.ensureCapacity(this.used + 1); 22 22 23 24 25 23 this.list[this.used] = recogniser; 24 this.used ++; 25 } 26 26 27 28 {boolean result;27 public void processFile(URL url) 28 { boolean result; 29 29 30 31 {if (list[r].parseDocument(url)) {32 33 34 35 30 for (int r = 0; r < this.used; r ++) 31 { if (list[r].parseDocument(url)) { 32 break; 33 } 34 } 35 } 36 36 37 public void processFile(File file) 38 { try { 39 URL url = new URL("file://"+file.toString()); 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 } 40 48 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 } 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 57 }
Note:
See TracChangeset
for help on using the changeset viewer.