Changeset 3106


Ignore:
Timestamp:
08/27/07 10:28:46 (13 years ago)
Author:
curtis
Message:

Clean up isThisType(String, boolean) methods a little bit more.

Location:
trunk/loci/formats/in
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/ImprovisionTiffReader.java

    r3054 r3106  
    5555  public boolean isThisType(String name, boolean open) { 
    5656    if (!super.isThisType(name, open)) return false; // check extension 
    57  
    58     if (open) { 
    59       try { 
    60         RandomAccessStream ras = new RandomAccessStream(name); 
    61         Hashtable ifd = TiffTools.getFirstIFD(ras); 
    62         ras.close(); 
    63         if (ifd == null) return false; 
    64  
    65         String comment = 
    66           (String) ifd.get(new Integer(TiffTools.IMAGE_DESCRIPTION)); 
    67         return comment == null ? false : comment.indexOf("Improvision") != -1; 
    68       } 
    69       catch (IOException exc) { 
    70         if (debug) trace(exc); 
    71         return false; 
    72       } 
    73     } 
    74     else return false; 
     57    if (!open) return true; // not allowed to check the file contents 
     58 
     59    // just checking the filename isn't enough to differentiate between 
     60    // Improvision and regular TIFF; open the file and check more thoroughly 
     61    try { 
     62      RandomAccessStream ras = new RandomAccessStream(name); 
     63      Hashtable ifd = TiffTools.getFirstIFD(ras); 
     64      ras.close(); 
     65      if (ifd == null) return false; 
     66 
     67      String comment = 
     68        (String) ifd.get(new Integer(TiffTools.IMAGE_DESCRIPTION)); 
     69      return comment == null ? false : comment.indexOf("Improvision") != -1; 
     70    } 
     71    catch (IOException exc) { 
     72      if (debug) trace(exc); 
     73      return false; 
     74    } 
    7575  } 
    7676 
  • trunk/loci/formats/in/LeicaReader.java

    r3097 r3106  
    228228    if (lname.endsWith(".lei")) return true; 
    229229    else if (!lname.endsWith(".tif") && !lname.endsWith(".tiff")) return false; 
    230     if (!open) return true; // now allowed to be any more thorough 
     230    if (!open) return true; // not allowed to check the file contents 
    231231    if (!isGroupFiles()) return false; 
    232232 
  • trunk/loci/formats/in/OMETiffReader.java

    r3104 r3106  
    5454  public boolean isThisType(String name, boolean open) { 
    5555    if (!super.isThisType(name, open)) return false; // check extension 
     56    if (!open) return true; // not allowed to check the file contents 
    5657 
    5758    // just checking the filename isn't enough to differentiate between 
    5859    // OME-TIFF and regular TIFF; open the file and check more thoroughly 
    59     if (!open) return true; 
    60  
    6160    try { 
    6261      RandomAccessStream ras = new RandomAccessStream(name); 
  • trunk/loci/formats/in/OpenlabReader.java

    r3104 r3106  
    344344      return isThisType(b); 
    345345    } 
    346     else { 
     346    else { // not allowed to check the file contents 
    347347      return name.indexOf(".") < 0; // file appears to have no extension 
    348348    } 
  • trunk/loci/formats/in/TCSReader.java

    r3104 r3106  
    5050  public boolean isThisType(String name, boolean open) { 
    5151    if (!super.isThisType(name, open)) return false; // check extension 
     52    if (!open) return true; // not allowed to check the file contents 
    5253 
    5354    // just checking the filename isn't enough to differentiate between 
    5455    // Leica TCS and regular TIFF; open the file and check more thoroughly 
    55     if (!open) return true; 
    56  
    5756    try { 
    5857      RandomAccessStream ras = new RandomAccessStream(name); 
Note: See TracChangeset for help on using the changeset viewer.