Changeset 2117


Ignore:
Timestamp:
01/17/07 16:41:53 (13 years ago)
Author:
melissa
Message:

Replaced FileWrapper logic with new Location class. This provides an API similar
to java.io.File, but without the issues incurred by overriding java.io.File.
Also moved all id mapping logic to this class, and adapted all readers to use it.

Location:
trunk/loci
Files:
1 added
1 deleted
56 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/AxisGuesser.java

    r2078 r2117  
    2525package loci.formats; 
    2626 
    27 import java.io.File; 
    2827import java.io.IOException; 
    2928import java.math.BigInteger; 
     
    282281  /** Method for testing pattern guessing logic. */ 
    283282  public static void main(String[] args) throws FormatException, IOException { 
    284     File file = args.length < 1 ? 
    285       new FileWrapper(System.getProperty("user.dir")).listFiles()[0] : 
    286       new FileWrapper(args[0]); 
     283    Location file = args.length < 1 ? 
     284      new Location(System.getProperty("user.dir")).listFiles()[0] : 
     285      new Location(args[0]); 
    287286    System.out.println("File = " + file.getAbsoluteFile()); 
    288287    String pat = FilePattern.findPattern(file); 
     
    294293        System.out.println("Pattern is valid."); 
    295294        String id = fp.getFiles()[0]; 
    296         if (!new FileWrapper(id).exists()) { 
     295        if (!new Location(id).exists()) { 
    297296          System.out.println("File '" + id + "' does not exist."); 
    298297        } 
  • trunk/loci/formats/FilePattern.java

    r2078 r2117  
    8787 
    8888  /** Creates a pattern object using the given file as a template. */ 
    89   public FilePattern(File file) { this(FilePattern.findPattern(file)); } 
     89  public FilePattern(Location file) { this(FilePattern.findPattern(file)); } 
    9090 
    9191  /** 
     
    288288   * @param file The file to use as a template for the match. 
    289289   */ 
    290   public static String findPattern(File file) { 
     290  public static String findPattern(Location file) { 
    291291    return findPattern(file.getName(), file.getAbsoluteFile().getParent()); 
    292292  } 
     
    302302      dir += File.separator; 
    303303    } 
    304     File dirFile = new FileWrapper(dir.equals("") ? "." : dir); 
     304    Location dirFile = new Location(dir.equals("") ? "." : dir); 
    305305 
    306306    // list files in the given directory 
    307     File[] f = dirFile.listFiles(); 
     307    Location[] f = dirFile.listFiles(); 
    308308    if (f == null) return null; 
    309309    String[] nameList = new String[f.length]; 
     
    538538    if (args.length > 0) { 
    539539      // test file pattern detection based on the given file on disk 
    540       File file = new FileWrapper(args[0]); 
     540      Location file = new Location(args[0]); 
    541541      System.out.println("File = " + file.getAbsoluteFile()); 
    542542      pat = findPattern(file); 
  • trunk/loci/formats/FileStitcher.java

    r2104 r2117  
    184184    if (!patternIds) { 
    185185      // find the containing pattern 
    186       Hashtable map = getIdMap(); 
     186      Hashtable map = Location.getIdMap(); 
    187187      String pattern = null; 
    188188      if (map.containsKey(id)) { 
     
    198198        // id is an unmapped file path; look to similar files on disk 
    199199 
    200         // id == getMapped(id) 
    201         pattern = FilePattern.findPattern(new FileWrapper(id)); 
     200        pattern = FilePattern.findPattern(new Location(id)); 
    202201      } 
    203202      if (pattern != null) id = pattern; 
     
    573572  } 
    574573 
    575   /* @see IFormatHandler#mapId(String, String) */ 
    576   public void mapId(String id, String filename) { 
    577     // NB: all readers share the same ID map 
    578     reader.mapId(id, filename); 
    579   } 
    580  
    581   /* @see IFormatHandler#getMappedId(String) */ 
    582   public String getMappedId(String id) { 
    583     return reader.getMappedId(id); 
    584   } 
    585  
    586   /* @see IFormatHandler#getIdMap() */ 
    587   public Hashtable getIdMap() { 
    588     return reader.getIdMap(); 
    589   } 
    590  
    591   /* @see IFormatHandler#setIdMap(Hashtable) */ 
    592   public void setIdMap(Hashtable map) { 
    593     for (int i=0; i<readers.length; i++) readers[i].setIdMap(map); 
    594   } 
    595  
    596574  // -- Helper methods -- 
    597575 
     
    618596    } 
    619597    for (int i=0; i<files.length; i++) { 
    620       if (!new FileWrapper(getMappedId(files[i])).exists()) { 
     598      if (!new Location(files[i]).exists()) { 
    621599        throw new FormatException("File #" + i + 
    622600          " (" + files[i] + ") does not exist."); 
     
    637615    readers = new IFormatReader[files.length]; 
    638616    readers[0] = reader; 
    639     Hashtable map = reader.getIdMap(); 
    640617    for (int i=1; i<readers.length; i++) { 
    641618      // use crazy reflection to instantiate a reader of the proper type 
     
    651628        } 
    652629        readers[i] = (IFormatReader) r; 
    653         // NB: ensure all readers share the same ID map 
    654         readers[i].setIdMap(map); 
    655630      } 
    656631      catch (InstantiationException exc) { exc.printStackTrace(); } 
  • trunk/loci/formats/FormatHandler.java

    r1786 r2117  
    2626 
    2727import java.lang.reflect.InvocationTargetException; 
    28 import java.util.Hashtable; 
    2928import javax.swing.JFileChooser; 
    3029import javax.swing.SwingUtilities; 
     
    4140  /** Valid suffixes for this file format. */ 
    4241  protected String[] suffixes; 
    43  
    44   /** Map from given filenames to actual filenames. */ 
    45   protected Hashtable idMap; 
    4642 
    4743  /** File filters for this file format, for use with a JFileChooser. */ 
     
    6561    this.format = format; 
    6662    this.suffixes = suffixes == null ? new String[0] : suffixes; 
    67     idMap = new Hashtable(); 
    6863  } 
    6964 
     
    111106    if (chooser == null) chooser = buildFileChooser(getFileFilters()); 
    112107    return chooser; 
    113   } 
    114  
    115   /* @see IFormatHandler#mapId(String, String) */ 
    116   public void mapId(String id, String filename) { 
    117     if (id == null) return; 
    118     if (filename == null) idMap.remove(id); 
    119     else idMap.put(id, filename); 
    120   } 
    121  
    122   /* @see IFormatHandler#getMappedId(String) */ 
    123   public String getMappedId(String id) { 
    124     String filename = id == null ? null : (String) idMap.get(id); 
    125     return filename == null ? id : filename; 
    126   } 
    127  
    128   /* @see IFormatHandler#getIdMap() */ 
    129   public Hashtable getIdMap() { 
    130     return idMap; 
    131   } 
    132  
    133   /* @see IFormatHandler#setIdMap(Hashtable) */ 
    134   public void setIdMap(Hashtable map) { 
    135     idMap = map; 
    136108  } 
    137109 
  • trunk/loci/formats/FormatReader.java

    r2110 r2117  
    577577      return false; 
    578578    } 
    579     if (map != null) reader.mapId(id, map); 
     579    if (map != null) Location.mapId(id, map); 
    580580    if (omexml) { 
    581581      try { 
     
    604604      reader = new FileStitcher(reader, true); 
    605605      String pat = 
    606         FilePattern.findPattern(new FileWrapper(map == null ? id : map)); 
     606        FilePattern.findPattern(new Location(map == null ? id : map)); 
    607607      if (pat != null) id = pat; 
    608608    } 
  • trunk/loci/formats/IFormatHandler.java

    r1786 r2117  
    2525package loci.formats; 
    2626 
    27 import java.util.Hashtable; 
    2827import javax.swing.JFileChooser; 
    2928import javax.swing.filechooser.FileFilter; 
     
    5352  /** Gets a JFileChooser that recognizes accepted file types. */ 
    5453  JFileChooser getFileChooser(); 
    55  
    56   /** 
    57    * Maps the given id to the actual filename on disk. Typically actual 
    58    * filenames are used for ids, making this step unnecessary, but in some 
    59    * cases it is useful; e.g., if the file has been renamed to conform to a 
    60    * standard naming scheme and the original file extension is lost, then using 
    61    * the original filename as the id assists format handlers with type 
    62    * identification and pattern matching, and the id can be mapped to the 
    63    * actual filename for reading the file's contents. 
    64    * @see #getMappedId(String) 
    65    */ 
    66   void mapId(String id, String filename); 
    67  
    68   /** 
    69    * Gets the actual filename on disk for the given id. Typically the id itself 
    70    * is the filename, but in some cases may not be; e.g., if OMEIS has renamed 
    71    * a file from its original name to a standard location such as Files/101, 
    72    * the original filename is useful for checking the file extension and doing 
    73    * pattern matching, but the renamed filename is required to read its 
    74    * contents. 
    75    * @see #mapId(String, String) 
    76    */ 
    77   String getMappedId(String id); 
    78  
    79   /** 
    80    * Gets a hashtable containing mappings from ids to actual filenames on disk. 
    81    * @see #mapId(String, String) 
    82    * @see #getMappedId(String) 
    83    */ 
    84   Hashtable getIdMap(); 
    85  
    86   /** 
    87    * Sets the mappings from ids to actual filenames on disk to match those 
    88    * given in the. 
    89    * @see #mapId(String, String) 
    90    * @see #getMappedId(String) 
    91    */ 
    92   void setIdMap(Hashtable map); 
    93  
    9454} 
  • trunk/loci/formats/ImageReader.java

    r2053 r2117  
    123123    // add built-in readers to the list 
    124124    Vector v = new Vector(); 
    125     Hashtable map = null; 
    126125    for (int i=0; i<readerClasses.size(); i++) { 
    127126      Class readerClass = (Class) readerClasses.elementAt(i); 
     
    129128      try { 
    130129        reader = (IFormatReader) readerClass.newInstance(); 
    131         // NB: ensure all readers share the same ID map 
    132         if (i == 0) map = reader.getIdMap(); 
    133         else reader.setIdMap(map); 
    134130      } 
    135131      catch (IllegalAccessException exc) { } 
     
    511507    } 
    512508    return chooser; 
    513   } 
    514  
    515   /* @see IFormatHandler#mapId(String, String) */ 
    516   public void mapId(String id, String filename) { 
    517     // NB: all readers share the same ID map 
    518     readers[0].mapId(id, filename); 
    519   } 
    520  
    521   /* @see IFormatHandler#getMappedId(String) */ 
    522   public String getMappedId(String id) { 
    523     return readers[0].getMappedId(id); 
    524   } 
    525  
    526   /* @see IFormatHandler.getIdMap() */ 
    527   public Hashtable getIdMap() { 
    528     return readers[0].getIdMap(); 
    529   } 
    530  
    531   /* @see IFormatHandler.setIdMap(Hashtable) */ 
    532   public void setIdMap(Hashtable map) { 
    533     for (int i=0; i<readers.length; i++) readers[i].setIdMap(map); 
    534509  } 
    535510 
  • trunk/loci/formats/ImageViewer.java

    r2078 r2117  
    180180    wait(true); 
    181181    try { 
    182       File f = new FileWrapper(id); 
     182      Location f = new Location(id); 
    183183      id = f.getAbsolutePath(); 
    184184      int num = myReader.getImageCount(id); 
  • trunk/loci/formats/ImageWriter.java

    r2001 r2117  
    123123    // add built-in writers to the list 
    124124    Vector v = new Vector(); 
    125     Hashtable map = null; 
    126125    for (int i=0; i<writerClasses.size(); i++) { 
    127126      Class writerClass = (Class) writerClasses.elementAt(i); 
     
    129128      try { 
    130129        writer = (FormatWriter) writerClass.newInstance(); 
    131         // NB: ensure all writers share the same ID map 
    132         if (i == 0) map = writer.getIdMap(); 
    133         else writer.setIdMap(map); 
    134130      } 
    135131      catch (IllegalAccessException exc) { } 
     
    320316  } 
    321317 
    322   /* @see IFormatHandler#mapId(String, String) */ 
    323   public void mapId(String id, String filename) { 
    324     // NB: all writers share the same ID map 
    325     writers[0].mapId(id, filename); 
    326   } 
    327  
    328   /* @see IFormatHandler#getMappedId(String) */ 
    329   public String getMappedId(String id) { 
    330     return writers[0].getMappedId(id); 
    331   } 
    332  
    333   /* @see IFormatHandler.getIdMap() */ 
    334   public Hashtable getIdMap() { 
    335     return writers[0].getIdMap(); 
    336   } 
    337  
    338   /* @see IFormatHandler.setIdMap(Hashtable) */ 
    339   public void setIdMap(Hashtable map) { 
    340     for (int i=0; i<writers.length; i++) writers[i].setIdMap(map); 
    341   } 
    342  
    343318  // -- Static ImageWriter API methods -- 
    344319 
  • trunk/loci/formats/LegacyQTTools.java

    r2078 r2117  
    2828import java.awt.image.DirectColorModel; 
    2929import java.awt.image.MemoryImageSource; 
    30 import java.io.File; 
    3130import java.net.*; 
    3231import java.util.StringTokenizer; 
     
    7877 
    7978    while (st.hasMoreTokens()) { 
    80       File f = new FileWrapper(st.nextToken(), "QTJava.zip"); 
     79      Location f = new Location(st.nextToken(), "QTJava.zip"); 
    8180      if (f.exists()) { 
    8281        try { 
  • trunk/loci/formats/OmeisImporter.java

    r2036 r2117  
    8787      ids[i] = (String) fileInfo.get("Name"); 
    8888      String path = getLocalFilePath(fileIds[i]); 
    89       reader.mapId(ids[i], path); 
     89      Location.mapId(ids[i], path); 
    9090    } 
    9191 
     
    138138      ids[i] = (String) fileInfo.get("Name"); 
    139139      String path = getLocalFilePath(fileIds[i]); 
    140       reader.mapId(ids[i], path); 
     140      Location.mapId(ids[i], path); 
    141141    } 
    142142 
    143143    // read file group 
    144144    String id = ids[0]; 
    145     String path = reader.getMappedId(ids[0]); 
     145    String path = Location.getMappedId(ids[0]); 
    146146    if (DEBUG) log("Reading file '" + id + "' --> " + path); 
    147147 
  • trunk/loci/formats/ReaderWrapper.java

    r2053 r2117  
    288288  } 
    289289 
    290   public void mapId(String id, String filename) { 
    291     reader.mapId(id, filename); 
    292   } 
    293  
    294   public String getMappedId(String id) { 
    295     return reader.getMappedId(id); 
    296   } 
    297  
    298   public Hashtable getIdMap() { 
    299     return reader.getIdMap(); 
    300   } 
    301  
    302   public void setIdMap(Hashtable map) { 
    303     reader.setIdMap(map); 
    304   } 
    305  
    306290} 
  • trunk/loci/formats/in/AVIReader.java

    r2033 r2117  
    186186    if (debug) debug("initFile(" + id + ")"); 
    187187    super.initFile(id); 
    188     in = new RandomAccessStream(getMappedId(id)); 
     188    in = new RandomAccessStream(id); 
    189189    in.order(true); 
    190190 
  • trunk/loci/formats/in/AliconaReader.java

    r1947 r2117  
    154154    if (debug) debug("initFile(" + id + ")"); 
    155155    super.initFile(id); 
    156     in = new RandomAccessStream(getMappedId(id)); 
     156    in = new RandomAccessStream(id); 
    157157 
    158158    // check that this is a valid AL3D file 
  • trunk/loci/formats/in/AndorReader.java

    r2033 r2117  
    9797    // just checking the filename isn't enough to differentiate between 
    9898    // Andor and regular TIFF; open the file and check more thoroughly 
    99     return open ? checkBytes(getMappedId(name), BLOCK_CHECK_LEN) : true; 
     99    return open ? checkBytes(name, BLOCK_CHECK_LEN) : true; 
    100100  } 
    101101 
  • trunk/loci/formats/in/BMPReader.java

    r2010 r2117  
    241241    if (debug) debug("initFile(" + id + ")"); 
    242242    super.initFile(id); 
    243     in = new RandomAccessStream(getMappedId(id)); 
     243    in = new RandomAccessStream(id); 
    244244 
    245245    littleEndian = true; 
  • trunk/loci/formats/in/BaseTiffReader.java

    r2100 r2117  
    842842    super.initFile(id); 
    843843    channelMinMax = null; 
    844     in = new RandomAccessStream(getMappedId(id)); 
     844    in = new RandomAccessStream(id); 
    845845    if (in.readShort() == 0x4949) in.order(true); 
    846846 
  • trunk/loci/formats/in/BioRadReader.java

    r2033 r2117  
    170170    if (debug) debug("initFile(" + id + ")"); 
    171171    super.initFile(id); 
    172     in = new RandomAccessStream(getMappedId(id)); 
     172    in = new RandomAccessStream(id); 
    173173    in.order(true); 
    174174 
  • trunk/loci/formats/in/DeltavisionReader.java

    r2010 r2117  
    227227    super.initFile(id); 
    228228 
    229     in = new RandomAccessStream(getMappedId(id)); 
     229    in = new RandomAccessStream(id); 
    230230 
    231231    // read in the image header data 
  • trunk/loci/formats/in/DicomReader.java

    r2033 r2117  
    245245    if (debug) debug("initFile(" + id + ")"); 
    246246    super.initFile(id); 
    247     in = new RandomAccessStream(getMappedId(id)); 
     247    in = new RandomAccessStream(id); 
    248248    in.order(true); 
    249249 
  • trunk/loci/formats/in/EPSReader.java

    r2033 r2117  
    113113    byte[] p = new byte[width * height * channels * (bps / 8)]; 
    114114 
    115     RandomAccessStream ras = new RandomAccessStream(getMappedId(id)); 
     115    RandomAccessStream ras = new RandomAccessStream(id); 
    116116    int line = 0; 
    117117 
     
    172172    if (debug) debug("initFile(" + id + ")"); 
    173173    super.initFile(id); 
    174     in = new BufferedReader(new FileReader(getMappedId(id))); 
     174    in = new BufferedReader(new FileReader(id)); 
    175175    String line = in.readLine(); 
    176176    if (!line.trim().startsWith("%!PS")) { 
  • trunk/loci/formats/in/FluoviewReader.java

    r2033 r2117  
    103103    // just checking the filename isn't enough to differentiate between 
    104104    // Fluoview and regular TIFF; open the file and check more thoroughly 
    105     return open ? checkBytes(getMappedId(name), BLOCK_CHECK_LEN) : true; 
     105    return open ? checkBytes(name, BLOCK_CHECK_LEN) : true; 
    106106  } 
    107107 
  • trunk/loci/formats/in/GIFReader.java

    r1947 r2117  
    223223 
    224224    status = STATUS_OK; 
    225     in = new RandomAccessStream(getMappedId(id)); 
     225    in = new RandomAccessStream(id); 
    226226    images = new Vector(); 
    227227 
  • trunk/loci/formats/in/GatanReader.java

    r2105 r2117  
    161161    if (debug) debug("initFile(" + id + ")"); 
    162162    super.initFile(id); 
    163     in = new RandomAccessStream(getMappedId(id)); 
     163    in = new RandomAccessStream(id); 
    164164 
    165165    littleEndian = false; 
  • trunk/loci/formats/in/ICSReader.java

    r2078 r2117  
    4949  /** Current file. */ 
    5050  protected RandomAccessStream idsIn; // IDS file 
    51   protected File icsIn; // ICS file 
     51  protected Location icsIn; // ICS file 
    5252 
    5353  /** Flag indicating whether current file is little endian. */ 
     
    218218 
    219219    if (icsId == null) throw new FormatException("No ICS file found."); 
    220     File icsFile = new FileWrapper(getMappedId(icsId)); 
     220    Location icsFile = new Location(icsId); 
    221221    if (!icsFile.exists()) throw new FormatException("ICS file not found."); 
    222222 
    223223    // check if we have a v2 ICS file 
    224     RandomAccessStream f = new RandomAccessStream(getMappedId(icsId)); 
     224    RandomAccessStream f = new RandomAccessStream(icsId); 
    225225    byte[] b = new byte[17]; 
    226226    f.read(b); 
    227227    f.close(); 
    228228    if (new String(b).trim().equals("ics_version\t2.0")) { 
    229       idsIn = new RandomAccessStream(getMappedId(icsId)); 
     229      idsIn = new RandomAccessStream(icsId); 
    230230      versionTwo = true; 
    231231    } 
    232232    else { 
    233233      if (idsId == null) throw new FormatException("No IDS file found."); 
    234       File idsFile = new FileWrapper(getMappedId(idsId)); 
     234      Location idsFile = new Location(idsId); 
    235235      if (!idsFile.exists()) throw new FormatException("IDS file not found."); 
    236236      currentIdsId = idsId; 
    237       idsIn = new RandomAccessStream(getMappedId(idsId)); 
     237      idsIn = new RandomAccessStream(idsId); 
    238238    } 
    239239 
  • trunk/loci/formats/in/IPLabReader.java

    r2033 r2117  
    163163    if (debug) debug("initFile(" + id + ")"); 
    164164    super.initFile(id); 
    165     in = new RandomAccessStream(getMappedId(id)); 
     165    in = new RandomAccessStream(id); 
    166166 
    167167    byte[] fourBytes = new byte[4]; 
  • trunk/loci/formats/in/IPWReader.java

    r2078 r2117  
    199199    currentId = id; 
    200200 
    201     in = new RandomAccessStream(getMappedId(id)); 
     201    in = new RandomAccessStream(id); 
    202202 
    203203    metadata = new Hashtable(); 
  • trunk/loci/formats/in/ImageIOReader.java

    r2078 r2117  
    106106 
    107107    return ImageIO.read(new DataInputStream(new BufferedInputStream( 
    108       new RandomAccessStream(getMappedId(id)), 4096))); 
     108      new RandomAccessStream(id), 4096))); 
    109109  } 
    110110 
  • trunk/loci/formats/in/ImageJReader.java

    r2078 r2117  
    2727import java.awt.Image; 
    2828import java.awt.image.BufferedImage; 
    29 import java.io.File; 
    3029import java.io.IOException; 
    3130import javax.swing.filechooser.FileFilter; 
     
    126125 
    127126    try { 
    128       File file = new FileWrapper(getMappedId(id)); 
     127      Location file = new Location(id); 
    129128      r.setVar("dir", file.getParent() + System.getProperty("file.separator")); 
    130129      r.setVar("name", file.getName()); 
  • trunk/loci/formats/in/ImarisReader.java

    r2010 r2117  
    7171    if (debug) debug("initFile(" + id + ")"); 
    7272    super.initFile(id); 
    73     in = new RandomAccessStream(getMappedId(id)); 
     73    in = new RandomAccessStream(id); 
    7474    in.order(IS_LITTLE); 
    7575 
  • trunk/loci/formats/in/ImarisTiffReader.java

    r2039 r2117  
    8989    // just checking the filename isn't enough to differentiate between 
    9090    // Andor and regular TIFF; open the file and check more thoroughly 
    91     return open ? checkBytes(getMappedId(name), 1024) : true; 
     91    return open ? checkBytes(name, 1024) : true; 
    9292  } 
    9393 
     
    127127 
    128128    channelMinMax = null; 
    129     in = new RandomAccessStream(getMappedId(id)); 
     129    in = new RandomAccessStream(id); 
    130130    if (in.readShort() == 0x4949) in.order(true); 
    131131 
  • trunk/loci/formats/in/LIFReader.java

    r2099 r2117  
    191191    if (debug) debug("initFile(" + id + ")"); 
    192192    super.initFile(id); 
    193     in = new RandomAccessStream(getMappedId(id)); 
     193    in = new RandomAccessStream(id); 
    194194    offsets = new Vector(); 
    195195 
  • trunk/loci/formats/in/LegacyPictReader.java

    r2078 r2117  
    8989 
    9090    // read in PICT data 
    91     File file = new FileWrapper(getMappedId(id)); 
    92     int len = (int) (file.length() - 512); 
     91    RandomAccessStream fin = new RandomAccessStream(id); 
     92    int len = (int) (fin.length() - 512); 
    9393    byte[] bytes = new byte[len]; 
    94     FileInputStream fin = new FileInputStream(file); 
    9594    fin.skip(512);  // skip 512 byte PICT header 
    9695    int read = 0; 
  • trunk/loci/formats/in/LegacyQTReader.java

    r2078 r2117  
    2828import java.awt.image.BufferedImage; 
    2929import java.awt.image.ImageProducer; 
    30 import java.io.File; 
    3130import java.io.IOException; 
    3231import java.util.Hashtable; 
     
    6867  public LegacyQTReader(Hashtable idMap) { 
    6968    super("QuickTime", "mov"); 
    70     if (idMap != null) this.idMap = idMap; 
    7169  } 
    7270 
     
    173171 
    174172      // open movie file 
    175       File file = new FileWrapper(getMappedId(id)); 
     173      Location file = new Location(id); 
    176174      r.setVar("path", file.getAbsolutePath()); 
    177175      r.exec("qtf = new QTFile(path)"); 
  • trunk/loci/formats/in/LegacyZVIReader.java

    r2078 r2117  
    155155    if (debug) debug("initFile(" + id + ")"); 
    156156    super.initFile(id); 
    157     in = new RandomAccessStream(getMappedId(id)); 
     157    in = new RandomAccessStream(id); 
    158158 
    159159    // Highly questionable decoding strategy: 
  • trunk/loci/formats/in/LeicaReader.java

    r2078 r2117  
    228228      if (ifds == null) super.initFile(id); 
    229229 
    230       in = new RandomAccessStream(getMappedId(id)); 
     230      in = new RandomAccessStream(id); 
    231231 
    232232      if (in.readShort() == 0x4949) { 
     
    309309      } 
    310310 
    311       in = new RandomAccessStream(getMappedId(id)); 
     311      in = new RandomAccessStream(id); 
    312312 
    313313      byte[] fourBytes = new byte[4]; 
     
    377377        int tempImages = DataTools.bytesToInt(tempData, 0, 4, littleEndian); 
    378378        String dirPrefix = 
    379           new FileWrapper(getMappedId(id)).getAbsoluteFile().getParent(); 
     379          new Location(id).getAbsoluteFile().getParent(); 
    380380        dirPrefix = dirPrefix == null ? "" : (dirPrefix + File.separator); 
    381381        for (int j=0; j<tempImages; j++) { 
     
    384384            new String(tempData, 20 + 2*(j*nameLength), 2*nameLength))); 
    385385          // test to make sure the path is valid 
    386           File test = new FileWrapper((String) f.get(f.size() - 1)); 
     386          Location test = new Location((String) f.get(f.size() - 1)); 
    387387          if (!test.exists()) { 
    388388            // TIFF files were renamed 
    389389 
    390             File[] dirListing = (new FileWrapper(dirPrefix)).listFiles(); 
     390            Location[] dirListing = (new Location(dirPrefix)).listFiles(); 
    391391 
    392392            int pos = 0; 
     
    456456    // just checking the filename isn't enough to differentiate between 
    457457    // Leica and regular TIFF; open the file and check more thoroughly 
    458     File file = new FileWrapper(getMappedId(name)); 
     458    Location file = new Location(name); 
    459459    if (!file.exists()) return false; 
    460460    long len = file.length(); 
     
    462462 
    463463    try { 
    464       RandomAccessStream ras = new RandomAccessStream(getMappedId(name)); 
     464      RandomAccessStream ras = new RandomAccessStream(name); 
    465465      Hashtable ifd = TiffTools.getFirstIFD(ras); 
    466466      if (ifd == null) return false; 
     
    478478      lei = dir + lei; 
    479479 
    480       File check = new FileWrapper(getMappedId(lei)); 
     480      Location check = new Location(lei); 
    481481      return check.exists(); 
    482482    } 
  • trunk/loci/formats/in/MDBParser.java

    r2078 r2117  
    2525package loci.formats.in; 
    2626 
     27import java.io.File; 
    2728import java.util.*; 
    2829import loci.formats.*; 
     
    8990      // print out all data 
    9091 
    91       r.setVar("dbfile", new FileWrapper(filename)); 
     92      // TODO: this doesn't work in general 
     93      r.setVar("dbfile", new File(filename)); 
    9294      r.exec("mdb = file.mdb_open(dbfile)"); 
    9395      r.exec("Catalog.mdb_read_catalog(mdb, Constants.MDB_TABLE)"); 
  • trunk/loci/formats/in/MRCReader.java

    r2039 r2117  
    126126    if (debug) debug("initFile(" + id + ")"); 
    127127    super.initFile(id); 
    128     in = new RandomAccessStream(getMappedId(id)); 
     128    in = new RandomAccessStream(id); 
    129129 
    130130    // check endianness 
  • trunk/loci/formats/in/ND2Reader.java

    r2110 r2117  
    217217    if (!foundReader) throw new FormatException(NO_JAI_MSG); 
    218218 
    219     in = new RandomAccessStream(getMappedId(id)); 
     219    in = new RandomAccessStream(id); 
    220220 
    221221    try { 
    222       File f = new File(getMappedId(id)); 
     222      File f = new File(Location.getMappedId(id)); 
    223223      if (f.exists()) { 
    224         r.setVar("id", getMappedId(id)); 
     224        r.setVar("id", Location.getMappedId(id)); 
    225225        r.setVar("read", "r"); 
    226226        r.setVar("size", 4096); 
  • trunk/loci/formats/in/NikonReader.java

    r2033 r2117  
    173173    // just checking the filename isn't enough to differentiate between 
    174174    // Nikon and regular TIFF; open the file and check more thoroughly 
    175     return open ? checkBytes(getMappedId(name), BLOCK_CHECK_LEN) : true; 
     175    return open ? checkBytes(name, BLOCK_CHECK_LEN) : true; 
    176176  } 
    177177 
     
    196196 
    197197    channelMinMax = null; 
    198     in = new RandomAccessStream(getMappedId(id)); 
     198    in = new RandomAccessStream(id); 
    199199    if (in.readShort() == 0x4949) in.order(true); 
    200200 
  • trunk/loci/formats/in/OIBReader.java

    r2035 r2117  
    276276 
    277277    try { 
    278       RandomAccessStream ras = new RandomAccessStream(getMappedId(id)); 
     278      RandomAccessStream ras = new RandomAccessStream(id); 
    279279      if (ras.length() % 4096 != 0) { 
    280280        ras.setExtend(4096 - (int) (ras.length() % 4096)); 
  • trunk/loci/formats/in/OIFReader.java

    r2078 r2117  
    230230    String oifFile = id; 
    231231    if (!id.toLowerCase().endsWith("oif")) { 
    232       File current = new FileWrapper(getMappedId(id)); 
     232      Location current = new Location(id); 
    233233      current = current.getAbsoluteFile(); 
    234234      String parent = current.getParent(); 
    235       File tmp = new FileWrapper(parent); 
     235      Location tmp = new Location(parent); 
    236236      parent = tmp.getParent(); 
    237237 
     
    243243      oifFile = parent + oifFile.substring(0, oifFile.indexOf("_")) + ".oif"; 
    244244 
    245       tmp = new FileWrapper(getMappedId(oifFile)); 
     245      tmp = new Location(oifFile); 
    246246      if (!tmp.exists()) { 
    247247        oifFile = oifFile.substring(0, oifFile.lastIndexOf(".")) + ".OIF"; 
    248         tmp = new FileWrapper(getMappedId(oifFile)); 
     248        tmp = new Location(oifFile); 
    249249        if (!tmp.exists()) throw new FormatException("OIF file not found"); 
    250250        currentId = oifFile; 
     
    254254 
    255255    super.initFile(oifFile); 
    256     reader = new RandomAccessStream(getMappedId(oifFile)); 
     256    reader = new RandomAccessStream(oifFile); 
    257257 
    258258    int slash = oifFile.lastIndexOf(File.separator); 
     
    306306      tiffPath = file.substring(0, file.lastIndexOf(File.separator)); 
    307307 
    308       ptyReader = new RandomAccessStream(getMappedId(file)); 
     308      ptyReader = new RandomAccessStream(file); 
    309309      b = new byte[(int) ptyReader.length()]; 
    310310      ptyReader.read(b); 
  • trunk/loci/formats/in/OMEXMLReader.java

    r2078 r2117  
    207207    currentId = id; 
    208208    metadata = new Hashtable(); 
    209     in = new RandomAccessStream(getMappedId(id)); 
     209    in = new RandomAccessStream(id); 
    210210 
    211211    in.skipBytes(200); 
     
    329329    OMENode ome = null; 
    330330    try { 
    331       File f = new File(getMappedId(id)); 
     331      File f = new File(Location.getMappedId(id)); 
    332332      f = f.getAbsoluteFile(); 
    333333      if (f.exists()) ome = new OMENode(f); 
  • trunk/loci/formats/in/OpenlabRawReader.java

    r2010 r2117  
    141141    if (debug) debug("initFile(" + id + ")"); 
    142142    super.initFile(id); 
    143     in = new RandomAccessStream(getMappedId(id)); 
     143    in = new RandomAccessStream(id); 
    144144 
    145145    // read the 12 byte file header 
  • trunk/loci/formats/in/OpenlabReader.java

    r2076 r2117  
    109109      byte[] b = new byte[8]; 
    110110      try { 
    111         in = new RandomAccessStream(getMappedId(name)); 
     111        in = new RandomAccessStream(name); 
    112112        in.read(b); 
    113113      } 
     
    387387    if (debug) debug("initFile(" + id + ")"); 
    388388    super.initFile(id); 
    389     in = new RandomAccessStream(getMappedId(id)); 
     389    in = new RandomAccessStream(id); 
    390390 
    391391    in.skipBytes(4); 
  • trunk/loci/formats/in/PerkinElmerReader.java

    r2078 r2117  
    117117 
    118118    String file = files[no]; 
    119     RandomAccessStream ras = new RandomAccessStream(getMappedId(file)); 
     119    RandomAccessStream ras = new RandomAccessStream(file); 
    120120    byte[] b = new byte[(int) ras.length() - 6]; // each file has 6 magic bytes 
    121121    ras.skipBytes(6); 
     
    171171 
    172172    // get the working directory 
    173     File tempFile = new FileWrapper(getMappedId(id)); 
    174     File workingDir = tempFile.getParentFile(); 
    175     if (workingDir == null) workingDir = new FileWrapper("."); 
     173    Location tempFile = new Location(id); 
     174    Location workingDir = tempFile.getParentFile(); 
     175    if (workingDir == null) workingDir = new Location("."); 
    176176    String workingDirPath = workingDir.getPath() + File.separator; 
    177177    String[] ls = workingDir.list(); 
     
    355355 
    356356    if (timPos != -1) { 
    357       tempFile = new FileWrapper(workingDir, ls[timPos]); 
     357      tempFile = new Location(workingDir, ls[timPos]); 
    358358      allFiles.add(tempFile.getAbsolutePath()); 
    359359      read = new RandomAccessStream(tempFile.getAbsolutePath()); 
     
    388388 
    389389    if (csvPos != -1) { 
    390       tempFile = new FileWrapper(workingDir, ls[csvPos]); 
     390      tempFile = new Location(workingDir, ls[csvPos]); 
    391391      allFiles.add(tempFile.getAbsolutePath()); 
    392392      read = new RandomAccessStream(tempFile.getAbsolutePath()); 
     
    417417    } 
    418418    else if (zpoPos != -1) { 
    419       tempFile = new FileWrapper(workingDir, ls[zpoPos]); 
     419      tempFile = new Location(workingDir, ls[zpoPos]); 
    420420      allFiles.add(tempFile.getAbsolutePath()); 
    421421      read = new RandomAccessStream(tempFile.getAbsolutePath()); 
     
    434434 
    435435    if (htmPos != -1) { 
    436       tempFile = new FileWrapper(workingDir, ls[htmPos]); 
     436      tempFile = new Location(workingDir, ls[htmPos]); 
    437437      allFiles.add(tempFile.getAbsolutePath()); 
    438438      read = new RandomAccessStream(tempFile.getAbsolutePath()); 
  • trunk/loci/formats/in/PictReader.java

    r2092 r2117  
    182182    if (debug) debug("initFile(" + id + ")"); 
    183183    super.initFile(id); 
    184     in = new RandomAccessStream(getMappedId(id)); 
     184    in = new RandomAccessStream(id); 
    185185 
    186186    little = false; 
  • trunk/loci/formats/in/PrairieReader.java

    r2078 r2117  
    7979 
    8080    // check if there is an XML file in the same directory 
    81     File f = new FileWrapper(name); 
     81    Location  f = new Location(name); 
    8282    f = f.getAbsoluteFile(); 
    83     File parent = f.getParentFile(); 
    84     FileFilter ff = new FileFilter() { 
    85       public boolean accept(File pathname) { 
    86         String path = pathname.getPath().toLowerCase(); 
    87         return path.endsWith(".xml"); 
    88       } 
    89     }; 
    90     File[] listing = parent.listFiles(ff); 
    91     boolean xml = listing != null && listing.length > 0; 
     83    Location parent = f.getParentFile(); 
     84    String[] listing = parent.list(); 
     85    int xmlCount = 0; 
     86    for (int i=0; i<listing.length; i++) { 
     87      if (listing[i].toLowerCase().endsWith(".xml")) xmlCount++;  
     88    } 
     89 
     90    boolean xml = xmlCount > 0; 
    9291 
    9392    // just checking the filename isn't enough to differentiate between 
    9493    // Prairie and regular TIFF; open the file and check more thoroughly 
    95     return open ? checkBytes(getMappedId(name), 524304) && xml : xml; 
     94    return open ? checkBytes(name, 524304) && xml : xml; 
    9695  } 
    9796 
     
    217216      } 
    218217 
    219       RandomAccessStream is = new RandomAccessStream(getMappedId(id)); 
     218      RandomAccessStream is = new RandomAccessStream(id); 
    220219      byte[] b = new byte[(int) is.length()]; 
    221220      is.read(b); 
     
    263262              el = el.substring(el.indexOf("\"", eq + 2) + 1).trim(); 
    264263              if (prefix.equals("File") && key.equals("filename")) { 
    265                 File current = new FileWrapper(getMappedId(id)); 
     264                Location current = new Location(id); 
    266265                current = current.getAbsoluteFile(); 
    267266                f.add(current.getParent() + "/" + value); 
     
    326325 
    327326      if (!readXML || !readCFG) { 
    328         File file = new FileWrapper(id); 
     327        Location file = new Location(id); 
    329328        file = file.getAbsoluteFile(); 
    330         File parent = file.getParentFile(); 
    331         FileFilter ff = new FileFilter() { 
    332           public boolean accept(File pathname) { 
    333             String path = pathname.getPath().toLowerCase(); 
    334             return !readXML ? path.endsWith(".xml") : path.endsWith(".cfg"); 
    335           } 
    336         }; 
    337         File[] listing = parent.listFiles(ff); 
    338         if (listing.length > 0) initFile(listing[0].getAbsolutePath()); 
     329        Location parent = file.getParentFile(); 
     330        String[] listing = parent.list(); 
     331        Location next = null; 
     332        for (int i=0; i<listing.length; i++) { 
     333          String path = listing[i].toLowerCase(); 
     334          if ((!readXML && path.endsWith(".xml")) ||  
     335            (readXML && path.endsWith(".cfg"))) 
     336          { 
     337            next = new Location(path); 
     338          } 
     339        } 
     340        if (next != null) initFile(next.getAbsolutePath()); 
    339341      } 
    340342    } 
     
    342344      // we have been given a TIFF file - reinitialize with the proper XML file 
    343345 
    344       String tiffFile = getMappedId(id); 
    345       File f = new FileWrapper(tiffFile); 
     346      Location f = new Location(id); 
    346347      f = f.getAbsoluteFile(); 
    347       File parent = f.getParentFile(); 
    348       FileFilter ff = new FileFilter() { 
    349         public boolean accept(File pathname) { 
    350           String path = pathname.getPath().toLowerCase(); 
    351           return path.endsWith(".xml") || path.endsWith(".cfg"); 
    352         } 
    353       }; 
    354       File[] listing = parent.listFiles(ff); 
     348      Location parent = f.getParentFile(); 
     349      String[] listing = parent.list(); 
    355350      for (int i=0; i<listing.length; i++) { 
    356         initFile(listing[i].getAbsolutePath()); 
     351        String path = listing[i].toLowerCase(); 
     352        if (path.endsWith(".xml") || path.endsWith(".cfg")) { 
     353          initFile(new Location(path).getAbsolutePath()); 
     354        } 
    357355      } 
    358356    } 
  • trunk/loci/formats/in/QTReader.java

    r2078 r2117  
    616616      else base = id; 
    617617 
    618       File f = new FileWrapper(getMappedId(base + ".qtr")); 
     618      Location f = new Location(base + ".qtr"); 
    619619      if (f.exists()) { 
    620620        in = new RandomAccessStream(f.getAbsolutePath()); 
     
    626626      } 
    627627      else { 
    628         f = new FileWrapper(getMappedId(base.substring(0, 
     628        f = new Location(base.substring(0, 
    629629          base.lastIndexOf(File.separator) + 1) + "._" + 
    630           base.substring(base.lastIndexOf(File.separator) + 1))); 
     630          base.substring(base.lastIndexOf(File.separator) + 1)); 
    631631        if (f.exists()) { 
    632632          in = new RandomAccessStream(f.getAbsolutePath()); 
     
    637637        } 
    638638        else { 
    639           f = new FileWrapper(getMappedId(base + "/rsrc")); 
     639          f = new Location(base + "/rsrc"); 
    640640          if (f.exists()) { 
    641641            in = new RandomAccessStream(f.getAbsolutePath()); 
     
    16061606  private LegacyQTReader createLegacyReader() { 
    16071607    // use the same id mappings that this reader does 
    1608     return new LegacyQTReader(idMap); 
     1608    return new LegacyQTReader(); 
    16091609  } 
    16101610 
  • trunk/loci/formats/in/SDTReader.java

    r1947 r2117  
    201201    if (debug) debug("initFile(" + id + ")"); 
    202202    super.initFile(id); 
    203     in = new RandomAccessStream(getMappedId(id)); 
     203    in = new RandomAccessStream(id); 
    204204    in.order(true); 
    205205 
  • trunk/loci/formats/in/SlidebookReader.java

    r2010 r2117  
    133133    if (debug) debug("initFile(" + id + ")"); 
    134134    super.initFile(id); 
    135     in = new RandomAccessStream(getMappedId(id)); 
     135    in = new RandomAccessStream(id); 
    136136 
    137137    in.skipBytes(4); 
  • trunk/loci/formats/in/ZeissLSMReader.java

    r2110 r2117  
    2626 
    2727import java.awt.image.BufferedImage; 
    28 import java.io.File; 
    2928import java.io.IOException; 
    3029import java.util.Hashtable; 
     
    694693    // see if we have an associated MDB file 
    695694 
    696     File dir = 
    697       new FileWrapper(getMappedId(currentId)).getAbsoluteFile().getParentFile(); 
     695    Location dir = new Location(currentId).getAbsoluteFile().getParentFile(); 
    698696    String[] dirList = dir.list(); 
    699697 
  • trunk/loci/formats/in/ZeissZVIReader.java

    r2110 r2117  
    216216  } 
    217217 
    218   /* @see IFormatHandler#mapId(String, String) */ 
    219   public void mapId(String id, String filename) { 
    220     super.mapId(id, filename); 
    221     legacy.mapId(id, filename); 
    222   } 
    223  
    224218  /* @see FormatReader#setMetadataStore(MetadataStore) */ 
    225219  public void setMetadataStore(MetadataStore store) { 
     
    362356 
    363357    try { 
    364       ras = new RandomAccessStream(getMappedId(id)); 
     358      ras = new RandomAccessStream(id); 
    365359 
    366360      // Don't uncomment this block.  Even though OIBReader has something 
  • trunk/loci/formats/test/ReaderTest.java

    r2078 r2117  
    326326      } 
    327327    } 
    328     String absFile = new FileWrapper(file).getAbsolutePath(); 
     328    String absFile = new Location(file).getAbsolutePath(); 
    329329    for (int i=0; i<badFiles.size(); i++) { 
    330330      String bad = (String) badFiles.elementAt(i); 
     
    336336  /** Recursively generates a list of files to test. */ 
    337337  public static void getFiles(String root, Vector files) { 
    338     File f = new FileWrapper(root); 
     338    Location f = new Location(root); 
    339339    String[] subs = f.list(); 
    340340    if (subs == null) { 
     
    350350        continue; 
    351351      } 
    352       File file = new FileWrapper(subs[i]); 
     352      Location file = new Location(subs[i]); 
    353353      if (file.isDirectory()) getFiles(subs[i], files); 
    354354      else { 
     
    401401    while (files.size() > 0) { 
    402402      String id = (String) files.elementAt(0); 
    403       String pattern = FilePattern.findPattern(new FileWrapper(id)); 
     403      String pattern = FilePattern.findPattern(new Location(id)); 
    404404      if (pattern == null) pattern = id; 
    405405      System.out.println("Testing " + pattern); 
  • trunk/loci/ome/upload/OMEUploader.java

    r2116 r2117  
    156156      if (stitch) { 
    157157        f = new FileStitcher(f); 
    158         FilePattern fp = new FilePattern(new File(file)); 
     158        FilePattern fp = new FilePattern(new loci.formats.Location(file)); 
    159159        String[] names = fp.getFiles(); 
    160160        for (int i=0; i<names.length; i++) files.add(names[i]); 
     
    210210      if (stitch) { 
    211211        f = new FileStitcher(f); 
    212         FilePattern fp = new FilePattern(new File(file)); 
     212        FilePattern fp = new FilePattern(new loci.formats.Location(file)); 
    213213        String[] names = fp.getFiles(); 
    214214        for (int i=0; i<names.length; i++) files.add(names[i]); 
  • trunk/loci/plugins/Importer.java

    r2113 r2117  
    146146 
    147147        // if no valid filename, give up 
    148         if (id == null || !new FileWrapper(id).exists()) { 
     148        if (id == null || !new Location(id).exists()) { 
    149149          if (!quiet) { 
    150150            IJ.error("LOCI Bio-Formats", "The specified file " + 
     
    297297        fs = new FileStitcher(r, true); 
    298298        // prompt user to confirm detected file pattern 
    299         id = FilePattern.findPattern(new FileWrapper(id)); 
     299        id = FilePattern.findPattern(new Location(id)); 
    300300        gd = new GenericDialog("LOCI Bio-Formats File Stitching"); 
    301301        int len = id.length() + 1; 
Note: See TracChangeset for help on using the changeset viewer.