Changeset 6040


Ignore:
Timestamp:
03/18/10 07:45:49 (10 years ago)
Author:
curtis
Message:

Readd some static MetadataTools methods, deprecated,
to ease migration of external legacy code.

File:
1 edited

Legend:

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

    r6026 r6040  
    3030import loci.common.DateTools; 
    3131import loci.common.Location; 
     32import loci.common.services.DependencyException; 
     33import loci.common.services.ServiceException; 
     34import loci.common.services.ServiceFactory; 
     35import loci.formats.meta.IMetadata; 
    3236import loci.formats.meta.MetadataRetrieve; 
    3337import loci.formats.meta.MetadataStore; 
     38import loci.formats.services.OMEXMLService; 
    3439 
    3540import org.slf4j.Logger; 
     
    221226 
    222227  /** Gets a sorted list of keys from the given hashtable. */ 
    223   public static String[] keys(Hashtable meta) { 
     228  public static String[] keys(Hashtable<String, Object> meta) { 
    224229    String[] keys = new String[meta.size()]; 
    225230    meta.keySet().toArray(keys); 
     
    232237   * specified prefix for the destination keys. 
    233238   */ 
    234   public static void merge(Map src, Map dest, String prefix) { 
    235     for (Object key : src.keySet()) { 
     239  public static void merge(Map<String, Object> src, Map<String, Object> dest, 
     240    String prefix) 
     241  { 
     242    for (String key : src.keySet()) { 
    236243      dest.put(prefix + key, src.get(key)); 
    237244    } 
    238245  } 
    239246 
     247  // -- Deprecated methods -- 
     248 
     249  private static OMEXMLService omexmlService = createOMEXMLService(); 
     250  private static OMEXMLService createOMEXMLService() { 
     251    try { 
     252      return new ServiceFactory().getInstance(OMEXMLService.class); 
     253    } 
     254    catch (DependencyException exc) { 
     255      return null; 
     256    } 
     257  } 
     258 
     259  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     260  public static String getLatestVersion() { 
     261    if (omexmlService == null) return null; 
     262    return omexmlService.getLatestVersion(); 
     263  } 
     264 
     265  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     266  public static IMetadata createOMEXMLMetadata() { 
     267    if (omexmlService == null) return null; 
     268    try { 
     269      return omexmlService.createOMEXMLMetadata(); 
     270    } 
     271    catch (ServiceException exc) { 
     272      return null; 
     273    } 
     274  } 
     275 
     276  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     277  public static IMetadata createOMEXMLMetadata(String xml) { 
     278    if (omexmlService == null) return null; 
     279    try { 
     280      return omexmlService.createOMEXMLMetadata(xml); 
     281    } 
     282    catch (ServiceException exc) { 
     283      return null; 
     284    } 
     285  } 
     286 
     287  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     288  public static IMetadata createOMEXMLMetadata(String xml, String version) { 
     289    if (omexmlService == null) return null; 
     290    try { 
     291      return omexmlService.createOMEXMLMetadata(xml); 
     292    } 
     293    catch (ServiceException exc) { 
     294      return null; 
     295    } 
     296  } 
     297 
     298  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     299  public static Object createOMEXMLRoot(String xml) { 
     300    if (omexmlService == null) return null; 
     301    try { 
     302      return omexmlService.createOMEXMLMetadata(xml); 
     303    } 
     304    catch (ServiceException exc) { 
     305      return null; 
     306    } 
     307  } 
     308 
     309  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     310  public static boolean isOMEXMLMetadata(Object o) { 
     311    if (omexmlService == null) return false; 
     312    return omexmlService.isOMEXMLMetadata(o); 
     313  } 
     314 
     315  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     316  public static boolean isOMEXMLRoot(Object o) { 
     317    if (omexmlService == null) return false; 
     318    return omexmlService.isOMEXMLRoot(o); 
     319  } 
     320 
     321  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     322  public static String getOMEXMLVersion(Object o) { 
     323    if (omexmlService == null) return null; 
     324    return omexmlService.getOMEXMLVersion(o); 
     325  } 
     326 
     327  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     328  public static IMetadata getOMEMetadata(MetadataRetrieve src) { 
     329    if (omexmlService == null) return null; 
     330    try { 
     331      return omexmlService.getOMEMetadata(src); 
     332    } 
     333    catch (ServiceException exc) { 
     334      return null; 
     335    } 
     336  } 
     337 
     338  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     339  public static String getOMEXML(MetadataRetrieve src) { 
     340    if (omexmlService == null) return null; 
     341    try { 
     342      return omexmlService.getOMEXML(src); 
     343    } 
     344    catch (ServiceException exc) { 
     345      return null; 
     346    } 
     347  } 
     348 
     349  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     350  public static boolean validateOMEXML(String xml) { 
     351    if (omexmlService == null) return false; 
     352    return omexmlService.validateOMEXML(xml); 
     353  } 
     354 
     355  /** @deprecated @see loci.formats.services.OMEXMLService */ 
     356  public static boolean validateOMEXML(String xml, boolean pixelsHack) { 
     357    if (omexmlService == null) return false; 
     358    return omexmlService.validateOMEXML(xml, pixelsHack); 
     359  } 
     360 
    240361} 
Note: See TracChangeset for help on using the changeset viewer.