Changeset 4864


Ignore:
Timestamp:
02/27/09 19:01:34 (11 years ago)
Author:
curtis
Message:

Change behavior of original metadata table:

  • Preserve the original data type rather than always converting to a string.
  • Filter out complex data types (anything other than String, Number, Boolean and Character) when filtering is enabled.
  • Only record simple types as OriginalMetadata ST instances in OME-XML.

This change fundamentally alters the way Bio-Formats treats original metadata,
and as such there may be behavioral discrepancies and other issues when
working with the original metadata hashtable -- please report any problems.

File:
1 edited

Legend:

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

    r4809 r4864  
    175175  protected void addMeta(String key, Object value) { 
    176176    if (key == null || value == null || !collectMetadata) return; 
    177     String val = value.toString(); 
     177 
     178    boolean simple = 
     179      value instanceof String || 
     180      value instanceof Number || 
     181      value instanceof Boolean || 
     182      value instanceof Character; 
     183    String val = simple ? value.toString() : null; 
     184 
    178185    if (filterMetadata) { 
     186      // filter out complex data types 
     187      if (val == null) return; 
     188 
    179189      // verify key & value are not empty 
    180190      if (key.length() == 0) return; 
     
    203213    } 
    204214 
    205     if (saveOriginalMetadata) { 
     215    if (saveOriginalMetadata && val != null) { 
    206216      MetadataStore store = getMetadataStore(); 
    207217      if (MetadataTools.isOMEXMLMetadata(store)) { 
     
    210220    } 
    211221 
    212     metadata.put(key, val); 
     222    metadata.put(key, val == null ? value : val); 
    213223  } 
    214224 
Note: See TracChangeset for help on using the changeset viewer.