Class NetCDFServiceImpl

java.lang.Object
loci.common.services.AbstractService
loci.formats.services.NetCDFServiceImpl
All Implemented Interfaces:
KryoSerializable, Service, NetCDFService

public class NetCDFServiceImpl extends AbstractService implements NetCDFService, KryoSerializable
Utility class for working with NetCDF/HDF files. Uses reflection to call the NetCDF Java library.
  • Field Details

    • NO_NETCDF_MSG

      public static final String NO_NETCDF_MSG
  • Constructor Details

    • NetCDFServiceImpl

      public NetCDFServiceImpl()
      Default constructor.
  • Method Details

    • setFile

      public void setFile(String file) throws IOException
      Description copied from interface: NetCDFService
      Initializes the service on a given file path.
      Specified by:
      setFile in interface NetCDFService
      Parameters:
      file - Path to initialize the service with.
      Throws:
      IOException - If there is an error initializing the service with file.
    • getFile

      public String getFile()
      Description copied from interface: NetCDFService
      Retrieves the current initialized file path.
      Specified by:
      getFile in interface NetCDFService
      Returns:
      Current initialized file path or null if the service has yet to be initialized or is closed.
    • getAttributeList

      public Vector<String> getAttributeList()
      Description copied from interface: NetCDFService
      Retrieves an exhaustive list of the HDF paths for all attributes in the HDF document.
      Specified by:
      getAttributeList in interface NetCDFService
      Returns:
      Collection of attribute paths.
    • getVariableList

      public Vector<String> getVariableList()
      Description copied from interface: NetCDFService
      Retrieves an exhaustive list of the HDF paths for all variables in the HDF document.
      Specified by:
      getVariableList in interface NetCDFService
      Returns:
      Collection of variable paths.
    • getAttributeValue

      public String getAttributeValue(String path)
      Description copied from interface: NetCDFService
      Retrieves an attribute's value.
      Specified by:
      getAttributeValue in interface NetCDFService
      Parameters:
      path - HDF path to the attribute.
      Returns:
      String value or null if the attribute is not a string.
    • getVariableValue

      public Object getVariableValue(String name) throws ServiceException
      Description copied from interface: NetCDFService
      Retrieves a variable's value.
      Specified by:
      getVariableValue in interface NetCDFService
      Parameters:
      name - HDF path to the variable.
      Returns:
      The Java one-dimensional array representation of the variable's values.
      Throws:
      ServiceException - If there is an error with the range of values or reading from the file.
      See Also:
    • getArray

      public Object getArray(String path, int[] origin, int[] shape) throws ServiceException
      Description copied from interface: NetCDFService
      Retrieves an HDF path's values.
      Specified by:
      getArray in interface NetCDFService
      Parameters:
      path - HDF path to the values.
      origin - Array specifying the starting index. If null, assume all zeroes.
      shape - Array specifying the extents in each dimension. This becomes the shape of the returned Array.
      Returns:
      The Java n-dimensional array representation of the path's values.
      Throws:
      ServiceException - If there is an error with the range of values or reading from the file.
      See Also:
    • getVariableAttributes

      public Hashtable<String,Object> getVariableAttributes(String name)
      Description copied from interface: NetCDFService
      Retrieves all of a variable's attributes.
      Specified by:
      getVariableAttributes in interface NetCDFService
      Parameters:
      name - HDF path to the variable.
      Returns:
      Hash table of attributes to Java one-dimensional array representations of the attribute's values.
      See Also:
    • getDimension

      public int getDimension(String name)
      Description copied from interface: NetCDFService
      Retrieves the length of a dimension.
      Specified by:
      getDimension in interface NetCDFService
      Parameters:
      name - HDF path to the dimension.
      Returns:
      Length of the dimension.
    • close

      public void close() throws IOException
      Description copied from interface: NetCDFService
      Closes and resets the service.
      Specified by:
      close in interface NetCDFService
      Throws:
      IOException - If there is an error closing the file.
    • read

      public void read(Kryo kryo, Input in)
      Specified by:
      read in interface KryoSerializable
    • write

      public void write(Kryo kryo, Output out)
      Specified by:
      write in interface KryoSerializable