Changeset 8484


Ignore:
Timestamp:
2004-11-08T15:56:35+13:00 (19 years ago)
Author:
kjdon
Message:

just formatting changes in preparation for my changes

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  
    11package org.greenstone.gsdl3.gs3build.doctypes;
     2
    23
    34import java.io.*;
     
    89public class GMLRecogniser implements RecogniserInterface
    910{
    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;
    1427  }
    1528
    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;
    2346    }
    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 required
    42     }
    43     return false;
    44   }
    4547}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/HTMLRecogniser.java

    r6452 r8484  
    99public class HTMLRecogniser implements RecogniserInterface
    1010{
    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;
    2416    }
    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;
    3327    }
    3428
    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;
    3932
    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;
    4460    }
    45     else {
    46       // Get Mime type remotely, and then proceed if required
    47       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   }
    5961}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/IndexRecogniser.java

    r7466 r8484  
    88public class IndexRecogniser implements RecogniserInterface
    99{
    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;
    3215    }
    3316   
    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    }
    4327
    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;
    5358    }
    54     else {
    55       // TODO: get Mime type remotely, and then proceed if required
    56     }
    57     return false;
    58   }
    5959}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/JPEGRecogniser.java

    r7189 r8484  
    88public class JPEGRecogniser implements RecogniserInterface
    99{
    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;
    4215    }
    4316
    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   
    4748}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/MetadataRecogniser.java

    r6452 r8484  
    88public class MetadataRecogniser implements RecogniserInterface
    99{
    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;
    3215    }
    3316
    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;
    4426    }
    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;
    4750    }
    48     return false;
    49   }
    5051}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/TextRecogniser.java

    r8422 r8484  
    99public class TextRecogniser implements RecogniserInterface
    1010{
    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;
    1632
    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;
    2457    }
    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     else
    45     { // Check MIME type
    46       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   }
    5958}
Note: See TracChangeset for help on using the changeset viewer.