loci.formats.services

## Class JHDFServiceImpl

- java.lang.Object
- - loci.common.services.AbstractService
  - - loci.formats.services.JHDFServiceImpl

- All Implemented Interfaces:
    loci.common.services.Service, JHDFService

      public class JHDFServiceImpl
      extends loci.common.services.AbstractService
      implements JHDFService

  Utility class for working with HDF files.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.lang.String` | `currentFile`
    `private ch.systemsx.cisd.hdf5.IHDF5Reader` | `hdfReader` Root of the HDF5 file.
    `private ch.systemsx.cisd.hdf5.IHDF5Writer` | `hdfWriter` Root of the HDF5 file.
    `static java.lang.String` | `NO_JHDF_MSG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JHDFServiceImpl()` Default constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes and resets the service.
    `void` | `createGroup(java.lang.String path)` Writes an array as sub-slice into an existing HDF5 dataset
    `boolean` | `exists(java.lang.String path)` Checks if path in HDF5 file exists.
    `int` | `getElementSize(java.lang.String path)` Retrieves the Element Size of a dataset in Byte.
    `java.lang.String` | `getFile()` Retrieves the current initialized file path.
    `java.util.List<java.lang.String>` | `getMember(java.lang.String path)` Retrieves the all members of a group.
    `int[]` | `getShape(java.lang.String path)` Retrieves the shape of a dataset.
    `void` | `initIntArray(java.lang.String path, long[] dimensions, long bpp)` Creates an HDF5 dataset in path consisting of integers specified by bytes per pixel bpp.
    `ch.systemsx.cisd.base.mdarray.MDByteArray` | `readByteArray(java.lang.String path)` Reads a multi-dimensional byte array from path.
    `ch.systemsx.cisd.base.mdarray.MDByteArray` | `readByteBlockArray(java.lang.String path, int[] offset, int[] size)` Reads a multi-dimensional sub-block byte array from path.
    `ch.systemsx.cisd.hdf5.HDF5CompoundDataMap[]` | `readCompoundArrayDataMap(java.lang.String path)` Reads Compound array of any type
    `ch.systemsx.cisd.base.mdarray.MDIntArray` | `readIntArray(java.lang.String path)` Reads a multi-dimensional int array from path.
    `ch.systemsx.cisd.base.mdarray.MDIntArray` | `readIntBlockArray(java.lang.String path, int[] offset, int[] size)` Reads a multi-dimensional sub-block int array from path.
    `ch.systemsx.cisd.base.mdarray.MDShortArray` | `readShortBlockArray(java.lang.String path, int[] offset, int[] size)` Reads a multi-dimensional sub-block short array from path.
    `java.lang.String[]` | `readStringArray(java.lang.String path)` Reads String array array from path.
    `void` | `setFile(java.lang.String file)` Initializes the service on a given file path.
    `void` | `setFileForWrite(java.lang.String file)` Initializes the service on a given file path.
    `void` | `writeArraySlice(java.lang.String path, ch.systemsx.cisd.base.mdarray.MDByteArray image, long[] offset)` Writes an array as sub-slice into an existing HDF5 dataset
    `void` | `writeArraySlice(java.lang.String path, ch.systemsx.cisd.base.mdarray.MDIntArray image, long[] offset)` Writes an array as sub-slice into an existing HDF5 dataset
    `void` | `writeArraySlice(java.lang.String path, ch.systemsx.cisd.base.mdarray.MDShortArray image, long[] offset)` Writes an array as sub-slice into an existing HDF5 dataset

    - ### Methods inherited from class loci.common.services.AbstractService

      `checkClassDependency`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NO_JHDF_MSG

          public static final java.lang.String NO_JHDF_MSG

    - #### currentFile

          private java.lang.String currentFile

    - #### hdfReader

          private ch.systemsx.cisd.hdf5.IHDF5Reader hdfReader

      Root of the HDF5 file.

    - #### hdfWriter

          private ch.systemsx.cisd.hdf5.IHDF5Writer hdfWriter

      Root of the HDF5 file.

  - ### Constructor Detail

    - #### JHDFServiceImpl

          public JHDFServiceImpl()

      Default constructor.

  - ### Method Detail

    - #### setFile

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

      Description copied from interface: `JHDFService`
      Initializes the service on a given file path.
      Specified by:
        `setFile` in interface `JHDFService`
      Parameters:
        `file` - Path to initialize the service with.
      Throws:
        `java.io.IOException` - If there is an error initializing the service with `file`.

    - #### setFileForWrite

          public void setFileForWrite(java.lang.String file)
                               throws java.io.IOException

      Description copied from interface: `JHDFService`
      Initializes the service on a given file path.
      Specified by:
        `setFileForWrite` in interface `JHDFService`
      Parameters:
        `file` - Path to initialize the service with.
      Throws:
        `java.io.IOException` - If there is an error initializing the service with `file`.

    - #### getFile

          public java.lang.String getFile()

      Description copied from interface: `JHDFService`
      Retrieves the current initialized file path.
      Specified by:
        `getFile` in interface `JHDFService`
      Returns:
        Current initialized file path or `null` if the service has yet to be initialized or is closed.

    - #### getMember

          public java.util.List<java.lang.String> getMember(java.lang.String path)

      Description copied from interface: `JHDFService`
      Retrieves the all members of a group.
      Specified by:
        `getMember` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the group.
      Returns:
        List of members.

    - #### getShape

          public int[] getShape(java.lang.String path)

      Description copied from interface: `JHDFService`
      Retrieves the shape of a dataset.
      Specified by:
        `getShape` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the dataset.
      Returns:
        int[] of shapes.

    - #### readByteArray

          public ch.systemsx.cisd.base.mdarray.MDByteArray readByteArray(java.lang.String path)

      Description copied from interface: `JHDFService`
      Reads a multi-dimensional byte array from path.
      Specified by:
        `readByteArray` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the dataset.
      Returns:
        MDByteArray array of bytes.

    - #### readIntArray

          public ch.systemsx.cisd.base.mdarray.MDIntArray readIntArray(java.lang.String path)

      Description copied from interface: `JHDFService`
      Reads a multi-dimensional int array from path.
      Specified by:
        `readIntArray` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the dataset.
      Returns:
        MDIntArray array of int.

    - #### readIntBlockArray

          public ch.systemsx.cisd.base.mdarray.MDIntArray readIntBlockArray(java.lang.String path,
                                                                            int[] offset,
                                                                            int[] size)

      Description copied from interface: `JHDFService`
      Reads a multi-dimensional sub-block int array from path.
      Specified by:
        `readIntBlockArray` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the dataset.
        `offset` - Offset of the block to read.
        `size` - Output size of the array.
      Returns:
        MDIntArray array of int.

    - #### readByteBlockArray

          public ch.systemsx.cisd.base.mdarray.MDByteArray readByteBlockArray(java.lang.String path,
                                                                              int[] offset,
                                                                              int[] size)

      Description copied from interface: `JHDFService`
      Reads a multi-dimensional sub-block byte array from path.
      Specified by:
        `readByteBlockArray` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the dataset.
        `offset` - Offset of the block to read.
        `size` - Output size of the array.
      Returns:
        MDIntArray array of int.

    - #### readShortBlockArray

          public ch.systemsx.cisd.base.mdarray.MDShortArray readShortBlockArray(java.lang.String path,
                                                                                int[] offset,
                                                                                int[] size)

      Description copied from interface: `JHDFService`
      Reads a multi-dimensional sub-block short array from path.
      Specified by:
        `readShortBlockArray` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the dataset.
        `offset` - Offset of the block to read.
        `size` - Output size of the array.
      Returns:
        MDIntArray array of int.

    - #### readStringArray

          public java.lang.String[] readStringArray(java.lang.String path)

      Description copied from interface: `JHDFService`
      Reads String array array from path.
      Specified by:
        `readStringArray` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the dataset.
      Returns:
        String[] array.

    - #### readCompoundArrayDataMap

          public ch.systemsx.cisd.hdf5.HDF5CompoundDataMap[] readCompoundArrayDataMap(java.lang.String path)

      Description copied from interface: `JHDFService`
      Reads Compound array of any type
      Specified by:
        `readCompoundArrayDataMap` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the dataset.
      Returns:
        HDF5CompoundDataMap[] compound array map.

    - #### getElementSize

          public int getElementSize(java.lang.String path)

      Description copied from interface: `JHDFService`
      Retrieves the Element Size of a dataset in Byte.
      Specified by:
        `getElementSize` in interface `JHDFService`
      Parameters:
        `path` - HDF path to the group.
      Returns:
        List of members.

    - #### initIntArray

          public void initIntArray(java.lang.String path,
                                   long[] dimensions,
                                   long bpp)

      Description copied from interface: `JHDFService`
      Creates an HDF5 dataset in path consisting of integers specified by bytes per pixel bpp.
      Specified by:
        `initIntArray` in interface `JHDFService`
      Parameters:
        `path` - path to HDF5 a dataset.
        `bpp` - bytes per pixel for the integer data type bpp \in {1,2,4} == {Byte, Short, Integer}

    - #### writeArraySlice

          public void writeArraySlice(java.lang.String path,
                                      ch.systemsx.cisd.base.mdarray.MDByteArray image,
                                      long[] offset)

      Description copied from interface: `JHDFService`
      Writes an array as sub-slice into an existing HDF5 dataset
      Specified by:
        `writeArraySlice` in interface `JHDFService`
      Parameters:
        `path` - path to the (existing) HDF5 dataset.
        `image` - the data stored as MDArray of pixel type Byte
        `offset` - dimensions, where to start writing the image. The image will be written from offset to offset + image.dimensions()

    - #### writeArraySlice

          public void writeArraySlice(java.lang.String path,
                                      ch.systemsx.cisd.base.mdarray.MDShortArray image,
                                      long[] offset)

      Description copied from interface: `JHDFService`
      Writes an array as sub-slice into an existing HDF5 dataset
      Specified by:
        `writeArraySlice` in interface `JHDFService`
      Parameters:
        `path` - path to the (existing) HDF5 dataset.
        `image` - the data stored as MDArray of pixel type Short
        `offset` - dimensions, where to start writing the image. The image will be written from offset to offset + image.dimensions()

    - #### writeArraySlice

          public void writeArraySlice(java.lang.String path,
                                      ch.systemsx.cisd.base.mdarray.MDIntArray image,
                                      long[] offset)

      Description copied from interface: `JHDFService`
      Writes an array as sub-slice into an existing HDF5 dataset
      Specified by:
        `writeArraySlice` in interface `JHDFService`
      Parameters:
        `path` - path to the (existing) HDF5 dataset.
        `image` - the data stored as MDArray of pixel type int
        `offset` - dimensions, where to start writing the image. The image will be written from offset to offset + image.dimensions()

    - #### createGroup

          public void createGroup(java.lang.String path)
                           throws java.io.IOException

      Description copied from interface: `JHDFService`
      Writes an array as sub-slice into an existing HDF5 dataset
      Specified by:
        `createGroup` in interface `JHDFService`
      Parameters:
        `path` - path of the HDF5 group.
      Throws:
        `java.io.IOException`

    - #### exists

          public boolean exists(java.lang.String path)

      Description copied from interface: `JHDFService`
      Checks if path in HDF5 file exists.
      Specified by:
        `exists` in interface `JHDFService`
      Parameters:
        `path` - path to HDF5 group or dataset.
      Returns:
        boolean true if path exists in HDF5 file else false.

    - #### close

          public void close()
                     throws java.io.IOException

      Description copied from interface: `JHDFService`
      Closes and resets the service.
      Specified by:
        `close` in interface `JHDFService`
      Throws:
        `java.io.IOException` - If there is an error closing the file.

Copyright © 2026 Open Microscopy Environment