Changeset 4866


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

Always preserve data type of non-string original metadata values.

File:
1 edited

Legend:

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

    r4864 r4866  
    176176    if (key == null || value == null || !collectMetadata) return; 
    177177 
    178     boolean simple = 
    179       value instanceof String || 
     178    boolean string = value instanceof String; 
     179    boolean simple = string || 
    180180      value instanceof Number || 
    181181      value instanceof Boolean || 
    182182      value instanceof Character; 
    183     String val = simple ? value.toString() : null; 
     183 
     184    // string value, if passed in value is a string 
     185    String val = string ? (String) value : null; 
    184186 
    185187    if (filterMetadata) { 
    186188      // filter out complex data types 
    187       if (val == null) return; 
     189      if (!simple) return; 
    188190 
    189191      // verify key & value are not empty 
    190192      if (key.length() == 0) return; 
    191       if (val.length() == 0) return; 
     193      if (string && val.length() == 0) return; 
    192194 
    193195      // verify key & value are reasonable length 
    194196      int maxLen = 8192; 
    195197      if (key.length() > maxLen) return; 
    196       if (val.length() > maxLen) return; 
     198      if (string && val.length() > maxLen) return; 
    197199 
    198200      // remove all non-printable characters 
    199201      key = DataTools.sanitize(key); 
    200       val = DataTools.sanitize(val); 
     202      if (string) val = DataTools.sanitize(val); 
    201203 
    202204      // verify key contains at least one alphabetic character 
     
    209211      for (int i=0; i<invalidSequences.length; i++) { 
    210212        key = key.replaceAll(invalidSequences[i], ""); 
    211         val = val.replaceAll(invalidSequences[i], ""); 
     213        if (string) val = val.replaceAll(invalidSequences[i], ""); 
    212214      } 
    213     } 
    214  
    215     if (saveOriginalMetadata && val != null) { 
     215 
     216      if (string) value = val; 
     217    } 
     218 
     219    if (saveOriginalMetadata && simple) { 
    216220      MetadataStore store = getMetadataStore(); 
    217221      if (MetadataTools.isOMEXMLMetadata(store)) { 
    218         MetadataTools.populateOriginalMetadata(store, key, val); 
     222        MetadataTools.populateOriginalMetadata(store, key, value.toString()); 
    219223      } 
    220224    } 
Note: See TracChangeset for help on using the changeset viewer.