Changeset 2274


Ignore:
Timestamp:
02/15/07 13:25:52 (13 years ago)
Author:
curtis
Message:

Throw a nicer exception if OME-Java is not present.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/OMEXMLReader.java

    r2220 r2274  
    3838 */ 
    3939public class OMEXMLReader extends FormatReader { 
     40 
     41  // -- Constants -- 
     42 
     43  private static final String NO_OME_JAVA_MSG = 
     44    "The Java OME-XML library is required to read OME-XML files. Please " + 
     45    "obtain ome-java.jar from http://loci.wisc.edu/ome/loci-ome-xml.html"; 
     46 
     47  // -- Static fields -- 
     48 
     49  private static boolean noOME = false; 
     50 
     51  static { 
     52    try { 
     53      Class.forName("org.openmicroscopy.xml.OMENode"); 
     54    } 
     55    catch (Throwable t) { 
     56      noOME = true; 
     57    } 
     58  } 
    4059 
    4160  // -- Fields -- 
     
    210229  /** Closes any open files. */ 
    211230  public void close() throws FormatException, IOException { 
     231    if (noOME) throw new FormatException(NO_OME_JAVA_MSG); 
    212232    if (in != null) in.close(); 
    213233    in = null; 
     
    220240  protected void initFile(String id) throws FormatException, IOException { 
    221241    if (debug) debug("OMEXMLReader.initFile(" + id + ")"); 
     242    if (noOME) throw new FormatException(NO_OME_JAVA_MSG); 
    222243    close(); 
    223244    currentId = id; 
Note: See TracChangeset for help on using the changeset viewer.