Interface NexusFile

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
NexusFileHDF5

public interface NexusFile extends AutoCloseable
Replacement for old Nexus file interface All elements of a path can be augmented with an optional NX_class string appended on with a ":". If the NX_class attribute does not match then an IllegalArgumentException will be thrown.
  • Field Details

  • Method Details

    • getFilePath

      String getFilePath()
      Returns the file path of this NexusFile
      Returns:
      file path
    • openToRead

      void openToRead() throws NexusException
      Open file to only read
      Throws:
      IOException
      NexusException
    • openToWrite

      void openToWrite(boolean createIfNecessary) throws NexusException
      Open file to write
      Parameters:
      createIfNecessary - if true, then create file if it does not exist
      Throws:
      IOException
      NexusException
    • createAndOpenToWrite

      void createAndOpenToWrite() throws NexusException
      Create file and open to write
      Throws:
      IOException
      NexusException
    • setWritesAsync

      void setWritesAsync(boolean async)
      Set to writes to be performed asynchronously for data nodes created after calling this
      Parameters:
      async -
    • setCacheDataset

      void setCacheDataset(boolean cacheDataset)
      Sets the datasets written to to be held open until the file is closed With this value set to true, datasets will not be flushed until the file is closed, call flushAllCachedDatasets() to flush
      Parameters:
      cacheDataset -
    • flushAllCachedDatasets

      void flushAllCachedDatasets()
      Flush datasets cached when setCacheDataset(boolean) is set true
    • setDebug

      void setDebug(boolean debug)
      Set to instrument some method calls via logging at the DEBUG level
      Parameters:
      debug -
    • getRoot

      String getRoot()
      Get the path of root node from internal tree
      Returns:
      root node path
    • getPath

      String getPath(Node node)
      Get path of node from internal tree
      Parameters:
      node - (can be null for root)
      Returns:
      (depth-first) path of node
    • getGroup

      GroupNode getGroup(String path, boolean createPathIfNecessary) throws NexusException
      Get group with given path and create path if necessary
      Parameters:
      path -
      createPathIfNecessary -
      Returns:
      node or null if group does not exist at specified path
      Throws:
      NexusException
    • getGroup

      GroupNode getGroup(GroupNode group, String name, String nxClass, boolean createPathIfNecessary) throws NexusException
      Get group in group with given name and create path if necessary
      Parameters:
      group - (can be null for root)
      name -
      nxClass -
      createPathIfNecessary -
      Returns:
      node or null
      Throws:
      NexusException - if node is not a group at specified path or group does not exist and not creating path
    • getData

      DataNode getData(String path) throws NexusException
      Get data node with given path
      Parameters:
      path -
      Returns:
      node or null if data does not exist at specified path
      Throws:
      NexusException
    • getData

      DataNode getData(GroupNode group, String name) throws NexusException
      Get data node in group with given name
      Parameters:
      group - (can be null for root)
      name -
      Returns:
      node or null if data does not exist in group
      Throws:
      NexusException
    • addNode

      void addNode(String path, Node node) throws NexusException
      Add node to given path. This will recursively add other nodes if the given node is a group node.
      Parameters:
      path -
      node -
      Throws:
      NexusException - if node already exists at given path or parts of path does not exist
    • addNode

      void addNode(GroupNode group, String name, Node node) throws NexusException
      Add node to group. This will recursively add other nodes if the given node is a group node.
      Parameters:
      group - parent group (can be null for root)
      name -
      node -
      Throws:
      NexusException - if node already exists in group with name
    • removeNode

      void removeNode(String path, String name) throws NexusException
      Remove node from given path.

      Note, this will fail if the file is in SWMR node

      Parameters:
      path - path to parent group of node
      name - name of node in parent group
      Throws:
      NexusException
    • removeNode

      void removeNode(GroupNode group, String name) throws NexusException
      Remove node from given group.

      Note, this will fail if the file is in SWMR node

      Parameters:
      group - parent group of node (can be null for root)
      name - name of node in parent group
      Throws:
      NexusException
    • createData

      DataNode createData(String path, org.eclipse.january.dataset.ILazyWriteableDataset data, boolean createPathIfNecessary) throws NexusException
      Create data node with given path to its group and create path if necessary The name of the dataset is used as the name of the data node within the parent group.
      Parameters:
      path - to group
      data -
      createPathIfNecessary -
      Returns:
      node or null if data does not exist at specified path
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(String path, String name, org.eclipse.january.dataset.ILazyWriteableDataset data, boolean createPathIfNecessary) throws NexusException
      Create data node with given name and path to its group and create path if necessary.
      Parameters:
      path - to parent group
      name - name within parent group
      data -
      createPathIfNecessary -
      Returns:
      node or null if data does not exist at specified path
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(String path, org.eclipse.january.dataset.ILazyWriteableDataset data, int compression, boolean createPathIfNecessary) throws NexusException
      Create data node with given path to its group and create path if necessary
      Parameters:
      path - to parent group
      data - data
      compression -
      createPathIfNecessary -
      Returns:
      node or null if data does not exist at specified path
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(String path, String name, org.eclipse.january.dataset.ILazyWriteableDataset data, int compression, boolean createPathIfNecessary) throws NexusException
      Create data node with given name and path to its group and create path if necessary
      Parameters:
      path - to parent group
      name - name within parent group
      data - dataset
      compression -
      createPathIfNecessary -
      Returns:
      node or null if data does not exist at specified path
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(String path, org.eclipse.january.dataset.IDataset data, boolean createPathIfNecessary) throws NexusException
      Create data node with given path to its group and create path if necessary
      Parameters:
      path - to group
      data - dataset
      createPathIfNecessary -
      Returns:
      node or null if data does not exist at specified path
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(String path, String name, org.eclipse.january.dataset.IDataset data, boolean createPathIfNecessary) throws NexusException
      Create data node with given path to its group and create path if necessary
      Parameters:
      path - to group
      name - name within parent group
      data - dataset
      createPathIfNecessary -
      Returns:
      node or null if data does not exist at specified path
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(GroupNode group, org.eclipse.january.dataset.ILazyWriteableDataset data) throws NexusException
      Create data node in given group
      Parameters:
      group - parent group (can be null for root)
      data - dataset
      Returns:
      node
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(GroupNode group, String name, org.eclipse.january.dataset.ILazyWriteableDataset data) throws NexusException
      Create data node with given name in given group
      Parameters:
      group - parent group (can be null for root)
      name - name within group
      data - dataset
      Returns:
      node
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(GroupNode group, org.eclipse.january.dataset.ILazyWriteableDataset data, int compression) throws NexusException
      Create data node in given group
      Parameters:
      group - parent group (can be null for root)
      data -
      compression -
      Returns:
      node
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(GroupNode group, String name, org.eclipse.january.dataset.ILazyWriteableDataset data, int compression) throws NexusException
      Create data node with given name in given group
      Parameters:
      group - parent group (can be null for root)
      data - dataset
      compression -
      Returns:
      node
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(GroupNode group, org.eclipse.january.dataset.IDataset data) throws NexusException
      Create data node in given group
      Parameters:
      group - parent group (can be null for root)
      data - dataset
      Returns:
      node
      Throws:
      NexusException - when node already exists
    • createData

      DataNode createData(GroupNode group, String name, org.eclipse.january.dataset.IDataset data) throws NexusException
      Create data node with given name in given group
      Parameters:
      group - parent group (can be null for root)
      name - name within group
      data - dataset
      Returns:
      Throws:
      NexusException
    • createAttribute

      Attribute createAttribute(org.eclipse.january.dataset.IDataset attr)
      Create attribute
      Parameters:
      attr -
      Returns:
      attribute
    • getAttributeValue

      String getAttributeValue(String path) throws NexusException
      The full attribute key is: @ e.g. /entry1/data@napimount
      Parameters:
      fullAttributeKey -
      Returns:
      Throws:
      NexusException
    • addAttribute

      void addAttribute(Node node, Attribute... attribute) throws NexusException
      Add (and write) attribute(s) to given node
      Parameters:
      node - (can be null for root)
      attribute -
      Throws:
      NexusException
    • addAttribute

      void addAttribute(String path, Attribute... attribute) throws NexusException
      Add (and write) attribute(s) to given path
      Parameters:
      path -
      attribute -
      Throws:
      NexusException
    • link

      void link(String source, String destination) throws NexusException
      Link source to a destination. If the destination ends in "/" then the source name is added to the destination.
      Parameters:
      source -
      destination -
      Throws:
      NexusException
    • linkExternal

      void linkExternal(URI source, String destination, boolean isGroup) throws NexusException
      Link source in another file to a destination. If the destination ends in "/" then the source name is added to the destination.
      Parameters:
      source -
      destination -
      isGroup -
      Throws:
      NexusException
    • flush

      int flush() throws NexusException
      Flush data to filesystem
      Returns:
      the nexus int code for the flush or -1 if unsucessfull.
      Throws:
      NexusException
    • close

      void close() throws NexusException
      Close file
      Specified by:
      close in interface AutoCloseable
      Throws:
      NexusException
    • isPathValid

      boolean isPathValid(String path)
      Checks if a path within the file exists
      Parameters:
      path -
      Returns:
      true if path exists
    • activateSwmrMode

      void activateSwmrMode() throws NexusException
      Activates SWMR mode. The file must have been created as with SWMR enabled.
      Throws:
      NexusException - if SWMR mode could not be activated
    • getNode

      Node getNode(String path) throws NexusException
      Get Node with given path. Can be a GroupNode or a DataNode
      Parameters:
      path -
      Returns:
      node or null if group does not exist at specified path
      Throws:
      NexusException