loci.formats.services

## Interface NetCDFService

- All Superinterfaces:
    loci.common.services.Service
  All Known Implementing Classes:
    NetCDFServiceImpl

      public interface NetCDFService
      extends loci.common.services.Service

  Utility class for working with NetCDF/HDF files. Uses reflection to call the NetCDF Java library.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes and resets the service.
    `java.lang.Object` | `getArray(java.lang.String path, int[] origin, int[] shape)` Retrieves an HDF path's values.
    `java.util.Vector<java.lang.String>` | `getAttributeList()` Retrieves an exhaustive list of the HDF paths for all attributes in the HDF document.
    `java.lang.String` | `getAttributeValue(java.lang.String path)` Retrieves an attribute's value.
    `int` | `getDimension(java.lang.String path)` Retrieves the length of a dimension.
    `java.lang.String` | `getFile()` Retrieves the current initialized file path.
    `java.util.Hashtable<java.lang.String,java.lang.Object>` | `getVariableAttributes(java.lang.String path)` Retrieves all of a variable's attributes.
    `java.util.Vector<java.lang.String>` | `getVariableList()` Retrieves an exhaustive list of the HDF paths for all variables in the HDF document.
    `java.lang.Object` | `getVariableValue(java.lang.String path)` Retrieves a variable's value.
    `void` | `setFile(java.lang.String file)` Initializes the service on a given file path.

- - ### Method Detail

    - #### setFile

          void setFile(java.lang.String file)
                throws java.io.IOException

      Initializes the service on a given file path.
      Parameters:
        `file` - Path to initialize the service with.
      Throws:
        `java.io.IOException` - If there is an error initializing the service with `file`.

    - #### getFile

          java.lang.String getFile()

      Retrieves the current initialized file path.
      Returns:
        Current initialized file path or `null` if the service has yet to be initialized or is closed.

    - #### getAttributeList

          java.util.Vector<java.lang.String> getAttributeList()

      Retrieves an exhaustive list of the HDF paths for all attributes in the HDF document.
      Returns:
        Collection of attribute paths.

    - #### getVariableList

          java.util.Vector<java.lang.String> getVariableList()

      Retrieves an exhaustive list of the HDF paths for all variables in the HDF document.
      Returns:
        Collection of variable paths.

    - #### getAttributeValue

          java.lang.String getAttributeValue(java.lang.String path)

      Retrieves an attribute's value.
      Parameters:
        `path` - HDF path to the attribute.
      Returns:
        String value or `null` if the attribute is not a string.

    - #### getVariableValue

          java.lang.Object getVariableValue(java.lang.String path)
                                     throws loci.common.services.ServiceException

      Retrieves a variable's value.
      Parameters:
        `path` - HDF path to the variable.
      Returns:
        The Java one-dimensional array representation of the variable's values.
      Throws:
        `loci.common.services.ServiceException` - If there is an error with the range of values or reading from the file.
      See Also:
        `Array.copyTo1DJavaArray()`

    - #### getArray

          java.lang.Object getArray(java.lang.String path,
                                    int[] origin,
                                    int[] shape)
                             throws loci.common.services.ServiceException

      Retrieves an HDF path's values.
      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:
        `loci.common.services.ServiceException` - If there is an error with the range of values or reading from the file.
      See Also:
        `Variable.read(int[], int[])`, `Array.copyToNDJavaArray()`

    - #### getVariableAttributes

          java.util.Hashtable<java.lang.String,java.lang.Object> getVariableAttributes(java.lang.String path)

      Retrieves all of a variable's attributes.
      Parameters:
        `path` - HDF path to the variable.
      Returns:
        Hash table of attributes to Java one-dimensional array representations of the attribute's values.
      See Also:
        `Array.copyTo1DJavaArray()`

    - #### getDimension

          int getDimension(java.lang.String path)

      Retrieves the length of a dimension.
      Parameters:
        `path` - HDF path to the dimension.
      Returns:
        Length of the dimension.

    - #### close

          void close()
              throws java.io.IOException

      Closes and resets the service.
      Throws:
        `java.io.IOException` - If there is an error closing the file.

Copyright © 2026 Open Microscopy Environment