Changeset 2786


Ignore:
Timestamp:
05/16/07 11:16:08 (13 years ago)
Author:
curtis
Message:

Make getZCTCoords and getIndex throw IllegalArgumentException
rather than FormatException.

Location:
trunk/loci/formats
Files:
8 edited

Legend:

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

    r2701 r2786  
    134134  } 
    135135 
    136   public int getIndex(int z, int c, int t) throws FormatException { 
     136  public int getIndex(int z, int c, int t) { 
    137137    return FormatTools.getIndex(this, z, c, t); 
    138138  } 
    139139 
    140   public int[] getZCTCoords(int index) throws FormatException { 
     140  public int[] getZCTCoords(int index) { 
    141141    return FormatTools.getZCTCoords(this, index); 
    142142  } 
  • trunk/loci/formats/ChannelSeparator.java

    r2726 r2786  
    163163  } 
    164164 
    165   public int getIndex(int z, int c, int t) throws FormatException { 
     165  public int getIndex(int z, int c, int t) { 
    166166    return FormatTools.getIndex(this, z, c, t); 
    167167  } 
    168168 
    169   public int[] getZCTCoords(int index) throws FormatException { 
     169  public int[] getZCTCoords(int index) { 
    170170    return FormatTools.getZCTCoords(this, index); 
    171171  } 
  • trunk/loci/formats/FileStitcher.java

    r2782 r2786  
    566566 
    567567  /* @see IFormatReader#getIndex(int, int, int) */ 
    568   public int getIndex(int z, int c, int t) throws FormatException { 
     568  public int getIndex(int z, int c, int t) { 
    569569    return FormatTools.getIndex(this, z, c, t); 
    570570  } 
    571571 
    572572  /* @see IFormatReader#getZCTCoords(int) */ 
    573   public int[] getZCTCoords(int index) throws FormatException { 
     573  public int[] getZCTCoords(int index) { 
    574574    return FormatTools.getZCTCoords(this, index); 
    575575  } 
  • trunk/loci/formats/FormatReader.java

    r2782 r2786  
    436436 
    437437  /* @see IFormatReader#getIndex(int, int, int) */ 
    438   public int getIndex(int z, int c, int t) throws FormatException { 
     438  public int getIndex(int z, int c, int t) { 
    439439    FormatTools.assertId(currentId, true, 1); 
    440440    return FormatTools.getIndex(this, z, c, t); 
     
    442442 
    443443  /* @see IFormatReader#getZCTCoords(int) */ 
    444   public int[] getZCTCoords(int index) throws FormatException { 
     444  public int[] getZCTCoords(int index) { 
    445445    FormatTools.assertId(currentId, true, 1); 
    446446    return FormatTools.getZCTCoords(this, index); 
  • trunk/loci/formats/FormatTools.java

    r2757 r2786  
    668668   * to the given Z, C and T coordinates. 
    669669   */ 
    670   public static int getIndex(IFormatReader reader, int z, int c, int t) 
    671     throws FormatException 
    672   { 
     670  public static int getIndex(IFormatReader reader, int z, int c, int t) { 
    673671    String order = reader.getDimensionOrder(); 
    674672    int zSize = reader.getSizeZ(); 
     
    684682   */ 
    685683  public static int getIndex(String order, int zSize, int cSize, int tSize, 
    686     int num, int z, int c, int t) throws FormatException 
     684    int num, int z, int c, int t) 
    687685  { 
    688686    // check DimensionOrder 
    689     if (order == null) throw new FormatException("Dimension order is null"); 
     687    if (order == null) { 
     688      throw new IllegalArgumentException("Dimension order is null"); 
     689    } 
    690690    if (!order.startsWith("XY")) { 
    691       throw new FormatException("Invalid dimension order: " + order); 
     691      throw new IllegalArgumentException("Invalid dimension order: " + order); 
    692692    } 
    693693    int iz = order.indexOf("Z") - 2; 
     
    695695    int it = order.indexOf("T") - 2; 
    696696    if (iz < 0 || iz > 2 || ic < 0 || ic > 2 || it < 0 || it > 2) { 
    697       throw new FormatException("Invalid dimension order: " + order); 
     697      throw new IllegalArgumentException("Invalid dimension order: " + order); 
    698698    } 
    699699 
    700700    // check SizeZ 
    701     if (zSize <= 0) throw new FormatException("Invalid Z size: " + zSize); 
     701    if (zSize <= 0) { 
     702      throw new IllegalArgumentException("Invalid Z size: " + zSize); 
     703    } 
    702704    if (z < 0 || z >= zSize) { 
    703       throw new FormatException("Invalid Z index: " + z + "/" + zSize); 
     705      throw new IllegalArgumentException("Invalid Z index: " + z + "/" + zSize); 
    704706    } 
    705707 
    706708    // check SizeC 
    707     if (cSize <= 0) throw new FormatException("Invalid C size: " + cSize); 
     709    if (cSize <= 0) { 
     710      throw new IllegalArgumentException("Invalid C size: " + cSize); 
     711    } 
    708712    if (c < 0 || c >= cSize) { 
    709       throw new FormatException("Invalid C index: " + c + "/" + cSize); 
     713      throw new IllegalArgumentException("Invalid C index: " + c + "/" + cSize); 
    710714    } 
    711715 
    712716    // check SizeT 
    713     if (tSize <= 0) throw new FormatException("Invalid T size: " + tSize); 
     717    if (tSize <= 0) { 
     718      throw new IllegalArgumentException("Invalid T size: " + tSize); 
     719    } 
    714720    if (t < 0 || t >= tSize) { 
    715       throw new FormatException("Invalid T index: " + t + "/" + tSize); 
     721      throw new IllegalArgumentException("Invalid T index: " + t + "/" + tSize); 
    716722    } 
    717723 
    718724    // check image count 
    719     if (num <= 0) throw new FormatException("Invalid image count: " + num); 
     725    if (num <= 0) { 
     726      throw new IllegalArgumentException("Invalid image count: " + num); 
     727    } 
    720728    if (num != zSize * cSize * tSize) { 
    721729      // if this happens, there is probably a bug in metadata population -- 
    722730      // either one of the ZCT sizes, or the total number of images -- 
    723731      // or else the input file is invalid 
    724       throw new FormatException("ZCT size vs image count mismatch (sizeZ=" + 
    725         zSize + ", sizeC=" + cSize + ", sizeT=" + tSize + ", total=" + num + 
    726         ")"); 
     732      throw new IllegalArgumentException("ZCT size vs image count mismatch " + 
     733        "(sizeZ=" + zSize + ", sizeC=" + cSize + ", sizeT=" + tSize + 
     734        ", total=" + num + ")"); 
    727735    } 
    728736 
     
    742750   * to the given rasterized index value. 
    743751   */ 
    744   public static int[] getZCTCoords(IFormatReader reader, int index) 
    745     throws FormatException 
    746   { 
     752  public static int[] getZCTCoords(IFormatReader reader, int index) { 
    747753    String order = reader.getDimensionOrder(); 
    748754    int zSize = reader.getSizeZ(); 
     
    758764   */ 
    759765  public static int[] getZCTCoords(String order, 
    760     int zSize, int cSize, int tSize, int num, int index) throws FormatException 
     766    int zSize, int cSize, int tSize, int num, int index) 
    761767  { 
    762768    // check DimensionOrder 
    763     if (order == null) throw new FormatException("Dimension order is null"); 
     769    if (order == null) { 
     770      throw new IllegalArgumentException("Dimension order is null"); 
     771    } 
    764772    if (!order.startsWith("XY")) { 
    765       throw new FormatException("Invalid dimension order: " + order); 
     773      throw new IllegalArgumentException("Invalid dimension order: " + order); 
    766774    } 
    767775    int iz = order.indexOf("Z") - 2; 
     
    769777    int it = order.indexOf("T") - 2; 
    770778    if (iz < 0 || iz > 2 || ic < 0 || ic > 2 || it < 0 || it > 2) { 
    771       throw new FormatException("Invalid dimension order: " + order); 
     779      throw new IllegalArgumentException("Invalid dimension order: " + order); 
    772780    } 
    773781 
    774782    // check SizeZ 
    775     if (zSize <= 0) throw new FormatException("Invalid Z size: " + zSize); 
     783    if (zSize <= 0) { 
     784      throw new IllegalArgumentException("Invalid Z size: " + zSize); 
     785    } 
    776786 
    777787    // check SizeC 
    778     if (cSize <= 0) throw new FormatException("Invalid C size: " + cSize); 
     788    if (cSize <= 0) { 
     789      throw new IllegalArgumentException("Invalid C size: " + cSize); 
     790    } 
    779791 
    780792    // check SizeT 
    781     if (tSize <= 0) throw new FormatException("Invalid T size: " + tSize); 
     793    if (tSize <= 0) { 
     794      throw new IllegalArgumentException("Invalid T size: " + tSize); 
     795    } 
    782796 
    783797    // check image count 
    784     if (num <= 0) throw new FormatException("Invalid image count: " + num); 
     798    if (num <= 0) { 
     799      throw new IllegalArgumentException("Invalid image count: " + num); 
     800    } 
    785801    if (num != zSize * cSize * tSize) { 
    786802      // if this happens, there is probably a bug in metadata population -- 
    787803      // either one of the ZCT sizes, or the total number of images -- 
    788804      // or else the input file is invalid 
    789       throw new FormatException("ZCT size vs image count mismatch (sizeZ=" + 
    790         zSize + ", sizeC=" + cSize + ", sizeT=" + tSize + ", total=" + num + 
    791         ")"); 
     805      throw new IllegalArgumentException("ZCT size vs image count mismatch " + 
     806        "(sizeZ=" + zSize + ", sizeC=" + cSize + ", sizeT=" + tSize + 
     807        ", total=" + num + ")"); 
    792808    } 
    793809    if (index < 0 || index >= num) { 
    794       throw new FormatException("Invalid image index: " + index + "/" + num); 
     810      throw new IllegalArgumentException("Invalid image index: " + 
     811        index + "/" + num); 
    795812    } 
    796813 
  • trunk/loci/formats/IFormatReader.java

    r2782 r2786  
    216216   * to the given Z, C and T coordinates. 
    217217   */ 
    218   int getIndex(int z, int c, int t) throws FormatException; 
     218  int getIndex(int z, int c, int t); 
    219219 
    220220  /** 
     
    222222   * to the given rasterized index value. 
    223223   */ 
    224   int[] getZCTCoords(int index) throws FormatException; 
     224  int[] getZCTCoords(int index); 
    225225 
    226226  /** 
  • trunk/loci/formats/ImageReader.java

    r2782 r2786  
    338338 
    339339  /* @see IFormatReader#getIndex(int, int, int) */ 
    340   public int getIndex(int z, int c, int t) throws FormatException { 
     340  public int getIndex(int z, int c, int t) { 
    341341    FormatTools.assertId(currentId, true, 2); 
    342342    return getReader().getIndex(z, c, t); 
     
    344344 
    345345  /* @see IFormatReader#getZCTCoords(int) */ 
    346   public int[] getZCTCoords(int index) throws FormatException { 
     346  public int[] getZCTCoords(int index) { 
    347347    FormatTools.assertId(currentId, true, 2); 
    348348    return getReader().getZCTCoords(index); 
  • trunk/loci/formats/ReaderWrapper.java

    r2782 r2786  
    224224  public String getCurrentFile() { return reader.getCurrentFile(); } 
    225225 
    226   public int getIndex(int z, int c, int t) throws FormatException { 
     226  public int getIndex(int z, int c, int t) { 
    227227    return reader.getIndex(z, c, t); 
    228228  } 
    229229 
    230   public int[] getZCTCoords(int index) throws FormatException { 
     230  public int[] getZCTCoords(int index) { 
    231231    return reader.getZCTCoords(index); 
    232232  } 
Note: See TracChangeset for help on using the changeset viewer.