Changeset 2957


Ignore:
Timestamp:
07/10/07 12:50:47 (13 years ago)
Author:
melissa
Message:

Added setOriginalMetadataPopulated(boolean) and isOriginalMetadataPopulated to IFormatReader API.

Location:
trunk/loci/formats
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/FileStitcher.java

    r2857 r2957  
    516516  public boolean isMetadataCollected() { 
    517517    return reader.isMetadataCollected(); 
     518  } 
     519 
     520  /* @see IFormatReader#setOriginalMetadataPopulated(boolean) */ 
     521  public void setOriginalMetadataPopulated(boolean populate) { 
     522    FormatTools.assertId(currentId, false, 1); 
     523    if (readers == null) reader.setOriginalMetadataPopulated(populate); 
     524    else { 
     525      for (int i=0; i<readers.length; i++) { 
     526        readers[i].setOriginalMetadataPopulated(populate); 
     527      } 
     528    } 
     529  } 
     530 
     531  /* @see IFormatReader#isOriginalMetadataPopulated() */ 
     532  public boolean isOriginalMetadataPopulated() { 
     533    return reader.isOriginalMetadataPopulated();  
    518534  } 
    519535 
  • trunk/loci/formats/FormatReader.java

    r2923 r2957  
    2727import java.awt.image.BufferedImage; 
    2828import java.io.IOException; 
     29import java.lang.reflect.Method; 
    2930import java.util.*; 
    3031 
     
    6667  /** Whether or not to collect metadata. */ 
    6768  protected boolean collectMetadata = true; 
     69 
     70  /** Whether or not to save proprietary metadata in the MetadataStore. */ 
     71  protected boolean saveOriginalMetadata = false;  
    6872 
    6973  /** Whether or not to group multi-file formats. */ 
     
    163167      if (!key.matches(".*[a-zA-Z].*")) return; 
    164168    } 
     169     
     170    if (saveOriginalMetadata) { 
     171      try { 
     172        MetadataStore store = getMetadataStore(); 
     173        if (store.getClass().getName().equals( 
     174          "loci.formats.ome.OMEXMLMetadataStore")); 
     175        { 
     176          Method m = store.getClass().getMethod("populateOriginalMetadata", 
     177            new Class[] {String.class, String.class}); 
     178          m.invoke(store, new Object[] {key, value}); 
     179        } 
     180      } 
     181      catch (Throwable t) { 
     182        debug("Error populating OME-XML"); 
     183        trace(t); 
     184      } 
     185    } 
     186     
    165187    metadata.put(key, value); 
    166188  } 
     
    409431  } 
    410432 
     433  /* @see IFormatReader#setOriginalMetadataPopulated(boolean) */ 
     434  public void setOriginalMetadataPopulated(boolean populate) { 
     435    FormatTools.assertId(currentId, false, 1); 
     436    if (currentId != null) { 
     437      String s = "setOriginalMetadataPopulated called with open file."; 
     438      if (debug && debugLevel >= 2) trace(s); 
     439      else LogTools.println("Warning: " + s); 
     440    } 
     441    saveOriginalMetadata = populate; 
     442  } 
     443 
     444  /* @see IFormatReader#isOriginalMetadataPopulated() */ 
     445  public boolean isOriginalMetadataPopulated() { 
     446    return saveOriginalMetadata; 
     447  } 
     448 
    411449  /* @see IFormatReader#getUsedFiles() */ 
    412450  public String[] getUsedFiles() { 
  • trunk/loci/formats/IFormatReader.java

    r2801 r2957  
    192192  boolean isMetadataCollected(); 
    193193 
     194  /**  
     195   * Specifies whether or not to save proprietary metadata  
     196   * in the MetadataStore.  
     197   */ 
     198  void setOriginalMetadataPopulated(boolean populate); 
     199 
     200  /**  
     201   * Returns true if we should save proprietary metadata  
     202   * in the MetadataStore.  
     203   */ 
     204  boolean isOriginalMetadataPopulated(); 
     205 
    194206  /** Specifies whether or not to force grouping in multi-file formats. */ 
    195207  void setGroupFiles(boolean group); 
  • trunk/loci/formats/ImageReader.java

    r2857 r2957  
    425425  } 
    426426 
     427  /* @see IFormatReader#setOriginalMetadataPopulated(boolean) */ 
     428  public void setOriginalMetadataPopulated(boolean populate) { 
     429    FormatTools.assertId(currentId, false, 1); 
     430    for (int i=0; i<readers.length; i++) { 
     431      readers[i].setOriginalMetadataPopulated(populate); 
     432    } 
     433  } 
     434 
     435  /* @see IFormatReader#isOriginalMetadataPopulated() */ 
     436  public boolean isOriginalMetadataPopulated() { 
     437    return readers[0].isOriginalMetadataPopulated();  
     438  } 
     439 
    427440  /* @see IFormatReader#getCurrentFile() */ 
    428441  public String getCurrentFile() { 
  • trunk/loci/formats/ReaderWrapper.java

    r2796 r2957  
    218218  public boolean isMetadataCollected() { return reader.isMetadataCollected(); } 
    219219 
     220  public void setOriginalMetadataPopulated(boolean populate) { 
     221    reader.setOriginalMetadataPopulated(populate);  
     222  } 
     223 
     224  public boolean isOriginalMetadataPopulated() { 
     225    return reader.isOriginalMetadataPopulated();  
     226  } 
     227 
    220228  public String[] getUsedFiles() { 
    221229    return reader.getUsedFiles(); 
  • trunk/loci/formats/ome/OMEReader.java

    r2857 r2957  
    9595    else { 
    9696      sessionKey = id.substring(id.lastIndexOf("?") + 5, ndx); 
    97       ndx = id.indexOf("&", ndx + 1); 
    9897      imageId = id.substring(ndx + 4); 
    9998    } 
  • trunk/loci/formats/ome/OMEXMLMetadataStore.java

    r2922 r2957  
    9595  } 
    9696 
    97   /**  
    98    * Add each of the key/value pairs in the hashtable as a new 
    99    * OriginalMetadata node. 
    100    */ 
    101   public void populateOriginalMetadata(Hashtable h) { 
    102     ImageNode image = (ImageNode) getChild(root, "Image", 0); 
    103     CustomAttributesNode ca =  
    104       (CustomAttributesNode) getChild(image, "CustomAttributes", 0); 
    105     firstImageCA = ca.getDOMElement(); 
    106  
    107     Vector original = DOMUtil.getChildElements("OriginalMetadata",  
    108       ca.getDOMElement()); 
     97  /** Add the key/value pair as a new OriginalMetadata node. */  
     98  public void populateOriginalMetadata(String key, String value) { 
     99    if (firstImageCA == null) {  
     100      ImageNode image = (ImageNode) getChild(root, "Image", 0); 
     101      CustomAttributesNode ca =  
     102        (CustomAttributesNode) getChild(image, "CustomAttributes", 0); 
     103      firstImageCA = ca.getDOMElement(); 
     104    } 
     105 
     106    Vector original = DOMUtil.getChildElements("OriginalMetadata", firstImageCA); 
    109107    if (original.size() == 0) { 
    110108      Element el = DOMUtil.createChild(root.getDOMElement(), 
     
    131129    } 
    132130 
    133     Object[] keys = h.keySet().toArray(); 
    134     for (int i=0; i<h.size(); i++) { 
    135       Element el = DOMUtil.createChild(firstImageCA, "OriginalMetadata"); 
    136       OMEXMLNode node = new AttributeNode(el); 
    137       node.setAttribute("name", keys[i].toString()); 
    138       node.setAttribute("value", h.get(keys[i]).toString()); 
    139     }  
     131    Element el = DOMUtil.createChild(firstImageCA, "OriginalMetadata"); 
     132    OMEXMLNode node = new AttributeNode(el); 
     133    node.setAttribute("name", key); 
     134    node.setAttribute("value", value); 
    140135  } 
    141136 
Note: See TracChangeset for help on using the changeset viewer.