Last change
on this file since 12188 was 12188, checked in by kjdon, 18 years ago |
Initial revision
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.2 KB
|
Rev | Line | |
---|
[12188] | 1 | package org.greenstone.gsdl3.gs3build.doctypes;
|
---|
| 2 |
|
---|
| 3 | import java.io.*;
|
---|
| 4 | import java.net.*;
|
---|
| 5 | import java.util.ArrayList;
|
---|
| 6 |
|
---|
| 7 | import org.greenstone.gsdl3.gs3build.metadata.*;
|
---|
| 8 |
|
---|
| 9 | public class IndexRecogniser extends AbstractRecogniser
|
---|
| 10 | {
|
---|
| 11 |
|
---|
| 12 | public IndexRecogniser(DocumentList listRepository)
|
---|
| 13 | {
|
---|
| 14 | this.preferred_mime_type = "text/plain";
|
---|
| 15 | this.filename_extensions = new ArrayList();
|
---|
| 16 | this.filename_extensions.add("index.txt");
|
---|
| 17 | this.document_type = IndexDocument.INDEX_DOCUMENT_TYPE;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | public boolean parseDocument(URL url)
|
---|
| 22 | {
|
---|
| 23 | String filename = null;
|
---|
| 24 |
|
---|
| 25 | if (url.getProtocol().equals("file")) {
|
---|
| 26 | filename = url.getPath();
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | if (filename != null) {
|
---|
| 30 | String leafName;
|
---|
| 31 | int leafAt = filename.lastIndexOf(File.separator);
|
---|
| 32 | if (leafAt >= 0) {
|
---|
| 33 | leafName = filename.substring(leafAt+1);
|
---|
| 34 | } else {
|
---|
| 35 | leafName = filename;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | if (leafName.equals("index.txt")) {
|
---|
| 39 |
|
---|
| 40 | System.out.println("Posting Index Document " + filename);
|
---|
| 41 | IndexDocument doc = new IndexDocument(url);
|
---|
| 42 | this.list_repository.addDocument(doc);
|
---|
| 43 | // TODO: spawn knowledge of children too...
|
---|
| 44 | // System.out.println(doc.getDocumentText());
|
---|
| 45 | return true;
|
---|
| 46 | }
|
---|
| 47 | } else {
|
---|
| 48 | // TODO: get Mime type remotely, and then proceed if required
|
---|
| 49 | }
|
---|
| 50 | return false;
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.