Changeset 8484
- Timestamp:
- 2004-11-08T15:56:35+13:00 (19 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/GMLRecogniser.java
r7466 r8484 1 1 package org.greenstone.gsdl3.gs3build.doctypes; 2 2 3 3 4 import java.io.*; … … 8 9 public class GMLRecogniser implements RecogniserInterface 9 10 { 10 DocumentList listRepository; 11 12 public GMLRecogniser(DocumentList listRepository) 13 { this.listRepository = listRepository; 11 DocumentList listRepository; 12 13 public GMLRecogniser(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/xml")) { 23 URL location = file.getLocation(); 24 return this.parseDocument(location); 25 } 26 return false; 14 27 } 15 28 16 public boolean parseDocument(METSFile file) 17 { 18 String MIMEType = file.getMIMEType(); 19 if (MIMEType == null || 20 MIMEType.equals("text/xml")) { 21 URL location = file.getLocation(); 22 return this.parseDocument(location); 29 public boolean parseDocument(URL url) 30 { 31 if (url.getProtocol().equals("file")) { 32 String fileName = url.getPath(); 33 if (fileName.endsWith(".gml")) { 34 35 System.out.println("Posting GML Document " + fileName); 36 GMLDocument doc = new GMLDocument(url); 37 this.listRepository.addDocument(doc); 38 // TODO: spawn knowledge of children too... 39 // System.out.println(doc.getDocumentText()); 40 return true; 41 } 42 } else { 43 // TODO: get Mime type remotely, and then proceed if required 44 } 45 return false; 23 46 } 24 return false;25 }26 27 public boolean parseDocument(URL url)28 { if (url.getProtocol().equals("file")) {29 String fileName = url.getPath();30 if (fileName.endsWith(".gml"))31 {32 System.out.println("Posting GML Document " + fileName);33 GMLDocument doc = new GMLDocument(url);34 this.listRepository.addDocument(doc);35 // TODO: spawn knowledge of children too...36 // System.out.println(doc.getDocumentText());37 return true;38 }39 }40 else {41 // TODO: get Mime type remotely, and then proceed if required42 }43 return false;44 }45 47 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/HTMLRecogniser.java
r6452 r8484 9 9 public class HTMLRecogniser implements RecogniserInterface 10 10 { 11 DocumentList listRepository; 12 13 public HTMLRecogniser(DocumentList listRepository) 14 { this.listRepository = listRepository; 15 } 16 17 public boolean parseDocument(METSFile file) 18 { 19 String MIMEType = file.getMIMEType(); 20 if (MIMEType == null || 21 MIMEType.equals("text/html")) { 22 URL location = file.getLocation(); 23 return this.parseDocument(location); 11 DocumentList listRepository; 12 13 public HTMLRecogniser(DocumentList listRepository) 14 { 15 this.listRepository = listRepository; 24 16 } 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(); 17 18 public boolean parseDocument(METSFile file) 19 { 20 String MIMEType = file.getMIMEType(); 21 if (MIMEType == null || 22 MIMEType.equals("text/html")) { 23 URL location = file.getLocation(); 24 return this.parseDocument(location); 25 } 26 return false; 33 27 } 34 28 35 if (fileName != null) { 36 if (fileName.endsWith(".htm") || 37 fileName.endsWith(".html")) 38 { System.out.println("Posting HTML Document " + fileName); 29 public boolean parseDocument(URL url) 30 { 31 String fileName = null; 39 32 40 HTMLDocument doc = new HTMLDocument(url); 41 this.listRepository.addDocument(doc); 42 return true; 43 } 33 if (url.getProtocol().equals("file")) { 34 fileName = url.getPath(); 35 } 36 37 if (fileName != null) { 38 if (fileName.endsWith(".htm") || 39 fileName.endsWith(".html")) { 40 41 System.out.println("Posting HTML Document " + fileName); 42 43 HTMLDocument doc = new HTMLDocument(url); 44 this.listRepository.addDocument(doc); 45 return true; 46 } 47 } else { 48 // Get Mime type remotely, and then proceed if required 49 String mimeType = HTTPTools.getMIMEType(url); 50 51 if (mimeType == "text/html") { 52 System.out.println("Posting HTML Document " + url.toString()); 53 54 HTMLDocument doc = new HTMLDocument(url); 55 this.listRepository.addDocument(doc); 56 return true; 57 } 58 } 59 return false; 44 60 } 45 else {46 // Get Mime type remotely, and then proceed if required47 String mimeType = HTTPTools.getMIMEType(url);48 49 if (mimeType == "text/html")50 { System.out.println("Posting HTML Document " + url.toString());51 52 HTMLDocument doc = new HTMLDocument(url);53 this.listRepository.addDocument(doc);54 return true;55 }56 }57 return false;58 }59 61 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/IndexRecogniser.java
r7466 r8484 8 8 public class IndexRecogniser implements RecogniserInterface 9 9 { 10 DocumentList listRepository; 11 12 public IndexRecogniser(DocumentList listRepository) 13 { this.listRepository = listRepository; 14 } 15 16 public boolean parseDocument(METSFile file) 17 { 18 String MIMEType = file.getMIMEType(); 19 if (MIMEType == null || 20 MIMEType.equals("text/plain")) { 21 URL location = file.getLocation(); 22 return this.parseDocument(location); 23 } 24 return false; 25 } 26 27 public boolean parseDocument(URL url) 28 { String fileName = null; 29 30 if (url.getProtocol().equals("file")) 31 { fileName = url.getPath(); 10 DocumentList listRepository; 11 12 public IndexRecogniser(DocumentList listRepository) 13 { 14 this.listRepository = listRepository; 32 15 } 33 16 34 if (fileName != null) { 35 String leafName; 36 int leafAt = fileName.lastIndexOf(File.separator); 37 if (leafAt >= 0) { 38 leafName = fileName.substring(leafAt+1); 39 } 40 else { 41 leafName = fileName; 42 } 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); 24 } 25 return false; 26 } 43 27 44 if (leafName.equals("index.txt")) 45 { 46 System.out.println("Posting Index Document " + fileName); 47 IndexDocument doc = new IndexDocument(url); 48 this.listRepository.addDocument(doc); 49 // TODO: spawn knowledge of children too... 50 // System.out.println(doc.getDocumentText()); 51 return true; 52 } 28 public boolean parseDocument(URL url) 29 { 30 String fileName = null; 31 32 if (url.getProtocol().equals("file")) { 33 fileName = url.getPath(); 34 } 35 36 if (fileName != null) { 37 String leafName; 38 int leafAt = fileName.lastIndexOf(File.separator); 39 if (leafAt >= 0) { 40 leafName = fileName.substring(leafAt+1); 41 } else { 42 leafName = fileName; 43 } 44 45 if (leafName.equals("index.txt")) { 46 47 System.out.println("Posting Index Document " + fileName); 48 IndexDocument doc = new IndexDocument(url); 49 this.listRepository.addDocument(doc); 50 // TODO: spawn knowledge of children too... 51 // System.out.println(doc.getDocumentText()); 52 return true; 53 } 54 } else { 55 // TODO: get Mime type remotely, and then proceed if required 56 } 57 return false; 53 58 } 54 else {55 // TODO: get Mime type remotely, and then proceed if required56 }57 return false;58 }59 59 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/JPEGRecogniser.java
r7189 r8484 8 8 public class JPEGRecogniser implements RecogniserInterface 9 9 { 10 DocumentList listRepository; 11 12 public JPEGRecogniser(DocumentList listRepository) 13 { this.listRepository = listRepository; 14 } 15 16 public boolean parseDocument(METSFile file) 17 { 18 String MIMEType = file.getMIMEType(); 19 if (MIMEType == null || 20 MIMEType.equals("image/jpeg")) { 21 URL location = file.getLocation(); 22 return this.parseDocument(location); 23 } 24 return false; 25 } 26 27 public boolean parseDocument(URL url) 28 { if (url.getProtocol().equals("file")) { 29 String fileName = url.getPath(); 30 31 if (fileName != null && 32 (fileName.endsWith(".jpg") || 33 fileName.endsWith(".jpeg"))) 34 { System.out.println("Posting jpeg document " + url.toString()); 35 this.listRepository.addDocument(new JPEGDocument(url)); 36 // TODO: spawn knowledge of children too... 37 return true; 38 } 39 } 40 else 41 { // TODO: get Mime type remotely, and then proceed if required 10 DocumentList listRepository; 11 12 public JPEGRecogniser(DocumentList listRepository) 13 { 14 this.listRepository = listRepository; 42 15 } 43 16 44 return false; 45 } 46 17 public boolean parseDocument(METSFile file) 18 { 19 String MIMEType = file.getMIMEType(); 20 if (MIMEType == null || 21 MIMEType.equals("image/jpeg")) { 22 URL location = file.getLocation(); 23 return this.parseDocument(location); 24 } 25 return false; 26 } 27 28 public boolean parseDocument(URL url) 29 { 30 if (url.getProtocol().equals("file")) { 31 String fileName = url.getPath(); 32 33 if (fileName != null && 34 (fileName.endsWith(".jpg") || 35 fileName.endsWith(".jpeg"))) { 36 System.out.println("Posting jpeg document " + url.toString()); 37 this.listRepository.addDocument(new JPEGDocument(url)); 38 // TODO: spawn knowledge of children too... 39 return true; 40 } 41 } else { 42 // TODO: get Mime type remotely, and then proceed if required 43 } 44 45 return false; 46 } 47 47 48 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/MetadataRecogniser.java
r6452 r8484 8 8 public class MetadataRecogniser implements RecogniserInterface 9 9 { 10 DocumentList listRepository; 11 12 public MetadataRecogniser(DocumentList listRepository) 13 { this.listRepository = listRepository; 14 } 15 16 public boolean parseDocument(METSFile file) 17 { 18 String MIMEType = file.getMIMEType(); 19 if (MIMEType == null || 20 MIMEType.equals("text/xml")) { 21 URL location = file.getLocation(); 22 return this.parseDocument(location); 23 } 24 return false; 25 } 26 27 public boolean parseDocument(URL url) 28 { String fileName = null; 29 30 if (url.getProtocol().equals("file")) { 31 fileName = url.getPath(); 10 DocumentList listRepository; 11 12 public MetadataRecogniser(DocumentList listRepository) 13 { 14 this.listRepository = listRepository; 32 15 } 33 16 34 if (fileName != null) 35 { if (fileName.endsWith(File.separatorChar + "metadata.xml")) 36 { 37 System.out.println("Posting Metadata Document " + fileName); 38 MetadataDocument doc = new MetadataDocument(url); 39 this.listRepository.addDocument(doc); 40 // TODO: spawn knowledge of children too... 41 // System.out.println(doc.getDocumentText()); 42 return true; 43 } 17 public boolean parseDocument(METSFile file) 18 { 19 String MIMEType = file.getMIMEType(); 20 if (MIMEType == null || 21 MIMEType.equals("text/xml")) { 22 URL location = file.getLocation(); 23 return this.parseDocument(location); 24 } 25 return false; 44 26 } 45 else { 46 // TODO: get Mime type remotely, and then proceed if required 27 28 public boolean parseDocument(URL url) 29 { 30 String fileName = null; 31 32 if (url.getProtocol().equals("file")) { 33 fileName = url.getPath(); 34 } 35 36 if (fileName != null) { 37 if (fileName.endsWith(File.separatorChar + "metadata.xml")) { 38 39 System.out.println("Posting Metadata Document " + fileName); 40 MetadataDocument doc = new MetadataDocument(url); 41 this.listRepository.addDocument(doc); 42 // TODO: spawn knowledge of children too... 43 // System.out.println(doc.getDocumentText()); 44 return true; 45 } 46 } else { 47 // TODO: get Mime type remotely, and then proceed if required 48 } 49 return false; 47 50 } 48 return false;49 }50 51 } -
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.