- Timestamp:
- 2004-11-08T15:56:35+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/TextRecogniser.java
r8422 r8484 9 9 public class TextRecogniser implements RecogniserInterface 10 10 { 11 DocumentList listRepository; 12 13 public TextRecogniser(DocumentList listRepository) 14 { this.listRepository = listRepository; 15 } 11 DocumentList listRepository; 12 13 public TextRecogniser(DocumentList listRepository) 14 { 15 this.listRepository = listRepository; 16 } 17 18 public boolean parseDocument(METSFile file) 19 { 20 String MIMEType = file.getMIMEType(); 21 if (MIMEType == null || 22 MIMEType.equals("text/plain")) { 23 URL location = file.getLocation(); 24 return this.parseDocument(location); 25 } 26 return false; 27 } 28 29 public boolean parseDocument(URL url) 30 { 31 String fileName = null; 16 32 17 public boolean parseDocument(METSFile file) 18 { 19 String MIMEType = file.getMIMEType(); 20 if (MIMEType == null || 21 MIMEType.equals("text/plain")) { 22 URL location = file.getLocation(); 23 return this.parseDocument(location); 33 if (url.getProtocol().equals("file")) { 34 fileName = url.getPath(); 35 } 36 37 if (fileName != null) { 38 if (fileName.endsWith(".txt") || fileName.endsWith(".text")) { 39 this.listRepository.addDocument(new TextDocument(url)); 40 // TODO: spawn knowledge of children too... 41 System.out.println("Posting text document " + fileName); 42 return true; 43 } 44 } else { // Check MIME type 45 String mimeType = HTTPTools.getMIMEType(url); 46 47 if (mimeType == "text/plain") { 48 System.out.println("Posting Text document " + url.toString()); 49 50 TextDocument doc = new TextDocument(url); 51 this.listRepository.addDocument(doc); 52 return true; 53 } 54 } 55 56 return false; 24 57 } 25 return false;26 }27 28 public boolean parseDocument(URL url)29 { String fileName = null;30 31 if (url.getProtocol().equals("file")) {32 fileName = url.getPath();33 }34 35 if (fileName != null) {36 if (fileName.endsWith(".txt") ||37 fileName.endsWith(".text"))38 { this.listRepository.addDocument(new TextDocument(url));39 // TODO: spawn knowledge of children too...40 System.out.println("Posting text document " + fileName);41 return true;42 }43 }44 else45 { // Check MIME type46 String mimeType = HTTPTools.getMIMEType(url);47 48 if (mimeType == "text/plain")49 { System.out.println("Posting Text document " + url.toString());50 51 TextDocument doc = new TextDocument(url);52 this.listRepository.addDocument(doc);53 return true;54 }55 }56 57 return false;58 }59 58 }
Note:
See TracChangeset
for help on using the changeset viewer.