Class GdaMetadata

All Implemented Interfaces:
Metadata, Configurable, Findable, gda.observable.IObservable, gda.observable.IObserver

@ServiceInterface(Metadata.class) public class GdaMetadata extends FindableConfigurableBase implements Metadata, gda.observable.IObserver
A concrete implementation of the Metadata interface. The class stores a list of IMetadataEntry objects and provides access to those objects and their contents. Metadata can be added programatically or configured via XML.
  • Constructor Details

    • GdaMetadata

      public GdaMetadata()
      Constructor.
  • Method Details

    • configure

      public void configure() throws FactoryException
      Description copied from class: ConfigurableBase
      Default implementation for classes that do not have to do any specific configuration.
      Classes that do their own configuration should *not* call this superclass function, as it may cause the object to appear configured before it really is.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class ConfigurableBase
      Throws:
      FactoryException - if there is an error in configuration e.g. required variable not set or cannot connect to device
    • setMetadataValue

      public void setMetadataValue(String name, String metadataValue)
      Description copied from interface: Metadata
      Sets the the value of a named metadata entry, for further information on what type of metadata this method can be used for see IMetadataEntry
      Specified by:
      setMetadataValue in interface Metadata
      Parameters:
      name - The name for which the metadata value is to be changed.
      metadataValue - The value required for the metadata entry.
      See Also:
    • getMetadataValue

      public String getMetadataValue(String name)
      Description copied from interface: Metadata
      Returns the value of a named metadata entry.
      Specified by:
      getMetadataValue in interface Metadata
      Parameters:
      name - The name of the required metadata entry.
      Returns:
      The value of the required metadata entry.
    • getMetadataValue

      public String getMetadataValue(String metadataName, String fallbackJavaProperty, String defaultValue)
      Description copied from interface: Metadata
      Gets the metadata value.
      Specified by:
      getMetadataValue in interface Metadata
      Parameters:
      metadataName - The name of the required metadata entry.
      fallbackJavaProperty - If set the value of this property will be used as a fallback.
      defaultValue - The default value for the fallback property i.e. it's value if the property is not set.
      Returns:
      The metadata value
    • addMetadataEntry

      public void addMetadataEntry(IMetadataEntry entry)
      Description copied from interface: Metadata
      Adds an entry to the metadata list or replaces its contents. If the name of the entry matches one already in the metadata list then the properties of that entry are changed to be the same as those passed in.
      Specified by:
      addMetadataEntry in interface Metadata
      Parameters:
      entry - MetadataListEntry The entry to be added.
    • getMetadataEntries

      public List<IMetadataEntry> getMetadataEntries()
      Description copied from interface: Metadata
      Fetches all the metadata entries in the list of metadata.
      Specified by:
      getMetadataEntries in interface Metadata
      Returns:
      ArrayList The list of MetadataEntry objects.
    • getMetadataEntry

      public IMetadataEntry getMetadataEntry(String name)
      Description copied from interface: Metadata
      Get a metadata entry by name
      Specified by:
      getMetadataEntry in interface Metadata
      Parameters:
      name - name of required entry
      Returns:
      metadata entry or null if there is no entry with this name
    • setMetadataEntries

      public void setMetadataEntries(List<IMetadataEntry> entries)
      Sets the entries within this metadata.
      Parameters:
      entries - the metadata entries
    • removeMetadataEntry

      public void removeMetadataEntry(String name)
      Removes the metadata entry with the specified name.
      Parameters:
      name - the metadata entry name
    • setName

      public void setName(String name)
      Description copied from interface: Findable
      Set or change the name of the object (as defined in XML).
      Specified by:
      setName in interface Findable
      Overrides:
      setName in class FindableConfigurableBase
      Parameters:
      name - the object name
    • update

      public void update(Object source, Object arg)
      Specified by:
      update in interface gda.observable.IObserver
    • addIObserver

      public void addIObserver(gda.observable.IObserver observer)
      Specified by:
      addIObserver in interface gda.observable.IObservable
    • deleteIObserver

      public void deleteIObserver(gda.observable.IObserver observer)
      Specified by:
      deleteIObserver in interface gda.observable.IObservable
    • deleteIObservers

      public void deleteIObservers()
      Specified by:
      deleteIObservers in interface gda.observable.IObservable
    • __getitem__

      public String __getitem__(String metaname)
      Convenience method for getting metadata from Jython
       >>> metadata['visit']
       'ab1234-5'
       >>> # is equivalent to
       >>> metadata.getMetadataValue('visit')
       'ab1234-5'
       >>>
       
      NB. this will return an empty string if no matching metadata entry is present
      Parameters:
      metaname - The name of the metadata to get
      See Also:
    • __setitem__

      public void __setitem__(String metaname, String metavalue)
      Convenience method for setting metadata from Jython
       >>> metadata['visit'] = 'ab1234-5'
       >>> # is equivalent to
       >>> metadata.setMetadataValue('visit', 'ab1234-5')
       
      NB this will not add a new metadata entry if an existing one is not present
      Parameters:
      metaname - The name of the metadata to set
      metavalue - The new value of the metadata entry
      See Also:
    • __contains__

      public boolean __contains__(Object name)
      Convenience method for checking if a metadata entry is present from Jython.
       >>> 'visit' in metadata
       True
       >>> 'foobar' in metadata
       False
       
      Parameters:
      name - The metadata entry to check
      Returns:
      True if there is a metadata entry present for the given name