Changeset 6141


Ignore:
Timestamp:
04/19/10 15:56:28 (10 years ago)
Author:
curtis
Message:

Use generics where appropriate; fix miscellaneous warnings and issues.

Location:
trunk/components
Files:
27 edited

Legend:

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

    r6026 r6141  
    2828import java.io.IOException; 
    2929import java.io.InputStreamReader; 
    30 import java.util.Vector; 
     30import java.util.ArrayList; 
     31import java.util.List; 
    3132 
    3233import org.slf4j.Logger; 
     
    4344 * @author Curtis Rueden ctrueden at wisc.edu 
    4445 */ 
    45 public class ClassList { 
     46public class ClassList<T> { 
    4647 
    4748  // -- Constants -- 
     
    5253 
    5354  /** Base class to which all classes are assignable. */ 
    54   private Class base; 
     55  private Class<T> base; 
    5556 
    5657  /** List of classes. */ 
    57   private Vector classes; 
     58  private List<Class<? extends T>> classes; 
    5859 
    5960  // -- Constructor -- 
     
    6364   * @param base Base class to which all classes are assignable. 
    6465   */ 
    65   public ClassList(Class base) { 
     66  public ClassList(Class<T> base) { 
    6667    this.base = base; 
    67     classes = new Vector(); 
     68    classes = new ArrayList<Class<? extends T>>(); 
    6869  } 
    6970 
     
    7475   * @throws IOException if the file cannot be read. 
    7576   */ 
    76   public ClassList(String file, Class base) throws IOException { 
     77  public ClassList(String file, Class<T> base) throws IOException { 
    7778    this(file, base, ClassList.class); 
    7879  } 
     
    8687   * @throws IOException if the file cannot be read. 
    8788   */ 
    88   public ClassList(String file, Class base, Class location) throws IOException { 
     89  public ClassList(String file, Class<T> base, Class<?> location) 
     90    throws IOException 
     91  { 
    8992    this.base = base; 
    90     classes = new Vector(); 
     93    classes = new ArrayList<Class<? extends T>>(); 
    9194    if (file == null) return; 
    9295 
     
    111114      if (line.equals("")) continue; 
    112115 
    113       // load reader class 
    114       Class c = null; 
    115       try { c = Class.forName(line); } 
     116      // load class 
     117      Class<? extends T> c = null; 
     118      try { 
     119        Class<?> rawClass = Class.forName(line); 
     120        c = cast(rawClass); 
     121      } 
    116122      catch (ClassNotFoundException exc) { 
    117123        LOGGER.debug("Could not find {}", line, exc); 
    118124      } 
    119125      catch (NoClassDefFoundError err) { 
    120         LOGGER.debug("Could not find{}", line, err); 
     126        LOGGER.debug("Could not find {}", line, err); 
    121127      } 
    122128      catch (ExceptionInInitializerError err) { 
     
    129135        LOGGER.debug("", exc); 
    130136      } 
    131       if (c == null || (base != null && !base.isAssignableFrom(c))) { 
     137      if (c == null) { 
    132138        LOGGER.error("\"{}\" is not valid.", line); 
    133139        continue; 
     
    143149   * Adds the given class, which must be assignable 
    144150   * to the base class, to the list. 
    145    * 
    146    * @throws FormatException if the class is not assignable to the base class. 
    147151   */ 
    148   public void addClass(Class c) throws FormatException { 
    149     if (base != null && !base.isAssignableFrom(c)) { 
    150       throw new FormatException( 
    151         "Class is not assignable to the base class"); 
    152     } 
     152  public void addClass(Class<? extends T> c) { 
    153153    classes.add(c); 
    154154  } 
    155155 
    156156  /** Removes the given class from the list. */ 
    157   public void removeClass(Class c) { 
     157  public void removeClass(Class<T> c) { 
    158158    classes.remove(c); 
    159159  } 
    160160 
    161161  /** Gets the list of classes as an array. */ 
    162   public Class[] getClasses() { 
    163     Class[] c = new Class[classes.size()]; 
    164     classes.copyInto(c); 
    165     return c; 
     162  @SuppressWarnings("unchecked") 
     163  public Class<? extends T>[] getClasses() { 
     164    return classes.toArray(new Class[0]); 
     165  } 
     166 
     167  // -- Helper methods -- 
     168 
     169  @SuppressWarnings("unchecked") 
     170  private Class<? extends T> cast(Class<?> rawClass) { 
     171    if (!rawClass.isAssignableFrom(base)) return null; 
     172    return (Class<? extends T>) rawClass; 
    166173  } 
    167174 
  • trunk/components/bio-formats/src/loci/formats/CoreMetadata.java

    r5743 r6141  
    127127 
    128128  /** Non-core metadata associated with this series. */ 
    129   public Hashtable seriesMetadata; 
     129  public Hashtable<String, Object> seriesMetadata; 
    130130 
    131131  /** 
     
    136136 
    137137  public CoreMetadata() { 
    138     seriesMetadata = new Hashtable(); 
     138    seriesMetadata = new Hashtable<String, Object>(); 
    139139  } 
    140140 
  • trunk/components/bio-formats/src/loci/formats/FileInfo.java

    r5447 r6141  
    3939 
    4040  /** IFormatReader implementation that would be used to read this file. */ 
    41   public Class reader; 
     41  public Class<?> reader; 
    4242 
    4343  /** 
     
    5353      "\nused to initialize = " + usedToInitialize; 
    5454  } 
     55 
    5556} 
  • trunk/components/bio-formats/src/loci/formats/FilePattern.java

    r6026 r6141  
    121121    // locate numerical blocks 
    122122    int len = pattern.length(); 
    123     Vector lt = new Vector(len); 
    124     Vector gt = new Vector(len); 
     123    Vector<Integer> lt = new Vector<Integer>(len); 
     124    Vector<Integer> gt = new Vector<Integer>(len); 
    125125    int left = -1; 
    126126    while (true) { 
     
    214214 
    215215    // build file listing 
    216     Vector v = new Vector(); 
     216    Vector<String> v = new Vector<String>(); 
    217217    buildFiles("", num, v); 
    218218    files = new String[v.size()]; 
     
    548548  /** Filters the given list of filenames according to the specified filter. */ 
    549549  private static String[] matchFiles(String[] inFiles, NumberFilter filter) { 
    550     Vector v = new Vector(); 
     550    Vector<String> v = new Vector<String>(); 
    551551    for (int i=0; i<inFiles.length; i++) { 
    552552      if (filter.accept(inFiles[i])) v.add(inFiles[i]); 
     
    560560 
    561561  /** Recursive method for building filenames for the file listing. */ 
    562   private void buildFiles(String prefix, int ndx, Vector fileList) { 
     562  private void buildFiles(String prefix, int ndx, Vector<String> fileList) { 
    563563    // compute bounds for constant (non-block) pattern fragment 
    564564    int num = startIndex.length; 
  • trunk/components/bio-formats/src/loci/formats/FileStitcher.java

    r6078 r6141  
    2727import java.io.IOException; 
    2828import java.math.BigInteger; 
     29import java.util.ArrayList; 
    2930import java.util.Arrays; 
    3031import java.util.HashMap; 
    3132import java.util.Hashtable; 
     33import java.util.List; 
    3234import java.util.Set; 
    3335import java.util.Vector; 
     
    118120 
    119121  private String[] seriesBlocks; 
    120   private Vector fileVector; 
     122  private Vector<String[]> fileVector; 
    121123  private Vector<String> seriesNames; 
    122124  private boolean seriesInFile; 
     
    723725    // this logic could fail if the first constituent has no extra used files, 
    724726    // but later constituents do; in practice, this scenario seems unlikely 
    725     Vector v = new Vector(); 
     727    Vector<String> v = new Vector<String>(); 
    726728    for (int i=0; i<files.length; i++) { 
    727729      for (int j=0; j<files[i].length; j++) { 
     
    816818 
    817819  /* @see IFormatReader#getGlobalMetadata() */ 
    818   public Hashtable getGlobalMetadata() { 
     820  public Hashtable<String, Object> getGlobalMetadata() { 
    819821    FormatTools.assertId(currentId, true, 2); 
    820822    return reader.getGlobalMetadata(); 
     
    822824 
    823825  /* @see IFormatReader#getSeriesMetadata() */ 
    824   public Hashtable getSeriesMetadata() { 
     826  public Hashtable<String, Object> getSeriesMetadata() { 
    825827    FormatTools.assertId(currentId, true, 2); 
    826828    return reader.getSeriesMetadata(); 
     
    828830 
    829831  /** @deprecated */ 
    830   public Hashtable getMetadata() { 
     832  public Hashtable<String, Object> getMetadata() { 
    831833    FormatTools.assertId(currentId, true ,2); 
    832834    return reader.getMetadata(); 
     
    870872  /* @see IFormatReader#getUnderlyingReaders() */ 
    871873  public IFormatReader[] getUnderlyingReaders() { 
    872     Vector v = new Vector(); 
     874    List<IFormatReader> list = new ArrayList<IFormatReader>(); 
    873875    for (int i=0; i<readers.length; i++) { 
    874876      for (int j=0; j<readers[i].length; j++) { 
    875         v.add(readers[i][j]); 
    876       } 
    877     } 
    878     return (IFormatReader[]) v.toArray(new IFormatReader[0]); 
     877        list.add(readers[i][j]); 
     878      } 
     879    } 
     880    return list.toArray(new IFormatReader[0]); 
    879881  } 
    880882 
     
    915917 
    916918  /* @see IFormatHandler#getNativeDataType() */ 
    917   public Class getNativeDataType() { 
     919  public Class<?> getNativeDataType() { 
    918920    FormatTools.assertId(currentId, true, 2); 
    919921    return reader.getNativeDataType(); 
     
    983985 
    984986      String[] blockPrefixes = fp.getPrefixes(); 
    985       Vector sBlock = new Vector(); 
     987      Vector<String> sBlock = new Vector<String>(); 
    986988 
    987989      for (int i=0; i<axes.length; i++) { 
     
    990992 
    991993      seriesBlocks = (String[]) sBlock.toArray(new String[0]); 
    992       fileVector = new Vector(); 
     994      fileVector = new Vector<String[]>(); 
    993995      seriesNames = new Vector<String>(); 
    994996 
     
    10031005      } 
    10041006 
    1005       Vector tmpFiles = new Vector(); 
     1007      Vector<String> tmpFiles = new Vector<String>(); 
    10061008      for (int i=0; i<fs.length; i++) { 
    10071009        if (fs[i].endsWith(ext)) tmpFiles.add(fs[i]); 
     
    10451047 
    10461048    // determine reader type for these files; assume all are the same type 
    1047     Class readerClass = reader.unwrap(files[0][0]).getClass(); 
     1049    Class<? extends IFormatReader> readerClass = 
     1050      reader.unwrap(files[0][0]).getClass(); 
    10481051 
    10491052    // construct list of readers for all files 
     
    13411344 
    13421345  private FilePattern getPattern(String[] f, String dir, String block) { 
    1343     Vector v = new Vector(); 
     1346    Vector<String> v = new Vector<String>(); 
    13441347    for (int i=0; i<f.length; i++) { 
    13451348      if (f[i].indexOf(File.separator) != -1) { 
  • trunk/components/bio-formats/src/loci/formats/FormatHandler.java

    r6128 r6141  
    8686 
    8787  /* @see IFormatHandler#getNativeDataType() */ 
    88   public Class getNativeDataType() { 
     88  public Class<?> getNativeDataType() { 
    8989    // NB: Handlers use byte arrays by default as the native type. 
    9090    return byte[].class; 
  • trunk/components/bio-formats/src/loci/formats/FormatReader.java

    r6082 r6141  
    174174 
    175175  /** Adds an entry to the specified Hashtable. */ 
    176   protected void addMeta(String key, Object value, Hashtable meta) { 
     176  protected void addMeta(String key, Object value, 
     177    Hashtable<String, Object> meta) 
     178  { 
    177179    if (key == null || value == null || !isMetadataCollected()) { 
    178180      return; 
     
    889891 
    890892  /* @see IFormatReader#getGlobalMetadata() */ 
    891   public Hashtable getGlobalMetadata() { 
     893  public Hashtable<String, Object> getGlobalMetadata() { 
    892894    FormatTools.assertId(currentId, true, 1); 
    893895    return metadata; 
     
    895897 
    896898  /* @see IFormatReader#getSeriesMetadata() */ 
    897   public Hashtable getSeriesMetadata() { 
     899  public Hashtable<String, Object> getSeriesMetadata() { 
    898900    FormatTools.assertId(currentId, true, 1); 
    899901    return core[series].seriesMetadata; 
     
    901903 
    902904  /** @deprecated */ 
    903   public Hashtable getMetadata() { 
    904     FormatTools.assertId(currentId, true, 1); 
    905     Hashtable h = new Hashtable(getGlobalMetadata()); 
     905  public Hashtable<String, Object> getMetadata() { 
     906    FormatTools.assertId(currentId, true, 1); 
     907    Hashtable<String, Object> h = 
     908      new Hashtable<String, Object>(getGlobalMetadata()); 
    906909    int oldSeries = getSeries(); 
    907910 
  • trunk/components/bio-formats/src/loci/formats/FormatTools.java

    r6118 r6141  
    773773    throws FormatException, IOException 
    774774  { 
    775     Vector filenames = new Vector(); 
     775    Vector<String> filenames = new Vector<String>(); 
    776776    String filename = null; 
    777777    for (int series=0; series<r.getSeriesCount(); series++) { 
     
    803803   * instance of the given class. 
    804804   */ 
    805   public static IFormatReader getReader(IFormatReader r, Class c) { 
     805  public static IFormatReader getReader(IFormatReader r, 
     806    Class<? extends IFormatReader> c) 
     807  { 
    806808    IFormatReader[] underlying = r.getUnderlyingReaders(); 
    807809    if (underlying != null) { 
  • trunk/components/bio-formats/src/loci/formats/IFormatHandler.java

    r6026 r6141  
    5151   * {@link java.awt.image.BufferedImage}. 
    5252   */ 
    53   Class getNativeDataType(); 
     53  Class<?> getNativeDataType(); 
    5454 
    5555  /** Sets the current file name. */ 
  • trunk/components/bio-formats/src/loci/formats/IFormatReader.java

    r6078 r6141  
    395395   * from the file 
    396396   */ 
    397   Hashtable getGlobalMetadata(); 
     397  Hashtable<String, Object> getGlobalMetadata(); 
    398398 
    399399  /** 
     
    404404   * @deprecated Use getGlobalMetadata() or getSeriesMetadata() instead. 
    405405   */ 
    406   Hashtable getMetadata(); 
     406  Hashtable<String, Object> getMetadata(); 
    407407 
    408408  /** 
     
    410410   * current series in the current file. 
    411411   */ 
    412   Hashtable getSeriesMetadata(); 
     412  Hashtable<String, Object> getSeriesMetadata(); 
    413413 
    414414  /** Obtains the core metadata values for the current file. */ 
  • trunk/components/bio-formats/src/loci/formats/ImageReader.java

    r6078 r6141  
    2525 
    2626import java.io.IOException; 
     27import java.util.ArrayList; 
    2728import java.util.Arrays; 
    2829import java.util.HashSet; 
    2930import java.util.Hashtable; 
     31import java.util.List; 
    3032import java.util.Set; 
    31 import java.util.Vector; 
    3233 
    3334import loci.common.Location; 
     
    6162 
    6263  /** Default list of reader classes, for use with noargs constructor. */ 
    63   private static ClassList defaultClasses; 
     64  private static ClassList<IFormatReader> defaultClasses; 
    6465 
    6566  // -- Static helper methods -- 
    6667 
    67   private static ClassList getDefaultReaderClasses() { 
     68  private static ClassList<IFormatReader> getDefaultReaderClasses() { 
    6869    if (defaultClasses == null) { 
    6970      // load built-in reader classes from readers.txt file 
    7071      try { 
    71         defaultClasses = new ClassList("readers.txt", IFormatReader.class); 
     72        defaultClasses = 
     73          new ClassList<IFormatReader>("readers.txt", IFormatReader.class); 
    7274      } 
    7375      catch (IOException exc) { 
    74         defaultClasses = new ClassList(IFormatReader.class); 
     76        defaultClasses = new ClassList<IFormatReader>(IFormatReader.class); 
    7577        LOGGER.info("Could not parse class list; using default classes", exc); 
    7678      } 
     
    107109 
    108110  /** Constructs a new ImageReader from the given list of reader classes. */ 
    109   public ImageReader(ClassList classList) { 
     111  public ImageReader(ClassList<IFormatReader> classList) { 
    110112    // add readers to the list 
    111     Vector v = new Vector(); 
    112     Class[] c = classList.getClasses(); 
     113    List<IFormatReader> list = new ArrayList<IFormatReader>(); 
     114    Class<? extends IFormatReader>[] c = classList.getClasses(); 
    113115    for (int i=0; i<c.length; i++) { 
    114116      IFormatReader reader = null; 
    115117      try { 
    116         reader = (IFormatReader) c[i].newInstance(); 
     118        reader = c[i].newInstance(); 
    117119      } 
    118120      catch (IllegalAccessException exc) { } 
     
    122124        continue; 
    123125      } 
    124       v.add(reader); 
    125     } 
    126     readers = new IFormatReader[v.size()]; 
    127     v.copyInto(readers); 
     126      list.add(reader); 
     127    } 
     128    readers = new IFormatReader[list.size()]; 
     129    list.toArray(readers); 
    128130  } 
    129131 
     
    168170 
    169171  /** Gets the file format reader instance matching the given class. */ 
    170   public IFormatReader getReader(Class c) { 
     172  public IFormatReader getReader(Class<? extends IFormatReader> c) { 
    171173    for (int i=0; i<readers.length; i++) { 
    172174      if (readers[i].getClass().equals(c)) return readers[i]; 
     
    453455 
    454456  /* @see IFormatReader#getGlobalMetadata() */ 
    455   public Hashtable getGlobalMetadata() { 
     457  public Hashtable<String, Object> getGlobalMetadata() { 
    456458    return getReader().getGlobalMetadata(); 
    457459  } 
    458460 
    459461  /* @see IFormatReader#getSeriesMetadata() */ 
    460   public Hashtable getSeriesMetadata() { 
     462  public Hashtable<String, Object> getSeriesMetadata() { 
    461463    return getReader().getSeriesMetadata(); 
    462464  } 
    463465 
    464466  /** @deprecated */ 
    465   public Hashtable getMetadata() { 
     467  public Hashtable<String, Object> getMetadata() { 
    466468    return getReader().getMetadata(); 
    467469  } 
     
    613615  public String[] getSuffixes() { 
    614616    if (suffixes == null) { 
    615       HashSet suffixSet = new HashSet(); 
     617      HashSet<String> suffixSet = new HashSet<String>(); 
    616618      for (int i=0; i<readers.length; i++) { 
    617619        String[] suf = readers[i].getSuffixes(); 
     
    626628 
    627629  /* @see IFormatHandler#getNativeDataType() */ 
    628   public Class getNativeDataType() { 
     630  public Class<?> getNativeDataType() { 
    629631    return getReader().getNativeDataType(); 
    630632  } 
  • trunk/components/bio-formats/src/loci/formats/ImageTools.java

    r5709 r6141  
    567567    for (int row=0; row<height; row++) { 
    568568      for (int col=0; col<width; col++) { 
    569         boolean evenRow = (row % 2) == 0; 
     569        //boolean evenRow = (row % 2) == 0; 
    570570        boolean evenCol = (col % 2) == 0; 
    571571 
  • trunk/components/bio-formats/src/loci/formats/ImageWriter.java

    r6026 r6141  
    2626import java.awt.image.ColorModel; 
    2727import java.io.IOException; 
     28import java.util.ArrayList; 
    2829import java.util.Arrays; 
    2930import java.util.HashSet; 
    30 import java.util.Vector; 
     31import java.util.List; 
    3132 
    3233import loci.formats.meta.MetadataRetrieve; 
     
    5657 
    5758  /** Default list of writer classes, for use with noargs constructor. */ 
    58   private static ClassList defaultClasses; 
     59  private static ClassList<IFormatWriter> defaultClasses; 
    5960 
    6061  // -- Static helper methods -- 
    6162 
    62   private static ClassList getDefaultWriterClasses() { 
     63  private static ClassList<IFormatWriter> getDefaultWriterClasses() { 
    6364    if (defaultClasses == null) { 
    6465      // load built-in writer classes from writers.txt file 
    6566      try { 
    66         defaultClasses = new ClassList("writers.txt", IFormatWriter.class); 
     67        defaultClasses = 
     68          new ClassList<IFormatWriter>("writers.txt", IFormatWriter.class); 
    6769      } 
    6870      catch (IOException exc) { 
    69         defaultClasses = new ClassList(IFormatWriter.class); 
     71        defaultClasses = new ClassList<IFormatWriter>(IFormatWriter.class); 
    7072        LOGGER.info("Could not parse class list; using default classes", exc); 
    7173      } 
     
    108110 
    109111  /** Constructs a new ImageWriter from the given list of writer classes. */ 
    110   public ImageWriter(ClassList classList) { 
     112  public ImageWriter(ClassList<IFormatWriter> classList) { 
    111113    // add writers to the list 
    112     Vector<IFormatWriter> v = new Vector<IFormatWriter>(); 
    113     Class<IFormatWriter>[] c = classList.getClasses(); 
     114    List<IFormatWriter> list = new ArrayList<IFormatWriter>(); 
     115    Class<? extends IFormatWriter>[] c = classList.getClasses(); 
    114116    for (int i=0; i<c.length; i++) { 
    115117      IFormatWriter writer = null; 
     
    123125        continue; 
    124126      } 
    125       v.add(writer); 
    126     } 
    127     writers = new IFormatWriter[v.size()]; 
    128     v.copyInto(writers); 
     127      list.add(writer); 
     128    } 
     129    writers = new IFormatWriter[list.size()]; 
     130    list.toArray(writers); 
    129131  } 
    130132 
     
    162164 
    163165  /** Gets the file format writer instance matching the given class. */ 
    164   public IFormatWriter getWriter(Class<IFormatWriter> c) { 
     166  public IFormatWriter getWriter(Class<? extends IFormatWriter> c) { 
    165167    for (int i=0; i<writers.length; i++) { 
    166168      if (writers[i].getClass().equals(c)) return writers[i]; 
     
    337339 
    338340  /* @see IFormatHandler#getNativeDataType() */ 
    339   public Class getNativeDataType() { 
     341  public Class<?> getNativeDataType() { 
    340342    return getWriter().getNativeDataType(); 
    341343  } 
  • trunk/components/bio-formats/src/loci/formats/MinMaxCalculator.java

    r5403 r6141  
    292292    int pixelType = getPixelType(); 
    293293 
    294     boolean fp = pixelType == FormatTools.FLOAT || 
    295       pixelType == FormatTools.DOUBLE; 
    296     boolean signed = pixelType == FormatTools.INT8 || 
    297       pixelType == FormatTools.INT16 || pixelType == FormatTools.INT32; 
     294    boolean signed = FormatTools.isSigned(pixelType); 
    298295 
    299296    long threshold = (long) Math.pow(2, bytes * 8 - 1); 
  • trunk/components/bio-formats/src/loci/formats/ReaderWrapper.java

    r6078 r6141  
    9696   *   {@link ImageReader}s. If null, the current id is used. 
    9797   */ 
    98   public IFormatReader unwrap(Class readerClass, String id) 
    99     throws FormatException, IOException 
     98  public IFormatReader unwrap(Class<? extends IFormatReader> readerClass, 
     99    String id) throws FormatException, IOException 
    100100  { 
    101101    IFormatReader r = this; 
     
    125125   * @throws FormatException If something goes wrong during the duplication. 
    126126   */ 
    127   public ReaderWrapper duplicate(Class imageReaderClass) 
    128     throws FormatException 
     127  public ReaderWrapper duplicate( 
     128    Class<? extends IFormatReader> imageReaderClass) throws FormatException 
    129129  { 
    130130    ReaderWrapper wrapperCopy = duplicateRecurse(imageReaderClass); 
     
    407407  } 
    408408 
    409   public Hashtable getGlobalMetadata() { 
     409  public Hashtable<String, Object> getGlobalMetadata() { 
    410410    return reader.getGlobalMetadata(); 
    411411  } 
    412412 
    413   public Hashtable getSeriesMetadata() { 
     413  public Hashtable<String, Object> getSeriesMetadata() { 
    414414    return reader.getSeriesMetadata(); 
    415415  } 
    416416 
    417417  /** @deprecated */ 
    418   public Hashtable getMetadata() { 
     418  public Hashtable<String, Object> getMetadata() { 
    419419    return reader.getMetadata(); 
    420420  } 
     
    474474  } 
    475475 
    476   public Class getNativeDataType() { 
     476  public Class<?> getNativeDataType() { 
    477477    return reader.getNativeDataType(); 
    478478  } 
     
    488488  // -- Helper methods -- 
    489489 
    490   private ReaderWrapper duplicateRecurse(Class imageReaderClass) 
    491     throws FormatException 
     490  private ReaderWrapper duplicateRecurse( 
     491    Class<? extends IFormatReader> imageReaderClass) throws FormatException 
    492492  { 
    493493    IFormatReader childCopy = null; 
     
    497497    } 
    498498    else { 
    499       Class c = null; 
     499      Class<? extends IFormatReader> c = null; 
    500500      if (reader instanceof ImageReader) { 
    501501        // found an image reader; if given, substitute the reader class 
     
    521521 
    522522    // use crazy reflection to instantiate a reader of the proper type 
    523     Class wrapperClass = getClass(); 
     523    Class<? extends ReaderWrapper> wrapperClass = getClass(); 
    524524    ReaderWrapper wrapperCopy = null; 
    525525    try { 
    526       wrapperCopy = (ReaderWrapper) wrapperClass.getConstructor(new Class[] 
     526      wrapperCopy = wrapperClass.getConstructor(new Class[] 
    527527        {IFormatReader.class}).newInstance(new Object[] {childCopy}); 
    528528    } 
  • trunk/components/bio-formats/src/loci/formats/WriterWrapper.java

    r6026 r6141  
    9292   *   {@link ImageWriter}s. If null, the current id is used. 
    9393   */ 
    94   public IFormatWriter unwrap(Class writerClass, String id) 
    95     throws FormatException, IOException 
     94  public IFormatWriter unwrap(Class<? extends IFormatWriter> writerClass, 
     95    String id) throws FormatException, IOException 
    9696  { 
    9797    IFormatWriter w = this; 
     
    121121   * @throws FormatException If something goes wrong during the duplication. 
    122122   */ 
    123   public WriterWrapper duplicate(Class imageWriterClass) 
    124     throws FormatException 
     123  public WriterWrapper duplicate( 
     124    Class<? extends IFormatWriter> imageWriterClass) throws FormatException 
    125125  { 
    126126    WriterWrapper wrapperCopy = duplicateRecurse(imageWriterClass); 
     
    238238  } 
    239239 
    240   public Class getNativeDataType() { 
     240  public Class<?> getNativeDataType() { 
    241241    return writer.getNativeDataType(); 
    242242  } 
     
    252252  // -- Helper methods -- 
    253253 
    254   private WriterWrapper duplicateRecurse(Class imageWriterClass) 
    255     throws FormatException 
     254  private WriterWrapper duplicateRecurse( 
     255    Class<? extends IFormatWriter> imageWriterClass) throws FormatException 
    256256  { 
    257257    IFormatWriter childCopy = null; 
     
    261261    } 
    262262    else { 
    263       Class c = null; 
     263      Class<? extends IFormatWriter> c = null; 
    264264      if (writer instanceof ImageWriter) { 
    265265        // found an image writer; if given, substitute the writer class 
     
    278278 
    279279    // use crazy reflection to instantiate a writer of the proper type 
    280     Class wrapperClass = getClass(); 
     280    Class<? extends WriterWrapper> wrapperClass = getClass(); 
    281281    WriterWrapper wrapperCopy = null; 
    282282    try { 
    283       wrapperCopy = (WriterWrapper) wrapperClass.getConstructor(new Class[] 
     283      wrapperCopy = wrapperClass.getConstructor(new Class[] 
    284284        {IFormatWriter.class}).newInstance(new Object[] {childCopy}); 
    285285    } 
  • trunk/components/bio-formats/src/loci/formats/cache/Cache.java

    r5191 r6141  
    6363 
    6464  /** List of cache event listeners. */ 
    65   protected Vector listeners; 
     65  protected Vector<CacheListener> listeners; 
    6666 
    6767  /** Whether the cache should automatically update when a parameter changes. */ 
     
    7979    this.source = source; 
    8080    this.autoUpdate = autoUpdate; 
    81     listeners = new Vector(); 
     81    listeners = new Vector<CacheListener>(); 
    8282    reset(); 
    8383    if (autoUpdate) recache(); 
     
    131131    synchronized (listeners) { 
    132132      for (int i=0; i<listeners.size(); i++) { 
    133         CacheListener l = (CacheListener) listeners.elementAt(i); 
     133        CacheListener l = listeners.elementAt(i); 
    134134        this.strategy.removeCacheListener(l); 
    135135        strategy.addCacheListener(l); 
     
    255255    synchronized (listeners) { 
    256256      for (int i=0; i<listeners.size(); i++) { 
    257         CacheListener l = (CacheListener) listeners.elementAt(i); 
     257        CacheListener l = listeners.elementAt(i); 
    258258        l.cacheUpdated(e); 
    259259      } 
  • trunk/components/bio-formats/src/loci/formats/in/BIFormatReader.java

    r5881 r6141  
    7575 
    7676  /* @see loci.formats.IFormatHandler#getNativeDataType() */ 
    77   public Class getNativeDataType() { 
     77  public Class<?> getNativeDataType() { 
    7878    return BufferedImage.class; 
    7979  } 
  • trunk/components/bio-formats/src/loci/formats/out/AVIWriter.java

    r6066 r6141  
    8888  private int microSecPerFrame; 
    8989 
    90   private Vector savedbLength; 
     90  private Vector<Long> savedbLength; 
    9191  private long idx1Pos; 
    9292  private long endPos; 
     
    136136      initialized = true; 
    137137      bytesPerPixel = nChannels == 2 ? 3 : nChannels; 
    138       savedbLength = new Vector(); 
     138      savedbLength = new Vector<Long>(); 
    139139 
    140140      out = new RandomAccessOutputStream(currentId); 
     
    510510      // AVIIF_TWOCC 2L 
    511511      // AVIIF_COMPUSE 0x0FFF0000L These bits are for compressor use. 
    512       out.writeInt((int) (((Long) 
    513         savedbLength.get(z)).longValue() - 4 - SAVE_MOVI)); 
     512      out.writeInt((int) (savedbLength.get(z) - 4 - SAVE_MOVI)); 
    514513 
    515514      // Write the offset (relative to the 'movi' field) to the relevant 
  • trunk/components/bio-formats/src/loci/formats/out/ICSWriter.java

    r6026 r6141  
    121121      } 
    122122 
    123       boolean signed = pixelType == FormatTools.INT8 || 
    124         pixelType == FormatTools.INT16 || pixelType == FormatTools.INT32; 
     123      boolean signed = FormatTools.isSigned(pixelType); 
    125124      boolean littleEndian = !meta.getPixelsBigEndian(series, 0).booleanValue(); 
    126125 
  • trunk/components/bio-formats/src/loci/formats/out/ImageIOWriter.java

    r5605 r6141  
    115115 
    116116  /* @see loci.formats.IFormatHandler#getNativeDataType() */ 
    117   public Class getNativeDataType() { 
     117  public Class<?> getNativeDataType() { 
    118118    return Image.class; 
    119119  } 
  • trunk/components/bio-formats/src/loci/formats/out/LegacyQTWriter.java

    r6026 r6141  
    297297 
    298298  /* @see loci.formats.IFormatHandler#getNativeDataType() */ 
    299   public Class getNativeDataType() { 
     299  public Class<?> getNativeDataType() { 
    300300    return Image.class; 
    301301  } 
  • trunk/components/bio-formats/src/loci/formats/out/OMEXMLWriter.java

    r6026 r6141  
    6161  // -- Fields -- 
    6262 
    63   private Vector xmlFragments; 
     63  private Vector<String> xmlFragments; 
    6464  private RandomAccessOutputStream out; 
    6565  private String currentFragment; 
     
    108108      } 
    109109 
    110       xmlFragments = new Vector(); 
     110      xmlFragments = new Vector<String>(); 
    111111      currentFragment = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; 
    112112      XMLTools.parseXML(xml, new OMEHandler()); 
     
    114114      xmlFragments.add(currentFragment); 
    115115 
    116       out.writeBytes((String) xmlFragments.get(0)); 
     116      out.writeBytes(xmlFragments.get(0)); 
    117117      initialized = true; 
    118118    } 
  • trunk/components/bio-formats/src/loci/formats/out/QTWriter.java

    r6026 r6141  
    108108 
    109109  /** Vector of plane offsets. */ 
    110   protected Vector offsets; 
     110  protected Vector<Integer> offsets; 
    111111 
    112112  /** Time the file was created. */ 
     
    209209      // -- write the header -- 
    210210 
    211       offsets = new Vector(); 
     211      offsets = new Vector<Integer>(); 
    212212      out = new RandomAccessOutputStream(currentId); 
    213213      created = (int) System.currentTimeMillis(); 
     
    240240 
    241241        for (int i=0; i<numWritten; i++) { 
    242           offsets.add(new Integer(16 + i * (buf.length + pad * height))); 
     242          offsets.add(16 + i * (buf.length + pad * height)); 
    243243        } 
    244244 
     
    248248      // -- write the first plane of pixel data (mdat) -- 
    249249 
    250       offsets.add(new Integer((int) out.length())); 
     250      offsets.add((int) out.length()); 
    251251    } 
    252252    else { 
     
    260260      out.seek(out.length()); 
    261261 
    262       offsets.add(new Integer(planeOffset + 16)); 
     262      offsets.add(planeOffset + 16); 
    263263    } 
    264264 
     
    574574      for (int i=0; i<numWritten; i++) { 
    575575        // write the plane offset 
    576         out.writeInt(((Integer) offsets.get(i)).intValue()); 
     576        out.writeInt(offsets.get(i)); 
    577577      } 
    578578 
  • trunk/components/bio-formats/src/loci/formats/tools/ImageInfo.java

    r6128 r6141  
    5454import loci.formats.gui.BufferedImageReader; 
    5555import loci.formats.gui.ImageViewer; 
     56import loci.formats.in.DefaultMetadataOptions; 
     57import loci.formats.in.MetadataLevel; 
     58import loci.formats.in.MetadataOptions; 
    5659import loci.formats.in.OMETiffReader; 
    5760import loci.formats.meta.MetadataRetrieve; 
     
    224227 
    225228  public void printUsage() { 
    226     String className = reader.getClass().getName(); 
    227229    String fmt = reader instanceof ImageReader ? "any" : reader.getFormat(); 
    228230    String[] s = { 
     
    274276      // create reader of a specific format type 
    275277      try { 
    276         Class c = Class.forName("loci.formats.in." + format + "Reader"); 
     278        Class<?> c = Class.forName("loci.formats.in." + format + "Reader"); 
    277279        reader = (IFormatReader) c.newInstance(); 
    278280      } 
     
    365367    reader.setNormalized(normalize); 
    366368    reader.setMetadataFiltered(filter); 
    367     reader.setMetadataCollected(doMeta); 
     369    MetadataOptions metaOptions = new DefaultMetadataOptions(doMeta ? 
     370      MetadataLevel.ALL : MetadataLevel.MINIMUM); 
     371    reader.setMetadataOptions(metaOptions); 
    368372  } 
    369373 
     
    669673    int sizeX = reader.getSizeX(); 
    670674    int sizeY = reader.getSizeY(); 
    671     int sizeC = reader.getSizeC(); 
    672  
    673675    if (width == 0) width = sizeX; 
    674676    if (height == 0) height = sizeY; 
     
    774776    LOGGER.info(""); 
    775777    LOGGER.info("Reading global metadata"); 
    776     Hashtable meta = reader.getGlobalMetadata(); 
     778    Hashtable<String, Object> meta = reader.getGlobalMetadata(); 
    777779    String[] keys = MetadataTools.keys(meta); 
    778780    for (String key : keys) { 
     
    786788    LOGGER.info(""); 
    787789    LOGGER.info("Reading{} metadata", seriesLabel); 
    788     Hashtable meta = reader.getSeriesMetadata(); 
     790    Hashtable<String, Object> meta = reader.getSeriesMetadata(); 
    789791    String[] keys = MetadataTools.keys(meta); 
    790792    for (int i=0; i<keys.length; i++) { 
  • trunk/components/loci-plugins/src/loci/plugins/util/ImageProcessorReader.java

    r6130 r6141  
    7575  public static ImageReader makeImageReader() { 
    7676    // include only enabled classes 
    77     Class<?>[] c = null; 
     77    Class<? extends IFormatReader>[] c = null; 
    7878    try { 
    79       ClassList defaultClasses = 
    80         new ClassList("readers.txt", IFormatReader.class); 
     79      ClassList<IFormatReader> defaultClasses = 
     80        new ClassList<IFormatReader>("readers.txt", IFormatReader.class); 
    8181      c = defaultClasses.getClasses(); 
    8282    } 
     
    8484      return new ImageReader(); 
    8585    } 
    86     ClassList enabledClasses = new ClassList(IFormatReader.class); 
     86    ClassList<IFormatReader> enabledClasses = 
     87      new ClassList<IFormatReader>(IFormatReader.class); 
    8788    for (int i=0; i<c.length; i++) { 
    8889      boolean on = LociPrefs.isReaderEnabled(c[i]); 
    89       if (on) { 
    90         try { 
    91           enabledClasses.addClass(c[i]); 
    92         } 
    93         catch (FormatException exc) { 
    94           exc.printStackTrace(); 
    95         } 
    96       } 
     90      if (on) enabledClasses.addClass(c[i]); 
    9791    } 
    9892    ImageReader reader = new ImageReader(enabledClasses); 
  • trunk/components/native/jar2lib/Jar2Lib.java

    r6134 r6141  
    5050* 
    5151* <dl><dt><b>Source code:</b></dt> 
    52 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/bio-formats/auto/Jar2Lib.java">Trac</a>, 
    53 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/auto/Jar2Lib.java">SVN</a></dd></dl> 
     52* <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/native/jar2lib/Jar2Lib.java">Trac</a>, 
     53* <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/native/jar2lib/Jar2Lib.java">SVN</a></dd></dl> 
    5454* 
    5555* @author Brian Selinsky bselinsky at wisc.edu 
Note: See TracChangeset for help on using the changeset viewer.