Ignore:
Timestamp:
2003-11-24T14:26:35+13:00 (20 years ago)
Author:
cs025
Message:

Index document type, metadata extensions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/TextRecogniser.java

    r5800 r5944  
    55
    66import org.greenstone.gsdl3.gs3build.metadata.*;
     7import org.greenstone.gsdl3.gs3build.util.HTTPTools;
    78
    89public class TextRecogniser implements RecogniserInterface
    910{
    10     DocumentList listRepository;
     11  DocumentList listRepository;
     12 
     13  public TextRecogniser(DocumentList listRepository)
     14  { this.listRepository = listRepository;
     15  }
    1116
    12     public TextRecogniser(DocumentList listRepository)
    13     {   this.listRepository = listRepository;
    14     }
     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  }
    1527
    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     }
     28  public boolean parseDocument(URL url)
     29  { String fileName = null;
    2630
    27     public boolean parseDocument(URL url)
    28     {   if (url.toString().startsWith("file://")) {
    29             String fileName = url.toString().substring(7);
     31    if (url.toString().startsWith("file://")) {
     32      fileName = url.toString().substring(7);
     33    }
     34    else if (url.toString().startsWith("file:/")) {
     35      fileName = url.toString().substring(5);
     36    }
    3037
    31             if (fileName.endsWith(".txt") ||
    32               fileName.endsWith(".text"))
    33             {   this.listRepository.addDocument(new TextDocument(url));
    34                 // TODO: spawn knowledge of children too...
    35                 System.out.println(">>> Posting text document " + fileName);
    36                 return true;
    37             }
    38         }
    39         else
    40         {   // Check MIME type
    41         }
     38    if (fileName != null) {
     39      if (fileName.endsWith(".txt") ||
     40      fileName.endsWith(".text"))
     41      { this.listRepository.addDocument(new TextDocument(url));
     42    // TODO: spawn knowledge of children too...
     43        System.out.println(">>> Posting text document " + fileName);
     44    return true;
     45      }
     46    }
     47    else
     48    { // Check MIME type
     49      String mimeType = HTTPTools.getMIMEType(url);
     50
     51      if (mimeType == "text/plain")
     52      { System.out.println("Posting Text document " + url.toString());
     53     
     54        TextDocument doc = new TextDocument(url);
     55    this.listRepository.addDocument(doc);
     56    return true;
     57      }
     58    }
    4259       
    43         return false;
    44     }
     60    return false;
     61  }
    4562}
Note: See TracChangeset for help on using the changeset viewer.