Changeset 6333


Ignore:
Timestamp:
05/18/10 13:07:47 (10 years ago)
Author:
melissa
Message:
  • Removed hopefully obsolete hack from RandomAccessInputStream.findString. See  omero:2374.
  • Adjusted ClassList.removeClass signature, so that reader classes can actually be removed.
  • Adjusted NRRDReader's delegation logic to be a little more straightforward.
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/components/bio-formats/src/loci/formats/ClassList.java

    r6142 r6333  
    155155 
    156156  /** Removes the given class from the list. */ 
    157   public void removeClass(Class<T> c) { 
     157  public void removeClass(Class<? extends T> c) { 
    158158    classes.remove(c); 
    159159  } 
  • branches/4.2/components/bio-formats/src/loci/formats/in/NRRDReader.java

    r6301 r6333  
    2424package loci.formats.in; 
    2525 
    26 import java.io.File; 
    2726import java.io.IOException; 
    28 import java.util.StringTokenizer; 
    2927 
    3028import loci.common.Location; 
    3129import loci.common.RandomAccessInputStream; 
     30import loci.formats.ClassList; 
    3231import loci.formats.FormatException; 
    3332import loci.formats.FormatReader; 
    3433import loci.formats.FormatTools; 
     34import loci.formats.IFormatReader; 
    3535import loci.formats.ImageReader; 
    3636import loci.formats.MetadataTools; 
     
    160160 
    161161    in = new RandomAccessInputStream(id); 
    162     helper = new ImageReader(); 
     162 
     163    ClassList<IFormatReader> classes = ImageReader.getDefaultReaderClasses(); 
     164    classes.removeClass(getClass()); 
     165    helper = new ImageReader(classes); 
    163166 
    164167    String key, v; 
     
    203206        } 
    204207        else if (key.equals("sizes")) { 
    205           StringTokenizer tokens = new StringTokenizer(v, " "); 
     208          String[] tokens = v.split(" "); 
    206209          for (int i=0; i<numDimensions; i++) { 
    207             String t = tokens.nextToken(); 
    208             int size = Integer.parseInt(t); 
     210            int size = Integer.parseInt(tokens[i]); 
    209211 
    210212            if (numDimensions >= 3 && i == 0 && size > 1 && size <= 4) { 
     
    253255        dataFile = new Location(parent, dataFile).getAbsolutePath(); 
    254256      } 
    255       // calling setId on dataFile will cause this reader to pick up 
    256       // the data file 
    257       String name = dataFile.substring(dataFile.lastIndexOf(File.separator)); 
    258       Location.mapId(name, dataFile); 
    259       helper.setId(name); 
     257      helper.setId(dataFile); 
    260258    } 
    261259 
  • branches/4.2/components/common/src/loci/common/RandomAccessInputStream.java

    r6227 r6333  
    219219    } 
    220220 
    221     // ensure that we don't try to read more bytes than are in the file 
    222     if (blockSize > maxLen / 2) { 
    223       blockSize = (int) maxLen / 2; 
    224     } 
    225  
    226221    InputStreamReader in = new InputStreamReader(this); 
    227222    char[] buf = new char[blockSize]; 
  • trunk/components/bio-formats/src/loci/formats/ClassList.java

    r6142 r6333  
    155155 
    156156  /** Removes the given class from the list. */ 
    157   public void removeClass(Class<T> c) { 
     157  public void removeClass(Class<? extends T> c) { 
    158158    classes.remove(c); 
    159159  } 
  • trunk/components/bio-formats/src/loci/formats/in/NRRDReader.java

    r6301 r6333  
    2424package loci.formats.in; 
    2525 
    26 import java.io.File; 
    2726import java.io.IOException; 
    28 import java.util.StringTokenizer; 
    2927 
    3028import loci.common.Location; 
    3129import loci.common.RandomAccessInputStream; 
     30import loci.formats.ClassList; 
    3231import loci.formats.FormatException; 
    3332import loci.formats.FormatReader; 
    3433import loci.formats.FormatTools; 
     34import loci.formats.IFormatReader; 
    3535import loci.formats.ImageReader; 
    3636import loci.formats.MetadataTools; 
     
    160160 
    161161    in = new RandomAccessInputStream(id); 
    162     helper = new ImageReader(); 
     162 
     163    ClassList<IFormatReader> classes = ImageReader.getDefaultReaderClasses(); 
     164    classes.removeClass(getClass()); 
     165    helper = new ImageReader(classes); 
    163166 
    164167    String key, v; 
     
    203206        } 
    204207        else if (key.equals("sizes")) { 
    205           StringTokenizer tokens = new StringTokenizer(v, " "); 
     208          String[] tokens = v.split(" "); 
    206209          for (int i=0; i<numDimensions; i++) { 
    207             String t = tokens.nextToken(); 
    208             int size = Integer.parseInt(t); 
     210            int size = Integer.parseInt(tokens[i]); 
    209211 
    210212            if (numDimensions >= 3 && i == 0 && size > 1 && size <= 4) { 
     
    253255        dataFile = new Location(parent, dataFile).getAbsolutePath(); 
    254256      } 
    255       // calling setId on dataFile will cause this reader to pick up 
    256       // the data file 
    257       String name = dataFile.substring(dataFile.lastIndexOf(File.separator)); 
    258       Location.mapId(name, dataFile); 
    259       helper.setId(name); 
     257      helper.setId(dataFile); 
    260258    } 
    261259 
  • trunk/components/common/src/loci/common/RandomAccessInputStream.java

    r6227 r6333  
    219219    } 
    220220 
    221     // ensure that we don't try to read more bytes than are in the file 
    222     if (blockSize > maxLen / 2) { 
    223       blockSize = (int) maxLen / 2; 
    224     } 
    225  
    226221    InputStreamReader in = new InputStreamReader(this); 
    227222    char[] buf = new char[blockSize]; 
Note: See TracChangeset for help on using the changeset viewer.