Changeset 5898 for branches/cleanup


Ignore:
Timestamp:
02/11/10 09:30:43 (10 years ago)
Author:
callan
Message:

#464 OME-XML and OME Notes services "for real"

  • Moved ServiceFactory and relevant interfaces into the common component
  • Services are now configured via the common component
  • Removed all ReflectedUniverse usage from MetadataTools
  • Re-organized OMEXMLMetadata hierarchy to use interfaces more effectively
Location:
branches/cleanup/components
Files:
1 added
1 deleted
20 edited
1 copied
7 moved

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/bio-formats/src/loci/formats/FormatReader.java

    r5852 r5898  
    3131import loci.common.Location; 
    3232import loci.common.RandomAccessInputStream; 
     33import loci.common.dependency.DependencyException; 
     34import loci.common.dependency.ServiceFactory; 
    3335import loci.formats.meta.DummyMetadata; 
    3436import loci.formats.meta.IMetadata; 
    3537import loci.formats.meta.MetadataStore; 
     38import loci.formats.ome.OMEXMLMetadata; 
     39import loci.formats.ome.OMEXMLService; 
    3640 
    3741/** 
     
    213217    if (saveOriginalMetadata && simple && meta.equals(metadata)) { 
    214218      MetadataStore store = getMetadataStore(); 
    215       if (MetadataTools.isOMEXMLMetadata(store)) { 
    216         MetadataTools.populateOriginalMetadata(store, key, value.toString()); 
     219      if (store instanceof OMEXMLMetadata) { 
     220        try { 
     221          ServiceFactory factory = new ServiceFactory(); 
     222          OMEXMLService service = factory.getInstance(OMEXMLService.class); 
     223          service.populateOriginalMetadata( 
     224              (OMEXMLMetadata) store, key, value.toString()); 
     225        } 
     226        catch (DependencyException e) { 
     227          LOGGER.warn("OMEXMLService not available.", e); 
     228        } 
    217229      } 
    218230    } 
  • branches/cleanup/components/bio-formats/src/loci/formats/FormatTools.java

    r5634 r5898  
    696696  { 
    697697    MetadataStore store = r.getMetadataStore(); 
    698     MetadataRetrieve retrieve = MetadataTools.asRetrieve(store); 
    699     if (retrieve == null) retrieve = new DummyMetadata(); 
     698    MetadataRetrieve retrieve =  
     699      store instanceof MetadataRetrieve? (MetadataRetrieve) store 
     700          : new DummyMetadata(); 
    700701 
    701702    String filename = pattern.replaceAll(SERIES_NUM, String.valueOf(series)); 
  • branches/cleanup/components/bio-formats/src/loci/formats/MetadataTools.java

    r5852 r5898  
    2424package loci.formats; 
    2525 
    26 import java.io.IOException; 
    2726import java.util.Arrays; 
    2827import java.util.Hashtable; 
    2928 
    30 import javax.xml.parsers.ParserConfigurationException; 
    31 import javax.xml.transform.Templates; 
    32 import javax.xml.transform.TransformerConfigurationException; 
    33 import javax.xml.transform.TransformerException; 
    34  
    3529import loci.common.DateTools; 
    3630import loci.common.Location; 
    37 import loci.common.ReflectException; 
    38 import loci.common.ReflectedUniverse; 
    39 import loci.common.xml.XMLTools; 
    40 import loci.formats.meta.IMetadata; 
    41 import loci.formats.meta.MetadataConverter; 
    4231import loci.formats.meta.MetadataRetrieve; 
    4332import loci.formats.meta.MetadataStore; 
     
    4534import org.slf4j.Logger; 
    4635import org.slf4j.LoggerFactory; 
    47  
    48 import org.w3c.dom.Document; 
    49 import org.w3c.dom.Node; 
    50 import org.w3c.dom.NodeList; 
    51 import org.xml.sax.SAXException; 
    5236 
    5337 
     
    7256  // -- Static fields -- 
    7357 
    74   private static Templates reorderXSLT = 
    75     XMLTools.getStylesheet("meta/reorder-2008-09.xsl", MetadataTools.class); 
    76  
    7758  // -- Constructor -- 
    7859 
     
    8061 
    8162  // -- Utility methods - OME-XML -- 
    82  
    83   /** 
    84    * Retrieves the latest supported version of the OME-XML schema. 
    85    */ 
    86   public static String getLatestVersion() { 
    87     ReflectedUniverse r = new ReflectedUniverse(); 
    88     try { 
    89       r.exec("import ome.xml.OMEXMLFactory"); 
    90       return (String) r.exec("OMEXMLFactory.LATEST_VERSION"); 
    91     } 
    92     catch (ReflectException e) { 
    93       LOGGER.debug("Could not retrieve OME-XML version", e); 
    94     } 
    95     return null; 
    96   } 
    97  
    98   /** 
    99    * Creates an OME-XML metadata object using reflection, to avoid 
    100    * direct dependencies on the optional {@link loci.formats.ome} package. 
    101    * @return A new instance of {@link loci.formats.ome.OMEXMLMetadata}, 
    102    *   or null if the class is not available. 
    103    */ 
    104   public static IMetadata createOMEXMLMetadata() { 
    105     return createOMEXMLMetadata(null); 
    106   } 
    107  
    108   /** 
    109    * Creates an OME-XML metadata object using reflection, to avoid 
    110    * direct dependencies on the optional {@link loci.formats.ome} package, 
    111    * wrapping a DOM representation of the given OME-XML string. 
    112    * @return A new instance of {@link loci.formats.ome.OMEXMLMetadata}, 
    113    *   or null if the class is not available. 
    114    */ 
    115   public static IMetadata createOMEXMLMetadata(String xml) { 
    116     return createOMEXMLMetadata(xml, null); 
    117   } 
    118  
    119   /** 
    120    * Creates an OME-XML metadata object using reflection, to avoid 
    121    * direct dependencies on the optional {@link loci.formats.ome} package, 
    122    * wrapping a DOM representation of the given OME-XML string. 
    123    * 
    124    * @param xml The OME-XML string to use for initial population of the 
    125    *   metadata object. 
    126    * @param version The OME-XML version to use (e.g., "2003-FC" or "2007-06"). 
    127    *   If the xml and version parameters are both null, the newest version is 
    128    *   used. 
    129    * @return A new instance of {@link loci.formats.ome.OMEXMLMetadata}, 
    130    *   or null if the class is not available. 
    131    */ 
    132   public static IMetadata createOMEXMLMetadata(String xml, String version) { 
    133     Object ome = null; 
    134     IMetadata meta = null; 
    135     ReflectedUniverse r = new ReflectedUniverse(); 
    136     try { 
    137       ome = createOMEXMLRoot(xml); 
    138       if (version == null) { 
    139         if (ome == null) { 
    140           // default to newest schema version 
    141           version = getLatestVersion(); 
    142         } 
    143         else { 
    144           // extract schema version from OME root node 
    145           r.setVar("ome", ome); 
    146           version = getOMEXMLVersion(ome); 
    147         } 
    148       } 
    149  
    150       // create metadata object of the appropriate schema version 
    151       String metaClass = "OMEXML" + 
    152         version.replaceAll("[^\\w]", "") + "Metadata"; 
    153       r.exec("import loci.formats.ome." + metaClass); 
    154       meta = (IMetadata) r.exec("new " + metaClass + "()"); 
    155  
    156       // attach OME root node to metadata object 
    157       if (ome != null) meta.setRoot(ome); 
    158     } 
    159     catch (ReflectException exc) { 
    160       LOGGER.debug("Could not create root node", exc); 
    161     } 
    162     if (ome == null) meta.createRoot(); 
    163     return meta; 
    164   } 
    165  
    166   /** 
    167    * Constructs an OME root node (ome.xml.OMEXMLNode subclass) 
    168    * of the appropriate schema version from the given XML string. 
    169    */ 
    170   public static Object createOMEXMLRoot(String xml) { 
    171     if (xml == null) return null; 
    172     ReflectedUniverse r = new ReflectedUniverse(); 
    173     try { 
    174       r.exec("import ome.xml.OMEXMLFactory"); 
    175       r.setVar("xml", xml); 
    176       return r.exec("OMEXMLFactory.newOMENodeFromSource(xml)"); 
    177     } 
    178     catch (ReflectException exc) { 
    179       LOGGER.debug("Could not create root node", exc); 
    180     } 
    181     return null; 
    182   } 
    183  
    184   /** 
    185    * Checks whether the given object is an OME-XML metadata object. 
    186    * @return True iff the object is an instance of 
    187    *   {@link loci.formats.ome.OMEXMLMetadata}. 
    188    */ 
    189   public static boolean isOMEXMLMetadata(Object o) { 
    190     return isInstance(o, "loci.formats.ome", "OMEXMLMetadata"); 
    191   } 
    192  
    193   /** 
    194    * Checks whether the given object is an OME-XML root object. 
    195    * @return True iff the object is an instance of ome.xml.OMEXMLNode. 
    196    */ 
    197   public static boolean isOMEXMLRoot(Object o) { 
    198     return isInstance(o, "ome.xml", "OMEXMLNode"); 
    199   } 
    200  
    201   /** 
    202    * Gets the schema version for the given OME-XML metadata or root object 
    203    * (e.g., "2007-06" or "2003-FC"). 
    204    * @return OME-XML schema version, or null if the object is not an instance 
    205    *   of {@link loci.formats.ome.OMEXMLMetadata} or ome.xml.OMEXMLNode. 
    206    */ 
    207   public static String getOMEXMLVersion(Object o) { 
    208     if (o == null) return null; 
    209     String name = o.getClass().getName(); 
    210     if (isOMEXMLMetadata(o)) { 
    211       final String prefix = "loci.formats.ome.OMEXML"; 
    212       final String suffix = "Metadata"; 
    213       if (name.startsWith(prefix) && name.endsWith(suffix)) { 
    214         String numbers = 
    215           name.substring(prefix.length(), name.length() - suffix.length()); 
    216         if (numbers.length() == 6) { 
    217           return numbers.substring(0, 4) + "-" + 
    218             numbers.substring(4, 6).toUpperCase(); 
    219         } 
    220       } 
    221     } 
    222     else if (isOMEXMLRoot(o)) { 
    223       ReflectedUniverse r = new ReflectedUniverse(); 
    224       r.setVar("ome", o); 
    225       try { 
    226         return (String) r.exec("ome.getVersion()"); 
    227       } 
    228       catch (ReflectException exc) { 
    229         LOGGER.debug("Could not retrieve OME-XML version", exc); 
    230       } 
    231     } 
    232     return null; 
    233   } 
    234  
    235   /** 
    236    * Returns a {@link loci.formats.ome.OMEXMLMetadata} object with the same 
    237    * contents as the given MetadataRetrieve, converting it if necessary. 
    238    */ 
    239   public static IMetadata getOMEMetadata(MetadataRetrieve src) { 
    240     // check if the metadata is already an OME-XML metadata object 
    241     if (isOMEXMLMetadata(src)) return (IMetadata) src; 
    242  
    243     // populate a new OME-XML metadata object with metadata 
    244     // converted from the non-OME-XML metadata object 
    245     IMetadata omexmlMeta = createOMEXMLMetadata(); 
    246     convertMetadata(src, omexmlMeta); 
    247     return omexmlMeta; 
    248   } 
    249  
    250   /** 
    251    * If the given IMetadata is an instance of 
    252    * {@link loci.formats.ome.OMEXMLMetadata}, the OriginalMetadata hashtable 
    253    * is returned. Otherwise, returns null. 
    254    */ 
    255   public static Hashtable<String, String> getOriginalMetadata(IMetadata src) { 
    256     if (isOMEXMLMetadata(src)) { 
    257       ReflectedUniverse r = new ReflectedUniverse(); 
    258       r.setVar("omexml", src); 
    259       try { 
    260         return 
    261           (Hashtable<String, String>) r.exec("omexml.getOriginalMetadata()"); 
    262       } 
    263       catch (ReflectException exc) { 
    264         LOGGER.debug("Could not retrieve original metadata", exc); 
    265       } 
    266     } 
    267     return null; 
    268   } 
    269  
    270   /** 
    271    * Extracts an OME-XML metadata string from the given metadata object, 
    272    * by converting to an OME-XML metadata object if necessary. 
    273    */ 
    274   public static String getOMEXML(MetadataRetrieve src) { 
    275     IMetadata omexmlMeta = getOMEMetadata(src); 
    276     ReflectedUniverse r = new ReflectedUniverse(); 
    277     r.setVar("omexmlMeta", omexmlMeta); 
    278     String xml = null; 
    279     try { 
    280       xml = (String) r.exec("omexmlMeta.dumpXML()"); 
    281     } 
    282     catch (ReflectException exc) { 
    283       LOGGER.debug("Could not retrieve OME-XML", exc); 
    284     } 
    285     String reordered = null; 
    286     try { 
    287       reordered = XMLTools.transformXML(xml, reorderXSLT); 
    288     } 
    289     catch (IOException exc) { 
    290       LOGGER.debug("Could not transform OME-XML", exc); 
    291     } 
    292     return reordered == null ? xml : reordered; 
    293   } 
    294  
    295   /** 
    296    * Attempts to validate the given OME-XML string using 
    297    * Java's XML validation facility. Requires Java 1.5+. 
    298    * 
    299    * @param xml XML string to validate. 
    300    * @return true if the XML successfully validates. 
    301    */ 
    302   public static boolean validateOMEXML(String xml) { 
    303     return validateOMEXML(xml, false); 
    304   } 
    305  
    306   /** 
    307    * Attempts to validate the given OME-XML string using 
    308    * Java's XML validation facility. Requires Java 1.5+. 
    309    * 
    310    * @param xml XML string to validate. 
    311    * @param pixelsHack Whether to ignore validation errors 
    312    *   due to childless Pixels elements 
    313    * @return true if the XML successfully validates. 
    314    */ 
    315   public static boolean validateOMEXML(String xml, boolean pixelsHack) { 
    316     // HACK: Inject a TiffData element beneath any childless Pixels elements. 
    317     if (pixelsHack) { 
    318       // convert XML string to DOM 
    319       Document doc = null; 
    320       Exception exception = null; 
    321       try { 
    322         doc = XMLTools.parseDOM(xml); 
    323       } 
    324       catch (ParserConfigurationException exc) { exception = exc; } 
    325       catch (SAXException exc) { exception = exc; } 
    326       catch (IOException exc) { exception = exc; } 
    327       if (exception != null) { 
    328         LOGGER.info("Malformed OME-XML", exception); 
    329         return false; 
    330       } 
    331  
    332       // inject TiffData elements as needed 
    333       NodeList list = doc.getElementsByTagName("Pixels"); 
    334       for (int i=0; i<list.getLength(); i++) { 
    335         Node node = list.item(i); 
    336         NodeList children = node.getChildNodes(); 
    337         boolean needsTiffData = true; 
    338         for (int j=0; j<children.getLength(); j++) { 
    339           Node child = children.item(j); 
    340           String name = child.getLocalName(); 
    341           if ("TiffData".equals(name) || "BinData".equals(name)) { 
    342             needsTiffData = false; 
    343             break; 
    344           } 
    345         } 
    346         if (needsTiffData) { 
    347           // inject TiffData element 
    348           Node tiffData = doc.createElement("TiffData"); 
    349           node.insertBefore(tiffData, node.getFirstChild()); 
    350         } 
    351       } 
    352  
    353       // convert tweaked DOM back to XML string 
    354       try { 
    355         xml = XMLTools.getXML(doc); 
    356       } 
    357       catch (TransformerConfigurationException exc) { exception = exc; } 
    358       catch (TransformerException exc) { exception = exc; } 
    359       if (exception != null) { 
    360         LOGGER.info("Internal XML conversion error", exception); 
    361         return false; 
    362       } 
    363     } 
    364     return XMLTools.validateXML(xml, "OME-XML"); 
    365   } 
    36663 
    36764  /** 
     
    475172          "call IFormatWriter.setMetadataRetrieve() first"); 
    476173    } 
    477     MetadataStore store = asStore(src); 
    478     if (store != null && store.getRoot() == null) { 
     174    if (src instanceof MetadataStore 
     175        && ((MetadataStore) src).getRoot() == null) { 
    479176      throw new FormatException("Metadata object has null root; " + 
    480177        "call IMetadata.createRoot() first"); 
     
    520217      series); 
    521218  } 
    522  
    523   /** 
    524    * Adds the specified key/value pair as a new OriginalMetadata node 
    525    * to the given OME-XML metadata object. 
    526    * Does nothing unless the given object is an OME-XML metadata object. 
    527    * @param omexmlMeta An object of type 
    528    *   {@link loci.formats.ome.OMEXMLMetadata}. 
    529    * @param key Metadata key to populate. 
    530    * @param value Metadata value corresponding to the specified key. 
    531    */ 
    532   public static void populateOriginalMetadata(Object omexmlMeta, 
    533     String key, String value) 
    534   { 
    535     ReflectedUniverse r = new ReflectedUniverse(); 
    536     r.setVar("omexmlMeta", omexmlMeta); 
    537     r.setVar("key", key); 
    538     r.setVar("value", value); 
    539     try { 
    540       r.exec("omexmlMeta.setOriginalMetadata(key, value)"); 
    541     } 
    542     catch (ReflectException exc) { 
    543       LOGGER.debug("Failed to set original metadata", exc); 
    544     } 
    545   } 
    546  
    547   /** 
    548    * Gets the value for the specified OriginalMetadata key 
    549    * from the given OME-XML metadata object. 
    550    * Does nothing unless the given object is an OME-XML metadata object. 
    551    * @param omexmlMeta An object of type 
    552    *   {@link loci.formats.ome.OMEXMLMetadata}. 
    553    * @param key Metadata key whose value is needed. 
    554    * @return Metadata value corresponding to the specified key. 
    555    */ 
    556   public static String getOriginalMetadata(Object omexmlMeta, String key) { 
    557     ReflectedUniverse r = new ReflectedUniverse(); 
    558     r.setVar("omexmlMeta", omexmlMeta); 
    559     r.setVar("key", key); 
    560     try { 
    561       return (String) r.exec("omexmlMeta.getOriginalMetadata(key)"); 
    562     } 
    563     catch (ReflectException exc) { 
    564       LOGGER.debug("Failed to retrieve original metadata '{}'", key, exc); 
    565     } 
    566     return null; 
    567   } 
    568  
    569   // -- Utility methods -- metadata conversion -- 
    570  
    571   /** 
    572    * Converts information from an OME-XML string (source) 
    573    * into a metadata store (destination). 
    574    */ 
    575   public static void convertMetadata(String xml, MetadataStore dest) { 
    576     Object ome = createOMEXMLRoot(xml); 
    577     String rootVersion = getOMEXMLVersion(ome); 
    578     String storeVersion = getOMEXMLVersion(dest); 
    579     if (rootVersion.equals(storeVersion)) { 
    580       // metadata store is already an OME-XML metadata object of the 
    581       // correct schema version; populate OME-XML string directly 
    582       ReflectedUniverse r = new ReflectedUniverse(); 
    583       try { 
    584         r.setVar("xml", xml); 
    585         r.setVar("omexmlMeta", dest); 
    586         r.exec("omexmlMeta.createRoot(xml)"); 
    587       } 
    588       catch (ReflectException exc) { 
    589         LOGGER.debug("Could not convert MetadataStore", exc); 
    590       } 
    591     } 
    592     else { 
    593       // metadata store is incompatible; create an OME-XML 
    594       // metadata object and copy it into the destination 
    595       IMetadata src = createOMEXMLMetadata(xml); 
    596       convertMetadata(src, dest); 
    597     } 
    598   } 
    599  
    600   /** 
    601    * Copies information from a metadata retrieval object 
    602    * (source) into a metadata store (destination). 
    603    */ 
    604   public static void convertMetadata(MetadataRetrieve src, MetadataStore dest) { 
    605     MetadataConverter.convertMetadata(src, dest); 
    606   } 
    607  
    608   // -- Utility methods - casting -- 
    609  
    610   /** 
    611    * Gets the given {@link MetadataRetrieve} object as a {@link MetadataStore}. 
    612    * Returns null if the object is incompatible and cannot be casted. 
    613    */ 
    614   public static MetadataStore asStore(MetadataRetrieve meta) { 
    615     return meta instanceof MetadataStore ? (MetadataStore) meta : null; 
    616   } 
    617  
    618   /** 
    619    * Gets the given {@link MetadataStore} object as a {@link MetadataRetrieve}. 
    620    * Returns null if the object is incompatible and cannot be casted. 
    621    */ 
    622   public static MetadataRetrieve asRetrieve(MetadataStore meta) { 
    623     return meta instanceof MetadataRetrieve ? (MetadataRetrieve) meta : null; 
    624   } 
    625  
    626219  // -- Utility methods - original metadata -- 
    627220 
     
    634227  } 
    635228 
    636   // -- Helper methods -- 
    637  
    638   /** 
    639    * Checks whether the given object is an instance of the specified class. 
    640    * @return True iff the object is an instance of the given class 
    641    *   from the specified package. 
    642    */ 
    643   private static boolean isInstance(Object o, 
    644     String packageName, String className) 
    645   { 
    646     ReflectedUniverse r = new ReflectedUniverse(); 
    647     try { 
    648       r.exec("import " + packageName + "." + className); 
    649       Class c = (Class) r.getVar(className); 
    650       return c.isInstance(o); 
    651     } 
    652     catch (ReflectException exc) { 
    653       LOGGER.debug("", exc); 
    654     } 
    655     return false; 
    656   } 
    657  
    658229} 
  • branches/cleanup/components/bio-formats/src/loci/formats/enums/EnumerationProvider.java

    r5644 r5898  
    2727import java.util.List; 
    2828 
     29import org.slf4j.Logger; 
     30import org.slf4j.LoggerFactory; 
     31 
     32import loci.common.dependency.DependencyException; 
     33import loci.common.dependency.ServiceFactory; 
    2934import loci.formats.MetadataTools; 
     35import loci.formats.MissingLibraryException; 
    3036import loci.formats.enums.handler.HandlerFactory; 
    3137import loci.formats.enums.handler.IEnumerationHandler; 
     38import loci.formats.ome.OMEXMLMetadata; 
     39import loci.formats.ome.OMEXMLService; 
     40import loci.formats.tools.ImageConverter; 
    3241 
    3342/** 
     
    4150public class EnumerationProvider implements IEnumerationProvider { 
    4251 
     52  // -- Constants -- 
     53 
     54  private static final Logger LOGGER = 
     55    LoggerFactory.getLogger(EnumerationProvider.class); 
     56 
    4357  // -- Fields -- 
    4458 
     
    4963 
    5064  /** Construct a new EnumerationProvider using the latest supported schema. */ 
    51   public EnumerationProvider() { 
    52     this(MetadataTools.getLatestVersion()); 
     65  public EnumerationProvider() throws DependencyException { 
     66    ServiceFactory factory = new ServiceFactory(); 
     67    OMEXMLService service = factory.getInstance(OMEXMLService.class); 
     68    this.schema = service.getLatestVersion(); 
    5369  } 
    5470 
  • branches/cleanup/components/bio-formats/src/loci/formats/in/OMETiffReader.java

    r5852 r5898  
    3232import java.util.Vector; 
    3333 
     34import javax.xml.parsers.ParserConfigurationException; 
     35 
     36import org.xml.sax.SAXException; 
     37 
    3438import loci.common.Location; 
    3539import loci.common.RandomAccessInputStream; 
     40import loci.common.dependency.DependencyException; 
     41import loci.common.dependency.ServiceFactory; 
    3642import loci.formats.CoreMetadata; 
    3743import loci.formats.FormatException; 
     
    3945import loci.formats.FormatTools; 
    4046import loci.formats.IFormatReader; 
    41 import loci.formats.MetadataTools; 
    42 import loci.formats.meta.IMetadata; 
     47import loci.formats.MissingLibraryException; 
     48import loci.formats.ome.OMEXMLMetadata; 
     49import loci.formats.ome.OMEXMLService; 
    4350import loci.formats.tiff.IFD; 
    4451import loci.formats.tiff.IFDList; 
     
    5764public class OMETiffReader extends FormatReader { 
    5865 
     66  // -- Constants -- 
     67   
     68  public static final String MISSING_OME_XML_JAR = 
     69    "ome-xml.jar is required to read OME-TIFF files.  Please download " + 
     70    "it from http://loci.wisc.edu/ome/formats-library.html"; 
     71 
    5972  // -- Fields -- 
    6073 
     
    89102    ras.close(); 
    90103    String xml = ifds.get(0).getComment(); 
    91     IMetadata meta = MetadataTools.createOMEXMLMetadata(xml); 
    92  
    93     if (meta == null) { 
    94       throw new FormatException("ome-xml.jar is required to read OME-TIFF " + 
    95         "files.  Please download it from " + 
    96         "http://loci.wisc.edu/ome/formats-library.html"); 
    97     } 
    98  
    99     if (meta.getRoot() == null) { 
     104    OMEXMLMetadata omexmlMeta; 
     105    try { 
     106      ServiceFactory factory = new ServiceFactory(); 
     107      OMEXMLService service = factory.getInstance(OMEXMLService.class); 
     108      omexmlMeta = service.createOMEXMLMetadata(xml); 
     109    } 
     110    catch (DependencyException de) { 
     111      throw new MissingLibraryException(MISSING_OME_XML_JAR, de); 
     112    } 
     113    catch (ParserConfigurationException pce) { 
     114      throw new FormatException(pce); 
     115    } 
     116    catch (SAXException se) { 
     117      throw new FormatException(se); 
     118    } 
     119 
     120    if (omexmlMeta.getRoot() == null) { 
    100121      throw new FormatException("Could not parse OME-XML from TIFF comment"); 
    101122    } 
    102123 
    103124    int nImages = 0; 
    104     for (int i=0; i<meta.getImageCount(); i++) { 
    105       int nChannels = meta.getLogicalChannelCount(i); 
     125    for (int i=0; i<omexmlMeta.getImageCount(); i++) { 
     126      int nChannels = omexmlMeta.getLogicalChannelCount(i); 
    106127      if (nChannels == 0) nChannels = 1; 
    107       for (int p=0; p<meta.getPixelsCount(i); p++) { 
    108         int z = meta.getPixelsSizeZ(i, p).intValue(); 
    109         int t = meta.getPixelsSizeT(i, p).intValue(); 
     128      for (int p=0; p<omexmlMeta.getPixelsCount(i); p++) { 
     129        int z = omexmlMeta.getPixelsSizeZ(i, p).intValue(); 
     130        int t = omexmlMeta.getPixelsSizeT(i, p).intValue(); 
    110131        nImages += z * t * nChannels; 
    111132      } 
     
    213234    ras.close(); 
    214235    String xml = firstIFD.getComment(); 
    215     IMetadata meta = MetadataTools.createOMEXMLMetadata(xml); 
    216  
    217     hasSPW = meta.getPlateCount() > 0; 
    218  
    219     Hashtable originalMetadata = MetadataTools.getOriginalMetadata(meta); 
     236    OMEXMLMetadata omexmlMeta; 
     237    OMEXMLService service; 
     238    try { 
     239      ServiceFactory factory = new ServiceFactory(); 
     240      service = factory.getInstance(OMEXMLService.class); 
     241      omexmlMeta = service.createOMEXMLMetadata(xml); 
     242    } 
     243    catch (DependencyException de) { 
     244      throw new MissingLibraryException(MISSING_OME_XML_JAR, de); 
     245    } 
     246    catch (ParserConfigurationException pce) { 
     247      throw new FormatException(pce); 
     248    } 
     249    catch (SAXException se) { 
     250      throw new FormatException(se); 
     251    } 
     252 
     253    hasSPW = omexmlMeta.getPlateCount() > 0; 
     254 
     255    Hashtable originalMetadata = omexmlMeta.getOriginalMetadata(); 
    220256    if (originalMetadata != null) metadata = originalMetadata; 
    221257 
    222258    LOGGER.trace(xml); 
    223259 
    224     if (meta == null) { 
    225       throw new FormatException("ome-xml.jar is required to read OME-TIFF " + 
    226         "files.  Please download it from " + 
    227         "http://loci.wisc.edu/ome/formats-library.html"); 
    228     } 
    229  
    230     if (meta.getRoot() == null) { 
     260    if (omexmlMeta.getRoot() == null) { 
    231261      throw new FormatException("Could not parse OME-XML from TIFF comment"); 
    232262    } 
    233263 
    234     String currentUUID = meta.getUUID(); 
    235     MetadataTools.convertMetadata(meta, metadataStore); 
     264    String currentUUID = omexmlMeta.getUUID(); 
     265    service.convertMetadata(omexmlMeta, metadataStore); 
    236266 
    237267    // determine series count from Image and Pixels elements 
    238268    int seriesCount = 0; 
    239     int imageCount = meta.getImageCount(); 
    240     for (int i=0; i<imageCount; i++) seriesCount += meta.getPixelsCount(i); 
     269    int imageCount = omexmlMeta.getImageCount(); 
     270    for (int i=0; i<imageCount; i++) seriesCount += omexmlMeta.getPixelsCount(i); 
    241271    core = new CoreMetadata[seriesCount]; 
    242272    for (int i=0; i<seriesCount; i++) { 
     
    249279    boolean needSearch = false; 
    250280    for (int i=0; i<imageCount; i++) { 
    251       int pixelsCount = meta.getPixelsCount(i); 
     281      int pixelsCount = omexmlMeta.getPixelsCount(i); 
    252282      for (int p=0; p<pixelsCount; p++) { 
    253         int tiffDataCount = meta.getTiffDataCount(i, p); 
     283        int tiffDataCount = omexmlMeta.getTiffDataCount(i, p); 
    254284        for (int td=0; td<tiffDataCount; td++) { 
    255           String uuid = meta.getTiffDataUUID(i, p, td); 
     285          String uuid = omexmlMeta.getTiffDataUUID(i, p, td); 
    256286          String filename = null; 
    257287          if (uuid == null) { 
     
    261291          } 
    262292          else { 
    263             filename = meta.getTiffDataFileName(i, p, td); 
     293            filename = omexmlMeta.getTiffDataFileName(i, p, td); 
    264294            if (!new Location(dir, filename).exists()) filename = null; 
    265295            if (filename == null) { 
     
    319349    for (int i=0; i<imageCount; i++) { 
    320350      LOGGER.debug("Image[{}] {", i); 
    321       LOGGER.debug("  id = {}", meta.getImageID(i)); 
    322       int pixelsCount = meta.getPixelsCount(i); 
     351      LOGGER.debug("  id = {}", omexmlMeta.getImageID(i)); 
     352      int pixelsCount = omexmlMeta.getPixelsCount(i); 
    323353      for (int p=0; p<pixelsCount; p++, s++) { 
    324354        LOGGER.debug("  Pixels[{}] {", p); 
    325         LOGGER.debug("    id = {}", meta.getPixelsID(i, p)); 
    326         String order = meta.getPixelsDimensionOrder(i, p); 
    327  
    328         Integer samplesPerPixel = meta.getLogicalChannelSamplesPerPixel(i, 0); 
     355        LOGGER.debug("    id = {}", omexmlMeta.getPixelsID(i, p)); 
     356        String order = omexmlMeta.getPixelsDimensionOrder(i, p); 
     357 
     358        Integer samplesPerPixel = omexmlMeta.getLogicalChannelSamplesPerPixel(i, 0); 
    329359        int samples = samplesPerPixel == null ? 
    330360          -1 : samplesPerPixel.intValue(); 
     
    336366        } 
    337367 
    338         int effSizeC = meta.getPixelsSizeC(i, p).intValue() / samples; 
     368        int effSizeC = omexmlMeta.getPixelsSizeC(i, p).intValue() / samples; 
    339369        if (effSizeC == 0) effSizeC = 1; 
    340         if (effSizeC * samples != meta.getPixelsSizeC(i, p).intValue()) { 
    341           effSizeC = meta.getPixelsSizeC(i, p).intValue(); 
    342         } 
    343         int sizeT = meta.getPixelsSizeT(i, p).intValue(); 
    344         int sizeZ = meta.getPixelsSizeZ(i, p).intValue(); 
     370        if (effSizeC * samples != omexmlMeta.getPixelsSizeC(i, p).intValue()) { 
     371          effSizeC = omexmlMeta.getPixelsSizeC(i, p).intValue(); 
     372        } 
     373        int sizeT = omexmlMeta.getPixelsSizeT(i, p).intValue(); 
     374        int sizeZ = omexmlMeta.getPixelsSizeZ(i, p).intValue(); 
    345375        int num = effSizeC * sizeT * sizeZ; 
    346376 
     
    348378        for (int no=0; no<num; no++) planes[no] = new OMETiffPlane(); 
    349379 
    350         int tiffDataCount = meta.getTiffDataCount(i, p); 
     380        int tiffDataCount = omexmlMeta.getTiffDataCount(i, p); 
    351381        for (int td=0; td<tiffDataCount; td++) { 
    352382          LOGGER.debug("    TiffData[{}] {", td); 
    353383          // extract TiffData parameters 
    354           String filename = meta.getTiffDataFileName(i, p, td); 
    355           String uuid = meta.getTiffDataUUID(i, p, td); 
    356           Integer tdIFD = meta.getTiffDataIFD(i, p, td); 
     384          String filename = omexmlMeta.getTiffDataFileName(i, p, td); 
     385          String uuid = omexmlMeta.getTiffDataUUID(i, p, td); 
     386          Integer tdIFD = omexmlMeta.getTiffDataIFD(i, p, td); 
    357387          int ifd = tdIFD == null ? 0 : tdIFD.intValue(); 
    358           Integer numPlanes = meta.getTiffDataNumPlanes(i, p, td); 
    359           Integer firstC = meta.getTiffDataFirstC(i, p, td); 
    360           Integer firstT = meta.getTiffDataFirstT(i, p, td); 
    361           Integer firstZ = meta.getTiffDataFirstZ(i, p, td); 
     388          Integer numPlanes = omexmlMeta.getTiffDataNumPlanes(i, p, td); 
     389          Integer firstC = omexmlMeta.getTiffDataFirstC(i, p, td); 
     390          Integer firstT = omexmlMeta.getTiffDataFirstT(i, p, td); 
     391          Integer firstZ = omexmlMeta.getTiffDataFirstZ(i, p, td); 
    362392          int c = firstC == null ? 0 : firstC.intValue(); 
    363393          int t = firstT == null ? 0 : firstT.intValue(); 
     
    447477            LOGGER.warn("Pixels ID '{}': missing plane #{}. " + 
    448478              "Using TiffReader to determine the number of planes.", 
    449               meta.getPixelsID(i, p), no); 
     479              omexmlMeta.getPixelsID(i, p), no); 
    450480            TiffReader r = new TiffReader(); 
    451481            r.setId(currentId); 
     
    466496        info[s] = planes; 
    467497        try { 
    468           core[s].sizeX = meta.getPixelsSizeX(i, p).intValue(); 
     498          core[s].sizeX = omexmlMeta.getPixelsSizeX(i, p).intValue(); 
    469499          int tiffWidth = (int) firstIFD.getImageWidth(); 
    470500          if (core[s].sizeX != tiffWidth) { 
     
    472502              core[s].sizeX, tiffWidth); 
    473503          } 
    474           core[s].sizeY = meta.getPixelsSizeY(i, p).intValue(); 
     504          core[s].sizeY = omexmlMeta.getPixelsSizeY(i, p).intValue(); 
    475505          int tiffHeight = (int) firstIFD.getImageLength(); 
    476506          if (core[s].sizeY != tiffHeight) { 
     
    478508              core[s].sizeY, tiffHeight); 
    479509          } 
    480           core[s].sizeZ = meta.getPixelsSizeZ(i, p).intValue(); 
    481           core[s].sizeC = meta.getPixelsSizeC(i, p).intValue(); 
    482           core[s].sizeT = meta.getPixelsSizeT(i, p).intValue(); 
     510          core[s].sizeZ = omexmlMeta.getPixelsSizeZ(i, p).intValue(); 
     511          core[s].sizeC = omexmlMeta.getPixelsSizeC(i, p).intValue(); 
     512          core[s].sizeT = omexmlMeta.getPixelsSizeT(i, p).intValue(); 
    483513          core[s].pixelType = FormatTools.pixelTypeFromString( 
    484             meta.getPixelsPixelType(i, p)); 
     514            omexmlMeta.getPixelsPixelType(i, p)); 
    485515          int tiffPixelType = firstIFD.getPixelType(); 
    486516          if (core[s].pixelType != tiffPixelType) { 
     
    490520          } 
    491521          core[s].imageCount = num; 
    492           core[s].dimensionOrder = meta.getPixelsDimensionOrder(i, p); 
     522          core[s].dimensionOrder = omexmlMeta.getPixelsDimensionOrder(i, p); 
    493523          core[s].orderCertain = true; 
    494524          int photo = firstIFD.getPhotometricInterpretation(); 
     
    517547          } 
    518548 
    519           core[s].littleEndian = !meta.getPixelsBigEndian(i, p).booleanValue(); 
     549          core[s].littleEndian = !omexmlMeta.getPixelsBigEndian(i, p).booleanValue(); 
    520550          boolean tiffLittleEndian = firstIFD.isLittleEndian(); 
    521551          if (core[s].littleEndian != tiffLittleEndian) { 
  • branches/cleanup/components/bio-formats/src/loci/formats/in/OMEXMLReader.java

    r5852 r5898  
    2929import java.util.Vector; 
    3030 
     31import javax.xml.parsers.ParserConfigurationException; 
     32 
    3133import loci.common.CBZip2InputStream; 
    3234import loci.common.RandomAccessInputStream; 
     35import loci.common.dependency.DependencyException; 
     36import loci.common.dependency.ServiceFactory; 
    3337import loci.common.xml.XMLTools; 
    3438import loci.formats.CoreMetadata; 
     
    4549import loci.formats.meta.IMetadata; 
    4650import loci.formats.meta.MetadataStore; 
     51import loci.formats.ome.OMEXMLMetadata; 
     52import loci.formats.ome.OMEXMLService; 
    4753 
    4854import org.xml.sax.Attributes; 
     55import org.xml.sax.SAXException; 
    4956import org.xml.sax.helpers.DefaultHandler; 
    5057 
     
    272279    LOGGER.info("Populating metadata"); 
    273280 
    274     IMetadata omexmlMeta = MetadataTools.createOMEXMLMetadata(omexml); 
    275  
    276     if (omexmlMeta == null) { 
    277       throw new FormatException("ome-xml.jar is required to read " + 
    278         "OME-XML files. Please download it from " + 
    279         "http://loci.wisc.edu/ome/formats-library.html"); 
     281    OMEXMLMetadata omexmlMeta; 
     282    OMEXMLService service; 
     283    try { 
     284      ServiceFactory factory = new ServiceFactory(); 
     285      service = factory.getInstance(OMEXMLService.class); 
     286      omexmlMeta = service.createOMEXMLMetadata(omexml); 
     287    } 
     288    catch (DependencyException de) { 
     289      throw new MissingLibraryException(OMETiffReader.MISSING_OME_XML_JAR, de); 
     290    } 
     291    catch (ParserConfigurationException pce) { 
     292      throw new FormatException(pce); 
     293    } 
     294    catch (SAXException se) { 
     295      throw new FormatException(se); 
    280296    } 
    281297 
    282298    hasSPW = omexmlMeta.getPlateCount() > 0; 
    283299 
    284     Hashtable originalMetadata = MetadataTools.getOriginalMetadata(omexmlMeta); 
     300    Hashtable originalMetadata = omexmlMeta.getOriginalMetadata(); 
    285301    if (originalMetadata != null) metadata = originalMetadata; 
    286302 
     
    341357    MetadataStore store = getMetadataStore(); 
    342358 
    343     MetadataTools.convertMetadata(omexmlMeta, store); 
     359    service.convertMetadata(omexmlMeta, store); 
    344360  } 
    345361 
  • branches/cleanup/components/bio-formats/src/loci/formats/ome/AbstractOMEXMLMetadata.java

    r5848 r5898  
    11// 
    2 // OMEXMLMetadata.java 
     2// AbstractOMEXMLMetadata.java 
    33// 
    44 
     
    2929import javax.xml.transform.TransformerException; 
    3030 
    31 import loci.formats.meta.IMetadata; 
    3231import ome.xml.DOMUtil; 
    3332import ome.xml.OMEXMLNode; 
     
    4544 * 
    4645 * <dl><dt><b>Source code:</b></dt> 
    47  * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/bio-formats/src/loci/formats/ome/OMEXMLMetadata.java">Trac</a>, 
    48  * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/ome/OMEXMLMetadata.java">SVN</a></dd></dl> 
     46 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/bio-formats/src/loci/formats/ome/AbstractOMEXMLMetadata.java">Trac</a>, 
     47 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/ome/AbsractOMEXMLMetadata.java">SVN</a></dd></dl> 
    4948 * 
    5049 * @author Curtis Rueden ctrueden at wisc.edu 
    5150 * @author Melissa Linkert linkert at wisc.edu 
    5251 */ 
    53 public abstract class OMEXMLMetadata implements IMetadata { 
     52public abstract class AbstractOMEXMLMetadata implements OMEXMLMetadata { 
    5453 
    5554  // -- Constants -- 
     
    7574 
    7675  /** Creates a new OME-XML metadata object. */ 
    77   public OMEXMLMetadata() { } 
     76  public AbstractOMEXMLMetadata() { } 
    7877 
    7978  // -- OMEXMLMetadata API methods -- 
  • branches/cleanup/components/bio-formats/src/loci/formats/ome/OMEXML2003FCMetadata.java

    r5848 r5898  
    5353 * @author Melissa Linkert linkert at wisc.edu 
    5454 */ 
    55 public class OMEXML2003FCMetadata extends OMEXMLMetadata { 
     55public class OMEXML2003FCMetadata extends AbstractOMEXMLMetadata { 
    5656 
    5757  // -- Constants -- 
  • branches/cleanup/components/bio-formats/src/loci/formats/ome/OMEXML200706Metadata.java

    r5848 r5898  
    5454 * @author Melissa Linkert linkert at wisc.edu 
    5555 */ 
    56 public class OMEXML200706Metadata extends OMEXMLMetadata { 
     56public class OMEXML200706Metadata extends AbstractOMEXMLMetadata { 
    5757 
    5858  // -- Constants -- 
  • branches/cleanup/components/bio-formats/src/loci/formats/ome/OMEXML200802Metadata.java

    r5848 r5898  
    5454 * @author Melissa Linkert linkert at wisc.edu 
    5555 */ 
    56 public class OMEXML200802Metadata extends OMEXMLMetadata { 
     56public class OMEXML200802Metadata extends AbstractOMEXMLMetadata { 
    5757 
    5858  // -- Constants -- 
  • branches/cleanup/components/bio-formats/src/loci/formats/ome/OMEXML200809Metadata.java

    r5848 r5898  
    5454 * @author Melissa Linkert linkert at wisc.edu 
    5555 */ 
    56 public class OMEXML200809Metadata extends OMEXMLMetadata { 
     56public class OMEXML200809Metadata extends AbstractOMEXMLMetadata { 
    5757 
    5858  // -- Constants -- 
  • branches/cleanup/components/bio-formats/src/loci/formats/ome/OMEXMLMetadata.java

    r5848 r5898  
    2424package loci.formats.ome; 
    2525 
    26 import java.io.ByteArrayOutputStream; 
    2726import java.util.Hashtable; 
    2827 
    29 import javax.xml.transform.TransformerException; 
    30  
    3128import loci.formats.meta.IMetadata; 
    32 import ome.xml.DOMUtil; 
    33 import ome.xml.OMEXMLNode; 
    34  
    35 import org.w3c.dom.Attr; 
    36 import org.w3c.dom.Element; 
    37 import org.w3c.dom.NamedNodeMap; 
    38 import org.w3c.dom.Node; 
    39 import org.w3c.dom.NodeList; 
    4029 
    4130/** 
    4231 * A utility class for constructing and manipulating OME-XML DOMs. 
    43  * It is the superclass for all versions of OME-XML. It requires the 
    44  * ome.xml package to compile (part of ome-xml.jar). 
    4532 * 
    4633 * <dl><dt><b>Source code:</b></dt> 
     
    4835 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/ome/OMEXMLMetadata.java">SVN</a></dd></dl> 
    4936 * 
    50  * @author Curtis Rueden ctrueden at wisc.edu 
    51  * @author Melissa Linkert linkert at wisc.edu 
     37 * @author Chris Allan callan at blackcat dot ca 
    5238 */ 
    53 public abstract class OMEXMLMetadata implements IMetadata { 
    54  
    55   // -- Constants -- 
    56  
    57   /** Custom attribute for storing original metadata key/value pairs. */ 
    58   private static final String ORIGINAL_METADATA = "OriginalMetadata"; 
    59  
    60   // -- Fields -- 
    61  
    62   /** The root element of OME-XML. */ 
    63   protected OMEXMLNode root; 
    64  
    65   /** DOM element that backs the first Image's CustomAttributes node. */ 
    66   private Element imageCA; 
    67  
    68   /** Whether OriginalMetadata semantic type definition has been created. */ 
    69   private boolean omCreated; 
    70  
    71   /** Hashtable containing all OriginalMetadata objects. */ 
    72   private Hashtable<String, String> originalMetadata; 
    73  
    74   // -- Constructors -- 
    75  
    76   /** Creates a new OME-XML metadata object. */ 
    77   public OMEXMLMetadata() { } 
    78  
    79   // -- OMEXMLMetadata API methods -- 
     39public interface OMEXMLMetadata extends IMetadata { 
    8040 
    8141  /** 
     
    8343   * @return OME-XML as a string. 
    8444   */ 
    85   public String dumpXML() { 
    86     if (root == null) return null; 
    87     try { 
    88       ByteArrayOutputStream os = new ByteArrayOutputStream(); 
    89       DOMUtil.writeXML(os, root.getDOMElement().getOwnerDocument()); 
    90       return os.toString(); 
    91     } 
    92     catch (TransformerException exc) { 
    93     } 
    94     return null; 
    95   } 
     45  public String dumpXML(); 
    9646 
    9747  /** Adds the key/value pair as a new OriginalMetadata node. */ 
    98   public void setOriginalMetadata(String key, String value) { 
    99     if (imageCA == null) { 
    100       Element ome = root.getDOMElement(); 
    101       Element image = DOMUtil.getChildElement("Image", ome); 
    102       if (image == null) { 
    103         setImageName("", 0); // HACK - force creation of Image element 
    104         image = DOMUtil.getChildElement("Image", ome); 
    105       } 
    106       imageCA = DOMUtil.getChildElement("CA:CustomAttributes", image); 
    107       if (imageCA == null) { 
    108         imageCA = DOMUtil.createChild(image, "CA:CustomAttributes", true); 
    109       } 
    110     } 
    111     if (!omCreated) { 
    112       Element std = DOMUtil.createChild(root.getDOMElement(), 
    113         "STD:SemanticTypeDefinitions"); 
    114       DOMUtil.setAttribute("xmlns", 
    115         "http://www.openmicroscopy.org/XMLschemas/STD/RC2/STD.xsd", std); 
    116       Element st = DOMUtil.createChild(std, "STD:SemanticType"); 
    117       DOMUtil.setAttribute("Name", ORIGINAL_METADATA, st); 
    118       DOMUtil.setAttribute("AppliesTo", "I", st); 
    119  
    120       Element nameElement = DOMUtil.createChild(st, "STD:Element"); 
    121       DOMUtil.setAttribute("Name", "Name", nameElement); 
    122       DOMUtil.setAttribute("DBLocation", "ORIGINAL_METADATA.NAME", nameElement); 
    123       DOMUtil.setAttribute("DataType", "string", nameElement); 
    124  
    125       Element valueElement = DOMUtil.createChild(st, "STD:Element"); 
    126       DOMUtil.setAttribute("Name", "Value", valueElement); 
    127       DOMUtil.setAttribute("DBLocation", 
    128         "ORIGINAL_METADATA.VALUE", valueElement); 
    129       DOMUtil.setAttribute("DataType", "string", valueElement); 
    130       omCreated = true; 
    131     } 
    132     Element om = DOMUtil.createChild(imageCA, ORIGINAL_METADATA); 
    133     DOMUtil.setAttribute("ID", root.makeID(ORIGINAL_METADATA), om); 
    134     DOMUtil.setAttribute("Name", key, om); 
    135     DOMUtil.setAttribute("Value", value, om); 
    136   } 
     48  public void setOriginalMetadata(String key, String value); 
    13749 
    13850  /** Gets the Hashtable containing all OriginalMetadata key/value pairs. */ 
    139   public Hashtable<String, String> getOriginalMetadata() { 
    140     if (originalMetadata != null) return originalMetadata; 
    141     originalMetadata = new Hashtable<String, String>(); 
    142  
    143     if (imageCA == null) { 
    144       Element ome = root.getDOMElement(); 
    145       Element image = DOMUtil.getChildElement("Image", ome); 
    146       if (image == null) return null; 
    147       imageCA = DOMUtil.getChildElement("CA:CustomAttributes", image); 
    148       if (imageCA == null) return null; 
    149     } 
    150  
    151     NodeList list = imageCA.getChildNodes(); 
    152     int size = list.getLength(); 
    153     for (int i=0; i<size; i++) { 
    154       Node node = list.item(i); 
    155       if (!(node instanceof Element)) continue; 
    156       String nodeName = node.getNodeName(); 
    157       if (!nodeName.equals(ORIGINAL_METADATA)) { 
    158         // not an OriginalMetadata element 
    159         continue; 
    160       } 
    161       NamedNodeMap attrs = node.getAttributes(); 
    162       int len = attrs.getLength(); 
    163       String key = null, value = null; 
    164       for (int j=0; j<len; j++) { 
    165         Attr attr = (Attr) attrs.item(j); 
    166         if (attr == null) continue; 
    167         String name = attr.getName(); 
    168         if ("Name".equals(name)) key = attr.getValue(); 
    169         else if ("Value".equals(name)) value = attr.getValue(); 
    170       } 
    171       if (key != null) originalMetadata.put(key, value); 
    172     } 
    173  
    174     return originalMetadata; 
    175   } 
     51  public Hashtable<String, String> getOriginalMetadata(); 
    17652 
    17753  /** Gets the OriginalMetadata value corresponding to the given key. */ 
    178   public String getOriginalMetadataValue(String key) { 
    179     return originalMetadata == null ? null : originalMetadata.get(key); 
    180   } 
    181  
    182   // -- MetadataRetrieve API methods -- 
    183  
    184   /* @see loci.formats.meta.MetadataRetrieve#getUUID() */ 
    185   public String getUUID() { 
    186     Element ome = root.getDOMElement(); 
    187     return DOMUtil.getAttribute("UUID", ome); 
    188   } 
    189  
    190   // -- MetadataStore API methods -- 
    191  
    192   /* @see loci.formats.meta.MetadataStore#setRoot(Object) */ 
    193   public void setRoot(Object root) { 
    194     originalMetadata = null; 
    195   } 
    196  
    197   /* @see loci.formats.meta.MetadataStore#getRoot() */ 
    198   public Object getRoot() { 
    199     return root; 
    200   } 
    201  
    202   /* @see loci.formats.meta.MetadataRetrieve#setUUID(String) */ 
    203   public void setUUID(String uuid) { 
    204     Element ome = root.getDOMElement(); 
    205     DOMUtil.setAttribute("UUID", uuid, ome); 
    206   } 
    207  
    208   // -- Type conversion methods -- 
    209  
    210   /** 
    211    * Converts Boolean value to Integer. Used to convert 
    212    * from 2003-FC Laser FrequencyDoubled Boolean value 
    213    * to Laser FrequencyMultiplication Integer value. 
    214    */ 
    215   protected Integer booleanToInteger(Boolean value) { 
    216     return value == null ? null : new Integer(value.booleanValue() ? 2 : 1); 
    217   } 
    218  
    219   /** 
    220    * Converts Integer value to Boolean. Used to convert 
    221    * from Laser FrequencyMultiplication Integer value 
    222    * to 2003-FC Laser FrequencyDoubled Boolean value. 
    223    */ 
    224   protected Boolean integerToBoolean(Integer value) { 
    225     return value == null ? null : new Boolean(value.intValue() == 2); 
    226   } 
    227  
    228   /** 
    229    * Converts Double value to Integer. Used to convert 
    230    * from 2008-02 LogicalChannel PinholeSize Integer value 
    231    * to LogicalChannel PinholeSize Double value. 
    232    */ 
    233   protected Integer doubleToInteger(Double value) { 
    234     return value == null ? null : new Integer(value.intValue()); 
    235   } 
    236  
    237   /** 
    238    * Converts Integer value to Double. Used to convert 
    239    * from LogicalChannel PinholeSize Double value 
    240    * to 2008-02 LogicalChannel PinholeSize Integer value. 
    241    */ 
    242   protected Double integerToDouble(Integer value) { 
    243     return value == null ? null : new Double(value.doubleValue()); 
    244   } 
    245  
     54  public String getOriginalMetadataValue(String key); 
    24655} 
  • branches/cleanup/components/bio-formats/src/loci/formats/ome/OMEXMLService.java

    r5894 r5898  
    2222*/ 
    2323 
    24 package loci.formats.dependency.services; 
     24package loci.formats.ome; 
    2525 
    2626import java.io.IOException; 
     27import java.util.Hashtable; 
    2728 
    2829import javax.xml.parsers.ParserConfigurationException; 
     
    3031import org.xml.sax.SAXException; 
    3132 
     33import loci.common.dependency.services.Service; 
     34import loci.formats.FormatException; 
     35import loci.formats.IFormatReader; 
    3236import loci.formats.meta.IMetadata; 
     37import loci.formats.meta.MetadataRetrieve; 
     38import loci.formats.meta.MetadataStore; 
    3339 
    3440 
     
    4955   * Creates an OME-XML metadata object using reflection, to avoid 
    5056   * direct dependencies on the optional {@link loci.formats.ome} package. 
    51    * @return A new instance of {@link loci.formats.ome.OMEXMLMetadata}, 
     57   * @return A new instance of {@link loci.formats.ome.AbstractOMEXMLMetadata}, 
    5258   *   or null if the class is not available. 
    5359   * @throws IOException If there is an error reading from the string. 
     
    5662   * parsing infrastructure. 
    5763   */ 
    58   public IMetadata createOMEXMLMetadata() 
     64  public OMEXMLMetadata createOMEXMLMetadata() 
    5965    throws ParserConfigurationException, SAXException, IOException; 
    6066 
     
    6369   * direct dependencies on the optional {@link loci.formats.ome} package, 
    6470   * wrapping a DOM representation of the given OME-XML string. 
    65    * @return A new instance of {@link loci.formats.ome.OMEXMLMetadata}, 
     71   * @return A new instance of {@link loci.formats.ome.AbstractOMEXMLMetadata}, 
    6672   *   or null if the class is not available. 
    6773   * @throws IOException If there is an error reading from the string. 
     
    7076   * parsing infrastructure. 
    7177   */ 
    72   public IMetadata createOMEXMLMetadata(String xml) 
     78  public OMEXMLMetadata createOMEXMLMetadata(String xml) 
    7379    throws ParserConfigurationException, SAXException, IOException; 
    7480 
     
    8389   *   If the xml and version parameters are both null, the newest version is 
    8490   *   used. 
    85    * @return A new instance of {@link loci.formats.ome.OMEXMLMetadata}, 
     91   * @return A new instance of {@link loci.formats.ome.AbstractOMEXMLMetadata}, 
    8692   *   or null if the class is not available. 
    8793   * @throws IOException If there is an error reading from the string. 
     
    9096   * parsing infrastructure. 
    9197   */ 
    92   public IMetadata createOMEXMLMetadata(String xml, String version) 
     98  public OMEXMLMetadata createOMEXMLMetadata(String xml, String version) 
    9399    throws ParserConfigurationException, SAXException, IOException; 
    94100 
     
    108114  public Object createOMEXMLRoot(String xml) 
    109115    throws ParserConfigurationException, SAXException, IOException; 
    110    
     116 
     117  /** 
     118   * Checks whether the given object is an OME-XML metadata object. 
     119   * @return True if the object is an instance of 
     120   *   {@link loci.formats.ome.AbstractOMEXMLMetadata}. 
     121   */ 
     122  public boolean isOMEXMLMetadata(Object o); 
     123 
     124  /** 
     125   * Checks whether the given object is an OME-XML root object. 
     126   * @return True if the object is an instance of {@link ome.xml.OMEXMLNode}. 
     127   */ 
     128  public boolean isOMEXMLRoot(Object o); 
     129 
    111130  /** 
    112131   * Gets the schema version for the given OME-XML metadata or root object 
     
    116135   */ 
    117136  public String getOMEXMLVersion(Object o); 
     137 
     138  /** 
     139   * Returns a {@link loci.formats.ome.OMEXMLMetadata} object with the same 
     140   * contents as the given MetadataRetrieve, converting it if necessary. 
     141   * @throws IOException If there is an error reading from the string. 
     142   * @throws SAXException If there is an error parsing the XML. 
     143   * @throws ParserConfigurationException If there is an error preparing the 
     144   * parsing infrastructure. 
     145   */ 
     146  public OMEXMLMetadata getOMEMetadata(MetadataRetrieve src) 
     147    throws ParserConfigurationException, SAXException, IOException; 
     148 
     149  /** 
     150   * Extracts an OME-XML metadata string from the given metadata object, 
     151   * by converting to an OME-XML metadata object if necessary. 
     152   * @throws IOException If there is an error reading from the string. 
     153   * @throws SAXException If there is an error parsing the XML. 
     154   * @throws ParserConfigurationException If there is an error preparing the 
     155   * parsing infrastructure. 
     156   */ 
     157  public String getOMEXML(MetadataRetrieve src) 
     158    throws ParserConfigurationException, SAXException, IOException; 
     159 
     160  /** 
     161   * Attempts to validate the given OME-XML string using 
     162   * Java's XML validation facility. Requires Java 1.5+. 
     163   * 
     164   * @param xml XML string to validate. 
     165   * @return true if the XML successfully validates. 
     166   */ 
     167  public boolean validateOMEXML(String xml); 
     168 
     169  /** 
     170   * Attempts to validate the given OME-XML string using 
     171   * Java's XML validation facility. Requires Java 1.5+. 
     172   * 
     173   * @param xml XML string to validate. 
     174   * @param pixelsHack Whether to ignore validation errors 
     175   *   due to childless Pixels elements 
     176   * @return true if the XML successfully validates. 
     177   */ 
     178  public boolean validateOMEXML(String xml, boolean pixelsHack); 
     179 
     180  /** 
     181   * Adds the specified key/value pair as a new OriginalMetadata node 
     182   * to the given OME-XML metadata object. 
     183   * @param omexmlMeta An object of type 
     184   *   {@link loci.formats.ome.OMEXMLMetadata}. 
     185   * @param key Metadata key to populate. 
     186   * @param value Metadata value corresponding to the specified key. 
     187   */ 
     188  public void populateOriginalMetadata(OMEXMLMetadata omexmlMeta, 
     189    String key, String value); 
     190 
     191  /** 
     192   * Converts information from an OME-XML string (source) 
     193   * into a metadata store (destination). 
     194   * @throws IOException If there is an error reading from the string. 
     195   * @throws SAXException If there is an error parsing the XML. 
     196   * @throws ParserConfigurationException If there is an error preparing the 
     197   * parsing infrastructure. 
     198   */ 
     199  public void convertMetadata(String xml, MetadataStore dest) 
     200    throws ParserConfigurationException, SAXException, IOException; 
     201 
     202  /** 
     203   * Copies information from a metadata retrieval object 
     204   * (source) into a metadata store (destination). 
     205   */ 
     206  public void convertMetadata(MetadataRetrieve src, MetadataStore dest); 
    118207   
    119   /** 
    120    * Checks whether the given object is an OME-XML metadata object. 
    121    * @return True if the object is an instance of 
    122    *   {@link loci.formats.ome.OMEXMLMetadata}. 
    123    */ 
    124   public boolean isOMEXMLMetadata(Object o); 
    125  
    126   /** 
    127    * Checks whether the given object is an OME-XML root object. 
    128    * @return True if the object is an instance of {@link ome.xml.OMEXMLNode}. 
    129    */ 
    130   public boolean isOMEXMLRoot(Object o); 
     208  // -- Utility methods - casting -- 
     209 
     210  /** 
     211   * Gets the given {@link MetadataRetrieve} object as a {@link MetadataStore}. 
     212   * Returns null if the object is incompatible and cannot be casted. 
     213   */ 
     214  public MetadataStore asStore(MetadataRetrieve meta); 
     215 
     216  /** 
     217   * Gets the given {@link MetadataStore} object as a {@link MetadataRetrieve}. 
     218   * Returns null if the object is incompatible and cannot be casted. 
     219   */ 
     220  public MetadataRetrieve asRetrieve(MetadataStore meta); 
     221 
    131222} 
  • branches/cleanup/components/bio-formats/src/loci/formats/ome/OMEXMLServiceImpl.java

    r5894 r5898  
    11// 
    2 // OMENotesServiceImpl.java 
     2// OMEXMLServiceImpl.java 
    33// 
    44 
     
    2222*/ 
    2323 
    24 package loci.formats.dependency.services; 
     24package loci.formats.ome; 
    2525 
    2626import java.io.IOException; 
     27import java.util.Arrays; 
     28import java.util.Hashtable; 
    2729 
    2830import javax.xml.parsers.ParserConfigurationException; 
     31import javax.xml.transform.Templates; 
     32import javax.xml.transform.TransformerConfigurationException; 
     33import javax.xml.transform.TransformerException; 
    2934 
    3035import ome.xml.OMEXMLFactory; 
     
    3338import org.slf4j.Logger; 
    3439import org.slf4j.LoggerFactory; 
     40import org.w3c.dom.Document; 
     41import org.w3c.dom.Node; 
     42import org.w3c.dom.NodeList; 
    3543import org.xml.sax.SAXException; 
    3644 
     45import loci.common.DateTools; 
     46import loci.common.Location; 
     47import loci.common.xml.XMLTools; 
     48import loci.formats.FormatException; 
     49import loci.formats.FormatTools; 
     50import loci.formats.IFormatReader; 
    3751import loci.formats.meta.IMetadata; 
    38 import loci.formats.ome.OMEXMLMetadata; 
    39  
    40 //import loci.ome.notes.Notes; 
     52import loci.formats.meta.MetadataConverter; 
     53import loci.formats.meta.MetadataRetrieve; 
     54import loci.formats.meta.MetadataStore; 
    4155 
    4256/** 
     
    4559 * 
    4660 * <dl><dt><b>Source code:</b></dt> 
    47  * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/bio-formats/src/loci/formats/in/OMENotesServiceImpl.java">Trac</a>, 
    48  * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/in/OMENotesServiceImpl.java">SVN</a></dd></dl> 
     61 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/bio-formats/src/loci/formats/ome/OMEXMLServiceImpl.java">Trac</a>, 
     62 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/ome/OMEXMLServiceImpl.java">SVN</a></dd></dl> 
    4963 */ 
    5064public class OMEXMLServiceImpl implements OMEXMLService { 
     
    5367  private static final Logger LOGGER = 
    5468    LoggerFactory.getLogger(OMEXMLService.class); 
     69 
     70  /** Reorderingstylesheet. */ 
     71  private static Templates reorderXSLT = 
     72    XMLTools.getStylesheet("meta/reorder-2008-09.xsl", 
     73                           OMEXMLServiceImpl.class); 
    5574   
    5675  /** 
     
    6483   * Creates an OME-XML metadata object using reflection, to avoid 
    6584   * direct dependencies on the optional {@link loci.formats.ome} package. 
    66    * @return A new instance of {@link loci.formats.ome.OMEXMLMetadata}, 
     85   * @return A new instance of {@link loci.formats.ome.AbstractOMEXMLMetadata}, 
    6786   *   or null if the class is not available. 
    6887   */ 
    69   public IMetadata createOMEXMLMetadata() 
     88  public OMEXMLMetadata createOMEXMLMetadata() 
    7089    throws ParserConfigurationException, SAXException, IOException { 
    7190    return createOMEXMLMetadata(null); 
     
    7695   * direct dependencies on the optional {@link loci.formats.ome} package, 
    7796   * wrapping a DOM representation of the given OME-XML string. 
    78    * @return A new instance of {@link loci.formats.ome.OMEXMLMetadata}, 
     97   * @return A new instance of {@link loci.formats.ome.AbstractOMEXMLMetadata}, 
    7998   *   or null if the class is not available. 
    8099   */ 
    81   public IMetadata createOMEXMLMetadata(String xml) 
     100  public OMEXMLMetadata createOMEXMLMetadata(String xml) 
    82101    throws ParserConfigurationException, SAXException, IOException { 
    83102    return createOMEXMLMetadata(xml, null); 
     
    94113   *   If the xml and version parameters are both null, the newest version is 
    95114   *   used. 
    96    * @return A new instance of {@link loci.formats.ome.OMEXMLMetadata}, 
     115   * @return A new instance of {@link loci.formats.ome.AbstractOMEXMLMetadata}, 
    97116   *   or null if the class is not available. 
    98117   */ 
    99   public IMetadata createOMEXMLMetadata(String xml, String version) 
     118  public OMEXMLMetadata createOMEXMLMetadata(String xml, String version) 
    100119    throws ParserConfigurationException, SAXException, IOException { 
    101120    OMEXMLNode ome = createRoot(xml); 
     
    115134      version.replaceAll("[^\\w]", "") + "Metadata"; 
    116135    try { 
    117       Class<? extends IMetadata> klass =  
    118         (Class<? extends IMetadata>) Class.forName(metaClass); 
    119       IMetadata meta = klass.newInstance(); 
     136      Class<? extends OMEXMLMetadata> klass =  
     137        (Class<? extends OMEXMLMetadata>) Class.forName(metaClass); 
     138      OMEXMLMetadata meta = klass.newInstance(); 
    120139      // attach OME root node to metadata object 
    121140      if (ome != null) meta.setRoot(ome); 
     
    140159    throws ParserConfigurationException, SAXException, IOException { 
    141160    return createRoot(xml); 
     161  } 
     162 
     163  /** 
     164   * Checks whether the given object is an OME-XML metadata object. 
     165   * @return True if the object is an instance of 
     166   *   {@link loci.formats.ome.AbstractOMEXMLMetadata}. 
     167   */ 
     168  public boolean isOMEXMLMetadata(Object o) { 
     169    return o instanceof OMEXMLMetadata; 
     170  } 
     171 
     172  /** 
     173   * Checks whether the given object is an OME-XML root object. 
     174   * @return True if the object is an instance of ome.xml.OMEXMLNode. 
     175   */ 
     176  public boolean isOMEXMLRoot(Object o) { 
     177    return o instanceof OMEXMLNode; 
    142178  } 
    143179 
     
    162198   * (e.g., "2007-06" or "2003-FC"). 
    163199   * @return OME-XML schema version, or null if the object is not an instance 
    164    *   of {@link loci.formats.ome.OMEXMLMetadata} or ome.xml.OMEXMLNode. 
     200   *   of {@link loci.formats.ome.AbstractOMEXMLMetadata} or ome.xml.OMEXMLNode. 
    165201   */ 
    166202  public String getOMEXMLVersion(Object o) { 
     
    184220    return null; 
    185221  } 
    186  
    187   /** 
    188    * Checks whether the given object is an OME-XML metadata object. 
    189    * @return True if the object is an instance of 
    190    *   {@link loci.formats.ome.OMEXMLMetadata}. 
    191    */ 
    192   public boolean isOMEXMLMetadata(Object o) { 
    193     return o instanceof OMEXMLMetadata; 
    194   } 
    195  
    196   /** 
    197    * Checks whether the given object is an OME-XML root object. 
    198    * @return True if the object is an instance of ome.xml.OMEXMLNode. 
    199    */ 
    200   public boolean isOMEXMLRoot(Object o) { 
    201     return o instanceof OMEXMLNode; 
    202   } 
     222   
     223  /** 
     224   * Returns a {@link loci.formats.ome.AbstractOMEXMLMetadata} object with the same 
     225   * contents as the given MetadataRetrieve, converting it if necessary. 
     226   * @throws IOException If there is an error reading from the string. 
     227   * @throws SAXException If there is an error parsing the XML. 
     228   * @throws ParserConfigurationException If there is an error preparing the 
     229   * parsing infrastructure. 
     230   */ 
     231  public OMEXMLMetadata getOMEMetadata(MetadataRetrieve src) 
     232    throws ParserConfigurationException, SAXException, IOException { 
     233    // check if the metadata is already an OME-XML metadata object 
     234    if (src instanceof OMEXMLMetadata) return (OMEXMLMetadata) src; 
     235 
     236    // populate a new OME-XML metadata object with metadata 
     237    // converted from the non-OME-XML metadata object 
     238    OMEXMLMetadata omexmlMeta = createOMEXMLMetadata(); 
     239    convertMetadata(src, omexmlMeta); 
     240    return omexmlMeta; 
     241  } 
     242 
     243  /** 
     244   * Extracts an OME-XML metadata string from the given metadata object, 
     245   * by converting to an OME-XML metadata object if necessary. 
     246   * @throws IOException If there is an error reading from the string. 
     247   * @throws SAXException If there is an error parsing the XML. 
     248   * @throws ParserConfigurationException If there is an error preparing the 
     249   * parsing infrastructure. 
     250   */ 
     251  public String getOMEXML(MetadataRetrieve src) 
     252    throws ParserConfigurationException, SAXException, IOException { 
     253    OMEXMLMetadata omexmlMeta = getOMEMetadata(src); 
     254    String xml = omexmlMeta.dumpXML(); 
     255    String reordered = null; 
     256    try { 
     257      reordered = XMLTools.transformXML(xml, reorderXSLT); 
     258    } 
     259    catch (IOException exc) { 
     260      LOGGER.warn("Could not transform OME-XML", exc); 
     261    } 
     262    return reordered == null ? xml : reordered; 
     263  } 
     264 
     265  /** 
     266   * Attempts to validate the given OME-XML string using 
     267   * Java's XML validation facility. Requires Java 1.5+. 
     268   * 
     269   * @param xml XML string to validate. 
     270   * @return true if the XML successfully validates. 
     271   */ 
     272  public boolean validateOMEXML(String xml) { 
     273    return validateOMEXML(xml, false); 
     274  } 
     275   
     276  /** 
     277   * Attempts to validate the given OME-XML string using 
     278   * Java's XML validation facility. Requires Java 1.5+. 
     279   * 
     280   * @param xml XML string to validate. 
     281   * @param pixelsHack Whether to ignore validation errors 
     282   *   due to childless Pixels elements 
     283   * @return true if the XML successfully validates. 
     284   */ 
     285  public boolean validateOMEXML(String xml, boolean pixelsHack) { 
     286    // HACK: Inject a TiffData element beneath any childless Pixels elements. 
     287    if (pixelsHack) { 
     288      // convert XML string to DOM 
     289      Document doc = null; 
     290      Exception exception = null; 
     291      try { 
     292        doc = XMLTools.parseDOM(xml); 
     293      } 
     294      catch (ParserConfigurationException exc) { exception = exc; } 
     295      catch (SAXException exc) { exception = exc; } 
     296      catch (IOException exc) { exception = exc; } 
     297      if (exception != null) { 
     298        LOGGER.info("Malformed OME-XML", exception); 
     299        return false; 
     300      } 
     301 
     302      // inject TiffData elements as needed 
     303      NodeList list = doc.getElementsByTagName("Pixels"); 
     304      for (int i=0; i<list.getLength(); i++) { 
     305        Node node = list.item(i); 
     306        NodeList children = node.getChildNodes(); 
     307        boolean needsTiffData = true; 
     308        for (int j=0; j<children.getLength(); j++) { 
     309          Node child = children.item(j); 
     310          String name = child.getLocalName(); 
     311          if ("TiffData".equals(name) || "BinData".equals(name)) { 
     312            needsTiffData = false; 
     313            break; 
     314          } 
     315        } 
     316        if (needsTiffData) { 
     317          // inject TiffData element 
     318          Node tiffData = doc.createElement("TiffData"); 
     319          node.insertBefore(tiffData, node.getFirstChild()); 
     320        } 
     321      } 
     322 
     323      // convert tweaked DOM back to XML string 
     324      try { 
     325        xml = XMLTools.getXML(doc); 
     326      } 
     327      catch (TransformerConfigurationException exc) { exception = exc; } 
     328      catch (TransformerException exc) { exception = exc; } 
     329      if (exception != null) { 
     330        LOGGER.info("Internal XML conversion error", exception); 
     331        return false; 
     332      } 
     333    } 
     334    return XMLTools.validateXML(xml, "OME-XML"); 
     335  } 
     336 
     337  /** 
     338   * Adds the specified key/value pair as a new OriginalMetadata node 
     339   * to the given OME-XML metadata object. 
     340   * Does nothing unless the given object is an OME-XML metadata object. 
     341   * @param omexmlMeta An object of type 
     342   *   {@link loci.formats.ome.AbstractOMEXMLMetadata}. 
     343   * @param key Metadata key to populate. 
     344   * @param value Metadata value corresponding to the specified key. 
     345   */ 
     346  public void populateOriginalMetadata(OMEXMLMetadata omexmlMeta, 
     347    String key, String value) 
     348  { 
     349    omexmlMeta.setOriginalMetadata(key, value); 
     350  } 
     351 
     352  /** 
     353   * Converts information from an OME-XML string (source) 
     354   * into a metadata store (destination). 
     355   * @throws IOException If there is an error reading from the string. 
     356   * @throws SAXException If there is an error parsing the XML. 
     357   * @throws ParserConfigurationException If there is an error preparing the 
     358   * parsing infrastructure. 
     359   */ 
     360  public void convertMetadata(String xml, MetadataStore dest) 
     361    throws ParserConfigurationException, SAXException, IOException { 
     362    OMEXMLNode ome = createRoot(xml); 
     363    String rootVersion = getOMEXMLVersion(ome); 
     364    String storeVersion = getOMEXMLVersion(dest); 
     365    if (rootVersion.equals(storeVersion)) { 
     366      // metadata store is already an OME-XML metadata object of the 
     367      // correct schema version; populate OME-XML string directly 
     368      if (!(dest instanceof OMEXMLMetadata)) { 
     369        throw new IllegalArgumentException( 
     370            "Expecting OMEXMLMetadata instance."); 
     371      } 
     372      // FIXME: What's below was in the ReflectedUniverse, the method no 
     373      // longer exists or has changed. 
     374      //((OMEXMLMetadata) dest).createRoot(xml); 
     375    } 
     376    else { 
     377      // metadata store is incompatible; create an OME-XML 
     378      // metadata object and copy it into the destination 
     379      IMetadata src = createOMEXMLMetadata(xml); 
     380      convertMetadata(src, dest); 
     381    } 
     382  } 
     383 
     384  /** 
     385   * Copies information from a metadata retrieval object 
     386   * (source) into a metadata store (destination). 
     387   */ 
     388  public void convertMetadata(MetadataRetrieve src, MetadataStore dest) { 
     389    MetadataConverter.convertMetadata(src, dest); 
     390  } 
     391 
     392  // -- Utility methods - casting -- 
     393 
     394  /** 
     395   * Gets the given {@link MetadataRetrieve} object as a {@link MetadataStore}. 
     396   * Returns null if the object is incompatible and cannot be casted. 
     397   */ 
     398  public MetadataStore asStore(MetadataRetrieve meta) { 
     399    return meta instanceof MetadataStore ? (MetadataStore) meta : null; 
     400  } 
     401 
     402  /** 
     403   * Gets the given {@link MetadataStore} object as a {@link MetadataRetrieve}. 
     404   * Returns null if the object is incompatible and cannot be casted. 
     405   */ 
     406  public MetadataRetrieve asRetrieve(MetadataStore meta) { 
     407    return meta instanceof MetadataRetrieve ? (MetadataRetrieve) meta : null; 
     408  } 
     409 
    203410} 
  • branches/cleanup/components/bio-formats/src/loci/formats/ome/OmeisImporter.java

    r5093 r5898  
    8383 
    8484  /** Metadata object, for gathering OME-XML metadata. */ 
    85   private OMEXMLMetadata omexmlMeta; 
     85  private AbstractOMEXMLMetadata omexmlMeta; 
    8686 
    8787  private boolean stitch; 
  • branches/cleanup/components/bio-formats/src/loci/formats/out/OMETiffWriter.java

    r5614 r5898  
    2424package loci.formats.out; 
    2525 
    26 import java.io.File; 
    2726import java.io.IOException; 
    2827import java.util.ArrayList; 
     
    3029import java.util.UUID; 
    3130 
     31import javax.xml.parsers.ParserConfigurationException; 
     32 
     33import org.xml.sax.SAXException; 
     34 
    3235import loci.common.Location; 
     36import loci.common.dependency.DependencyException; 
     37import loci.common.dependency.ServiceFactory; 
    3338import loci.formats.FormatException; 
    3439import loci.formats.FormatTools; 
    35 import loci.formats.MetadataTools; 
    36 import loci.formats.meta.IMetadata; 
    3740import loci.formats.meta.MetadataRetrieve; 
     41import loci.formats.ome.OMEXMLMetadata; 
     42import loci.formats.ome.OMEXMLService; 
    3843import loci.formats.tiff.TiffSaver; 
    3944 
     
    8691      // extract OME-XML string from metadata object 
    8792      MetadataRetrieve retrieve = getMetadataRetrieve(); 
    88       IMetadata omeMeta = MetadataTools.getOMEMetadata(retrieve); 
     93       
     94      OMEXMLMetadata omexmlMeta; 
     95      OMEXMLService service; 
     96      try { 
     97        ServiceFactory factory = new ServiceFactory(); 
     98        service = factory.getInstance(OMEXMLService.class); 
     99        omexmlMeta = service.getOMEMetadata(retrieve); 
     100      } 
     101      catch (DependencyException de) { 
     102        throw new IOException(de.getMessage()); 
     103        // FIXME: Modify close() interface to include FormatException? 
     104        //throw new MissingLibraryException( 
     105        //    OMETiffReader.MISSING_OME_XML_JAR, de); 
     106      } 
     107      catch (ParserConfigurationException pce) { 
     108        throw new IOException(pce.getMessage()); 
     109        // FIXME: Modify close() interface to include FormatException? 
     110        //throw new FormatException(pce); 
     111      } 
     112      catch (SAXException se) { 
     113        throw new IOException(se.getMessage()); 
     114        // FIXME: Modify close() interface to include FormatException? 
     115        //throw new FormatException(se); 
     116      } 
    89117 
    90118      // generate UUID and add to OME element 
    91119      String filename = new Location(currentId).getName(); 
    92120      String uuid = getUUID(filename); 
    93       omeMeta.setUUID(uuid); 
    94  
    95       for (int series=0; series<omeMeta.getImageCount(); series++) { 
    96         String dimensionOrder = omeMeta.getPixelsDimensionOrder(series, 0); 
    97         int sizeZ = omeMeta.getPixelsSizeZ(series, 0).intValue(); 
    98         int sizeC = omeMeta.getPixelsSizeC(series, 0).intValue(); 
    99         int sizeT = omeMeta.getPixelsSizeT(series, 0).intValue(); 
     121      omexmlMeta.setUUID(uuid); 
     122 
     123      for (int series=0; series<omexmlMeta.getImageCount(); series++) { 
     124        String dimensionOrder = omexmlMeta.getPixelsDimensionOrder(series, 0); 
     125        int sizeZ = omexmlMeta.getPixelsSizeZ(series, 0).intValue(); 
     126        int sizeC = omexmlMeta.getPixelsSizeC(series, 0).intValue(); 
     127        int sizeT = omexmlMeta.getPixelsSizeT(series, 0).intValue(); 
    100128 
    101129        int imageCount = 0; 
     
    106134 
    107135        if (imageCount == 0) { 
    108           omeMeta.setTiffDataNumPlanes(new Integer(0), series, 0, 0); 
     136          omexmlMeta.setTiffDataNumPlanes(new Integer(0), series, 0, 0); 
    109137          continue; 
    110138        } 
     
    117145        Integer samplesPerPixel = 
    118146          new Integer((sizeZ * sizeC * sizeT) / imageCount); 
    119         for (int c=0; c<omeMeta.getLogicalChannelCount(series); c++) { 
    120           omeMeta.setLogicalChannelSamplesPerPixel(samplesPerPixel, series, c); 
     147        for (int c=0; c<omexmlMeta.getLogicalChannelCount(series); c++) { 
     148          omexmlMeta.setLogicalChannelSamplesPerPixel(samplesPerPixel, series, c); 
    121149        } 
    122150 
     
    137165          int[] zct = FormatTools.getZCTCoords(dimensionOrder, 
    138166            sizeZ, sizeC, sizeT, imageCount, plane); 
    139           omeMeta.setTiffDataFileName(filename, series, 0, plane); 
    140           omeMeta.setTiffDataUUID(uuid, series, 0, plane); 
     167          omexmlMeta.setTiffDataFileName(filename, series, 0, plane); 
     168          omexmlMeta.setTiffDataUUID(uuid, series, 0, plane); 
    141169          // fill in any non-default TiffData attributes 
    142170          if (zct[0] > 0) { 
    143             omeMeta.setTiffDataFirstZ(new Integer(zct[0]), series, 0, plane); 
     171            omexmlMeta.setTiffDataFirstZ(new Integer(zct[0]), series, 0, plane); 
    144172          } 
    145173          if (zct[1] > 0) { 
    146             omeMeta.setTiffDataFirstC(new Integer(zct[1]), series, 0, plane); 
     174            omexmlMeta.setTiffDataFirstC(new Integer(zct[1]), series, 0, plane); 
    147175          } 
    148176          if (zct[2] > 0) { 
    149             omeMeta.setTiffDataFirstT(new Integer(zct[2]), series, 0, plane); 
     177            omexmlMeta.setTiffDataFirstT(new Integer(zct[2]), series, 0, plane); 
    150178          } 
    151179          if (ifd > 0) { 
    152             omeMeta.setTiffDataIFD(new Integer(ifd), series, 0, plane); 
     180            omexmlMeta.setTiffDataIFD(new Integer(ifd), series, 0, plane); 
    153181          } 
    154182          if (num != ifdCount) { 
    155             omeMeta.setTiffDataNumPlanes(new Integer(num), series, 0, plane); 
     183            omexmlMeta.setTiffDataNumPlanes(new Integer(num), series, 0, plane); 
    156184          } 
    157185          plane += num; 
     
    160188      } 
    161189 
    162       String xml = MetadataTools.getOMEXML(omeMeta); 
     190      String xml; 
     191      try { 
     192        xml = service.getOMEXML(omexmlMeta); 
     193      } 
     194      catch (ParserConfigurationException pce) { 
     195        throw new IOException(pce.getMessage()); 
     196        // FIXME: Modify close() interface to include FormatException? 
     197        //throw new FormatException(pce); 
     198      } 
     199      catch (SAXException se) { 
     200        throw new IOException(se.getMessage()); 
     201        // FIXME: Modify close() interface to include FormatException? 
     202        //throw new FormatException(se); 
     203      } 
    163204 
    164205      // insert warning comment 
  • branches/cleanup/components/bio-formats/src/loci/formats/out/OMEXMLWriter.java

    r5852 r5898  
    2727import java.util.Vector; 
    2828 
     29import javax.xml.parsers.ParserConfigurationException; 
     30 
    2931import loci.common.RandomAccessOutputStream; 
     32import loci.common.dependency.DependencyException; 
     33import loci.common.dependency.ServiceFactory; 
    3034import loci.common.xml.XMLTools; 
    3135import loci.formats.FormatException; 
     
    3438import loci.formats.ImageTools; 
    3539import loci.formats.MetadataTools; 
     40import loci.formats.MissingLibraryException; 
    3641import loci.formats.codec.Base64Codec; 
    3742import loci.formats.codec.CodecOptions; 
     
    3944import loci.formats.codec.JPEGCodec; 
    4045import loci.formats.codec.ZlibCodec; 
     46import loci.formats.in.OMETiffReader; 
    4147import loci.formats.meta.MetadataRetrieve; 
     48import loci.formats.ome.OMEXMLMetadata; 
     49import loci.formats.ome.OMEXMLService; 
    4250 
    4351import org.xml.sax.Attributes; 
     52import org.xml.sax.SAXException; 
    4453import org.xml.sax.helpers.DefaultHandler; 
    4554 
     
    8998      out = new RandomAccessOutputStream(currentId); 
    9099 
    91       String xml = MetadataTools.getOMEXML(retrieve); 
     100      String xml; 
     101      try { 
     102        ServiceFactory factory = new ServiceFactory(); 
     103        OMEXMLService service = factory.getInstance(OMEXMLService.class); 
     104        xml = service.getOMEXML(retrieve); 
     105      } 
     106      catch (DependencyException de) { 
     107        throw new MissingLibraryException( 
     108            OMETiffReader.MISSING_OME_XML_JAR, de); 
     109      } 
     110      catch (ParserConfigurationException pce) { 
     111        throw new FormatException(pce); 
     112      } 
     113      catch (SAXException se) { 
     114        throw new FormatException(se); 
     115      } 
    92116 
    93117      xmlFragments = new Vector(); 
  • branches/cleanup/components/bio-formats/src/loci/formats/tools/ImageConverter.java

    r5852 r5898  
    2727import java.io.IOException; 
    2828 
     29import javax.xml.parsers.ParserConfigurationException; 
     30 
    2931import loci.common.Location; 
     32import loci.common.dependency.DependencyException; 
     33import loci.common.dependency.ServiceFactory; 
    3034import loci.formats.ChannelFiller; 
    3135import loci.formats.ChannelMerger; 
     
    3943import loci.formats.ImageWriter; 
    4044import loci.formats.MetadataTools; 
     45import loci.formats.MissingLibraryException; 
     46import loci.formats.in.OMETiffReader; 
    4147import loci.formats.meta.MetadataRetrieve; 
    4248import loci.formats.meta.MetadataStore; 
     49import loci.formats.ome.OMEXMLMetadata; 
     50import loci.formats.ome.OMEXMLService; 
    4351import loci.formats.out.TiffWriter; 
    4452 
     
    4957import org.slf4j.Logger; 
    5058import org.slf4j.LoggerFactory; 
     59import org.xml.sax.SAXException; 
    5160 
    5261/** 
     
    176185    reader.setMetadataFiltered(true); 
    177186    reader.setOriginalMetadataPopulated(true); 
    178     MetadataStore store = MetadataTools.createOMEXMLMetadata(); 
    179     if (store == null) LOGGER.info("OME-XML Java library not found."); 
    180     else reader.setMetadataStore(store); 
     187    try { 
     188      ServiceFactory factory = new ServiceFactory(); 
     189      OMEXMLService service = factory.getInstance(OMEXMLService.class); 
     190      reader.setMetadataStore(service.createOMEXMLMetadata()); 
     191    } 
     192    catch (DependencyException de) { 
     193      throw new MissingLibraryException(OMETiffReader.MISSING_OME_XML_JAR, de); 
     194    } 
     195    catch (ParserConfigurationException pce) { 
     196      throw new FormatException(pce); 
     197    } 
     198    catch (SAXException se) { 
     199      throw new FormatException(se); 
     200    } 
    181201 
    182202    reader.setId(in); 
    183203 
    184     store = reader.getMetadataStore(); 
    185     MetadataRetrieve retrieve = MetadataTools.asRetrieve(store); 
    186     if (retrieve != null) writer.setMetadataRetrieve(retrieve); 
     204    MetadataStore store = reader.getMetadataStore(); 
     205    if (store instanceof MetadataRetrieve) { 
     206      writer.setMetadataRetrieve((MetadataRetrieve) store); 
     207    } 
    187208 
    188209    if (writer instanceof TiffWriter) { 
  • branches/cleanup/components/bio-formats/src/loci/formats/tools/ImageInfo.java

    r5852 r5898  
    2929import java.util.StringTokenizer; 
    3030 
     31import javax.xml.parsers.ParserConfigurationException; 
     32 
    3133import loci.common.ByteArrayHandle; 
    3234import loci.common.DataTools; 
    3335import loci.common.Location; 
    3436import loci.common.RandomAccessInputStream; 
     37import loci.common.dependency.DependencyException; 
     38import loci.common.dependency.ServiceFactory; 
    3539import loci.common.xml.XMLTools; 
    3640import loci.formats.ChannelFiller; 
     
    4751import loci.formats.MetadataTools; 
    4852import loci.formats.MinMaxCalculator; 
     53import loci.formats.MissingLibraryException; 
    4954import loci.formats.gui.AWTImageTools; 
    5055import loci.formats.gui.BufferedImageReader; 
    5156import loci.formats.gui.ImageViewer; 
     57import loci.formats.in.OMETiffReader; 
    5258import loci.formats.meta.MetadataRetrieve; 
    5359import loci.formats.meta.MetadataStore; 
     60import loci.formats.ome.OMEXMLMetadata; 
     61import loci.formats.ome.OMEXMLService; 
    5462 
    5563import org.apache.log4j.ConsoleAppender; 
     
    5967import org.slf4j.Logger; 
    6068import org.slf4j.LoggerFactory; 
     69import org.xml.sax.SAXException; 
    6170 
    6271/** 
     
    314323    if (omexml) { 
    315324      reader.setOriginalMetadataPopulated(true); 
    316       MetadataStore store = 
    317         MetadataTools.createOMEXMLMetadata(null, omexmlVersion); 
    318       if (store != null) reader.setMetadataStore(store); 
     325      try { 
     326        ServiceFactory factory = new ServiceFactory(); 
     327        OMEXMLService service = factory.getInstance(OMEXMLService.class); 
     328        reader.setMetadataStore( 
     329            service.createOMEXMLMetadata(null, omexmlVersion)); 
     330      } 
     331      catch (DependencyException de) { 
     332        throw new MissingLibraryException(OMETiffReader.MISSING_OME_XML_JAR, de); 
     333      } 
     334      catch (ParserConfigurationException pce) { 
     335        throw new FormatException(pce); 
     336      } 
     337      catch (SAXException se) { 
     338        throw new FormatException(se); 
     339      } 
    319340    } 
    320341 
     
    413434    LOGGER.info("Series count = {}", seriesCount); 
    414435    MetadataStore ms = reader.getMetadataStore(); 
    415     MetadataRetrieve mr = MetadataTools.asRetrieve(ms); 
     436    MetadataRetrieve mr = ms instanceof MetadataRetrieve? (MetadataRetrieve) ms 
     437        : null; 
    416438    for (int j=0; j<seriesCount; j++) { 
    417439      reader.setSeries(j); 
     
    778800  } 
    779801 
    780   public void printOMEXML() { 
     802  public void printOMEXML()  
     803    throws FormatException, ParserConfigurationException, SAXException, 
     804           IOException { 
    781805    LOGGER.info(""); 
    782806    MetadataStore ms = reader.getMetadataStore(); 
    783     String version = MetadataTools.getOMEXMLVersion(ms); 
     807    OMEXMLService service; 
     808    try { 
     809      ServiceFactory factory = new ServiceFactory(); 
     810      service = factory.getInstance(OMEXMLService.class); 
     811    } 
     812    catch (DependencyException de) { 
     813      throw new MissingLibraryException(OMETiffReader.MISSING_OME_XML_JAR, de); 
     814    } 
     815    String version = service.getOMEXMLVersion(ms); 
    784816    if (version == null) LOGGER.info("Generating OME-XML"); 
    785817    else { 
    786818      LOGGER.info("Generating OME-XML (schema version {})", version); 
    787819    } 
    788     MetadataRetrieve mr = MetadataTools.asRetrieve(ms); 
    789     if (mr != null) { 
    790       String xml = MetadataTools.getOMEXML(mr); 
     820    if (ms instanceof MetadataRetrieve) { 
     821      String xml = service.getOMEXML((MetadataRetrieve) ms); 
    791822      LOGGER.info("{}", XMLTools.indentXML(xml, true)); 
    792       MetadataTools.validateOMEXML(xml, true); 
     823      service.validateOMEXML(xml, true); 
    793824    } 
    794825    else { 
     
    809840   */ 
    810841  public boolean testRead(String[] args) 
    811     throws FormatException, IOException 
    812   { 
     842    throws FormatException, ParserConfigurationException, SAXException, 
     843           IOException { 
    813844    parseArgs(args); 
    814845    if (printVersion) { 
     
    859890  // -- Main method -- 
    860891 
    861   public static void main(String[] args) throws FormatException, IOException { 
     892  public static void main(String[] args) throws Exception { 
    862893    if (!new ImageInfo().testRead(args)) System.exit(1); 
    863894  } 
  • branches/cleanup/components/bio-formats/test/loci/formats/utests/OMEXMLServiceTest.java

    r5894 r5898  
    2626import static org.testng.AssertJUnit.assertEquals; 
    2727 
    28 import loci.formats.dependency.DependencyException; 
    29 import loci.formats.dependency.ServiceFactory; 
    30 import loci.formats.dependency.services.OMEXMLService; 
     28import loci.common.dependency.DependencyException; 
     29import loci.common.dependency.ServiceFactory; 
     30import loci.formats.ome.OMEXMLService; 
    3131 
    3232import org.testng.annotations.BeforeMethod; 
  • branches/cleanup/components/bio-formats/test/loci/formats/utests/ServiceFactoryTest.java

    r5894 r5898  
    2424package loci.formats.utests; 
    2525 
    26 import loci.formats.dependency.DependencyException; 
    27 import loci.formats.dependency.ServiceFactory; 
    28 import loci.formats.dependency.services.Service; 
     26import loci.common.dependency.DependencyException; 
     27import loci.common.dependency.ServiceFactory; 
     28import loci.common.dependency.services.Service; 
    2929 
    3030import org.testng.annotations.BeforeMethod; 
  • branches/cleanup/components/common/src/loci/common/dependency/DependencyException.java

    r5894 r5898  
    2222*/ 
    2323 
    24 package loci.formats.dependency; 
     24package loci.common.dependency; 
    2525 
    26 import loci.formats.dependency.services.Service; 
     26import loci.common.dependency.services.Service; 
    2727 
    2828/** 
  • branches/cleanup/components/common/src/loci/common/dependency/ServiceFactory.java

    r5894 r5898  
    2222*/ 
    2323 
    24 package loci.formats.dependency; 
     24package loci.common.dependency; 
    2525 
    2626import java.io.IOException; 
     
    3333import java.util.Map.Entry; 
    3434 
    35 import loci.formats.dependency.services.Service; 
     35import loci.common.dependency.services.Service; 
    3636 
    3737import org.slf4j.Logger; 
     
    9999    Set<Entry<Object, Object>> entries = properties.entrySet(); 
    100100    for (Entry<Object, Object> entry : entries) { 
     101      String interfaceName = (String) entry.getKey(); 
     102      String implementationName = (String) entry.getValue(); 
     103      Class<? extends Service> interfaceClass; 
     104      Class<? extends Service> implementationClass; 
    101105      try { 
    102         Class<? extends Service> inter = (Class<? extends Service>) 
     106        interfaceClass = (Class<? extends Service>) 
    103107          Class.forName((String) entry.getKey()); 
    104         Class<? extends Service> impl = (Class<? extends Service>) 
     108      } 
     109      catch (ClassNotFoundException e) { 
     110        LOGGER.warn("CLASSPATH missing interface: {}", interfaceName); 
     111        continue; 
     112      } 
     113      try { 
     114        implementationClass = (Class<? extends Service>) 
    105115          Class.forName((String) entry.getValue()); 
    106         services.put(inter, impl); 
    107         LOGGER.debug("Added interface {} and implementation {}", inter, impl); 
    108       } catch (ClassNotFoundException e) { 
    109         throw new DependencyException(e); 
    110116      } 
     117      catch (ClassNotFoundException e) { 
     118        LOGGER.warn("CLASSPATH missing implementation: {}", implementationName); 
     119        continue; 
     120      } 
     121      services.put(interfaceClass, implementationClass); 
     122      LOGGER.debug("Added interface {} and implementation {}", 
     123          interfaceClass, implementationClass); 
    111124    } 
    112125     
  • branches/cleanup/components/common/src/loci/common/dependency/services/OMENotesService.java

    r5894 r5898  
    2222*/ 
    2323 
    24 package loci.formats.dependency.services; 
     24package loci.common.dependency.services; 
    2525 
    2626 
     
    3333public interface OMENotesService extends Service { 
    3434 
     35  /** 
     36   * Creates a new OME Notes instance. 
     37   * @param filename Path to the file to create a Notes instance for. 
     38   */ 
    3539  public void newNotes(String filename); 
    3640 
  • branches/cleanup/components/common/src/loci/common/dependency/services/Service.java

    r5894 r5898  
    2222*/ 
    2323 
    24 package loci.formats.dependency.services; 
     24package loci.common.dependency.services; 
    2525 
    2626/** 
  • branches/cleanup/components/common/src/services.properties

    r5894 r5898  
    33# 
    44 
    5 # OME notes service 
    6 loci.formats.dependency.services.OMENotesService=loci.formats.dependency.services.OMENotesServiceImpl 
    7 loci.formats.dependency.services.OMEXMLService=loci.formats.dependency.services.OMEXMLServiceImpl 
     5# OME notes service (implementation in legacy ome-notes component) 
     6loci.common.dependency.services.OMENotesService=loci.ome.notes.OMENotesServiceImpl 
     7# OME-XML service (interface and implementation in bio-formats component) 
     8loci.formats.ome.OMEXMLService=loci.formats.ome.OMEXMLServiceImpl 
  • branches/cleanup/components/legacy/ome-notes/src/loci/ome/notes/OMENotesServiceImpl.java

    r5894 r5898  
    2222*/ 
    2323 
    24 package loci.formats.dependency.services; 
     24package loci.ome.notes; 
    2525 
    26 //import loci.ome.notes.Notes; 
     26import loci.common.dependency.services.OMENotesService; 
    2727 
    2828/** 
     
    3131 * 
    3232 * <dl><dt><b>Source code:</b></dt> 
    33  * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/bio-formats/src/loci/formats/in/OMENotesServiceImpl.java">Trac</a>, 
    34  * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/in/OMENotesServiceImpl.java">SVN</a></dd></dl> 
     33 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/legacy/ome-notes/src/loci/ome/notes/OMENotesServiceImpl.java">Trac</a>, 
     34 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/legacy/ome-notes/src/loci/ome/notes/OMENotesServiceImpl.java">SVN</a></dd></dl> 
    3535 */ 
    3636public class OMENotesServiceImpl implements OMENotesService { 
     
    4040   */ 
    4141  public void newNotes(String filename) { 
    42     System.err.println("Filename: " + filename); 
    43     //new Notes(null, filename); 
     42    new Notes(null, filename); 
    4443  } 
    4544 
Note: See TracChangeset for help on using the changeset viewer.