Changeset 2318


Ignore:
Timestamp:
02/22/07 16:26:54 (13 years ago)
Author:
curtis
Message:

Use getUsedFiles instead of FilePattern to group files.

File:
1 edited

Legend:

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

    r2316 r2318  
    8080   * with elements of the each group separated by spaces. 
    8181   */ 
    82   public void testIds(int[] fileIds) throws OmeisException { 
     82  public void testIds(int[] fileIds) 
     83    throws OmeisException, FormatException, IOException 
     84  { 
    8385    // set up file path mappings 
    8486    String[] ids = new String[fileIds.length]; 
     
    98100      if (ids[i] == null) continue; // invalid id 
    99101      if (!reader.isThisType(ids[i])) continue; // unknown format 
    100       FilePattern fp = reader.findPattern(ids[i]); 
    101       if (!fp.isValid()) continue; // invalid file pattern 
    102       String[] files = fp.getFiles(); 
     102      String[] files = reader.getUsedFiles(ids[i]); 
    103103      if (files == null) continue; // invalid files list 
    104104      sb.setLength(0); 
    105105      for (int j=0; j<files.length; j++) { 
    106106        for (int ii=i; ii<fileIds.length; ii++) { 
    107           if (files[j].equals(ids[ii])) { 
     107          if (files[j] == null) { 
     108            log("Warning: FileID " + fileIds[ii] + " ('" + 
     109              ids[ii] + "') has null used file #" + j); 
     110          } 
     111          else if (files[j].equals(ids[ii])) { 
    108112            if (done[ii]) { 
    109113              log("Warning: FileID " + fileIds[ii] + " ('" + 
     
    143147    // read file group 
    144148    String id = ids[0]; 
    145     String path = Location.getMappedId(ids[0]); 
     149    String path = Location.getMappedId(id); 
    146150    if (DEBUG) log("Reading file '" + id + "' --> " + path); 
    147151 
    148     // verify that all given file IDs were grouped by the file stitcher 
    149     FilePattern fp = reader.getFilePattern(id); 
    150     if (!fp.isValid()) { 
    151       throw new FormatException("Invalid file pattern for " + path); 
    152     } 
    153     String[] files = fp.getFiles(); 
    154     if (files == null) { 
     152    // verify that all given file IDs were grouped by the reader 
     153    String[] used = reader.getUsedFiles(id); 
     154    if (used == null) { 
    155155      throw new FormatException("Invalid file list for " + path); 
    156156    } 
    157     if (files.length != ids.length) { 
    158       throw new FormatException("File list length mismatch for " + path); 
     157    if (used.length != ids.length) { 
     158      throw new FormatException("File list length mismatch for " + path + 
     159        ": used=" + a2s(used) + "; ids=" + a2s(ids)); 
    159160    } 
    160161    boolean[] done = new boolean[ids.length]; 
    161162    int numLeft = ids.length; 
    162     for (int i=0; i<files.length; i++) { 
     163    for (int i=0; i<used.length; i++) { 
    163164      for (int j=0; j<ids.length; j++) { 
    164165        if (done[j]) continue; 
    165         if (files[i].equals(ids[j])) { 
     166        if (used[i].equals(ids[j])) { 
    166167          done[j] = true; 
    167168          numLeft--; 
     
    523524  } 
    524525 
     526  /** Prints a debugging message. */ 
    525527  private void log(String msg) { 
    526528    System.err.println("Bio-Formats: " + msg); 
     529  } 
     530 
     531  /** Gets a printable version of the given array of strings. */ 
     532  private String a2s(String[] s) { 
     533    StringBuffer sb = new StringBuffer(); 
     534    if (s == null) return "null"; 
     535    sb.append("["); 
     536    if (s.length > 0) sb.append(s[0]); 
     537    for (int i=1; i<s.length; i++) { 
     538      sb.append(" "); 
     539      sb.append(s[i]); 
     540    } 
     541    sb.append("]"); 
     542    return sb.toString(); 
    527543  } 
    528544 
Note: See TracChangeset for help on using the changeset viewer.