All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generated.docs.javadoc.io.github.h5jan.core.NxsFile.html Maven / Gradle / Ivy






NxsFile (h5jan API)












io.github.h5jan.core

Class NxsFile

  • java.lang.Object
    • io.github.h5jan.core.NxsFile
  • All Implemented Interfaces:
    java.lang.AutoCloseable


    public class NxsFile
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A simple delegate class which wraps the Dawnsci classes for easy reading and writing of datasets. You may also use the dawnsci classes directly however this API will be backwardsly compatible and not leak details of HDF5.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void activateSwmrMode()
      Activates SWMR mode.
      void addAttribute(Node node, Attribute... attribute)
      Add (and write) attribute(s) to given node
      void addAttribute(java.lang.String path, Attribute... attribute)
      Add (and write) attribute(s) to given path
      void addNode(GroupNode group, java.lang.String name, Node node)
      Add node to group.
      void addNode(java.lang.String path, Node node)
      Add node to given path.
      void close() 
      static NxsFile create(java.lang.String path)
      Create a new H5 file (overwriting any existing one)
      static NxsFile create(java.lang.String path, boolean enableSWMR)
      Create a new Nexus file (overwriting any existing one)
      Attribute createAttribute(IDataset attr)
      Create attribute
      DataNode createData(GroupNode group, IDataset data)
      Create data node in given group
      DataNode createData(GroupNode group, ILazyWriteableDataset data)
      Create data node in given group
      DataNode createData(GroupNode group, ILazyWriteableDataset data, int compression)
      Create data node in given group
      DataNode createData(GroupNode group, java.lang.String name, IDataset data)
      Create data node with given name in given group
      DataNode createData(GroupNode group, java.lang.String name, ILazyWriteableDataset data)
      Create data node with given name in given group
      DataNode createData(GroupNode group, java.lang.String name, ILazyWriteableDataset data, int compression)
      Create data node with given name in given group
      DataNode createData(java.lang.String path, IDataset data, boolean createPathIfNecessary)
      Create data node with given path to its group and create path if necessary
      DataNode createData(java.lang.String path, ILazyWriteableDataset data, boolean createPathIfNecessary)
      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.
      DataNode createData(java.lang.String path, ILazyWriteableDataset data, int compression, boolean createPathIfNecessary)
      Get data node in group with given name
      DataNode createData(java.lang.String path, java.lang.String name, IDataset data, boolean createPathIfNecessary)
      Create data node with given path to its group and create path if necessary
      DataNode createData(java.lang.String path, java.lang.String name, ILazyWriteableDataset data, boolean createPathIfNecessary)
      Create data node with given name and path to its group and create path if necessary.
      DataNode createData(java.lang.String path, java.lang.String name, ILazyWriteableDataset data, int compression, boolean createPathIfNecessary)
      Create data node with given name and path to its group and create path if necessary
      boolean equals(java.lang.Object obj) 
      int flush()
      Flush data to filesystem
      void flushAllCachedDatasets()
      Flush datasets cached when setCacheDataset(boolean) is set true
      java.lang.String getAttributeValue(java.lang.String fullAttributeKey)
      The full attribute key is: @ e.g.
      DataNode getData(GroupNode group, java.lang.String name) 
      DataNode getData(java.lang.String path)
      Get data node with given path
      ILazyDataset getDataset(java.lang.String path)
      Read an ILazyDataset
      java.lang.String getFilePath() 
      GroupNode getGroup(GroupNode group, java.lang.String name, java.lang.String nxClass, boolean createPathIfNecessary)
      Get group in group with given name and create path if necessary
      GroupNode getGroup(java.lang.String augmentedPath, boolean createPathIfNecessary)
      Get/Create a group node.
      Node getNode(java.lang.String augmentedPath)
      Get any node of any type.
      java.lang.String getPath(Node node)
      Path of node
      java.lang.String getRoot()
      Root node path
      Tree getTree()
      Get the complete tree of data.
      int hashCode() 
      boolean isPathValid(java.lang.String path)
      Checks if a path within the file exists
      void link(java.lang.String source, java.lang.String destination)
      Link source to a destination.
      void linkExternal(java.net.URI source, java.lang.String destination, boolean isGroup)
      Link source in another file to a destination.
      static NxsFile open(java.lang.String path)
      Open an existing Nexus file to modify
      static NxsFile reference(java.lang.String path)
      Open an existing file read only
      void removeNode(GroupNode group, java.lang.String name)
      Remove node from given group.
      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
      void setDebug(boolean debug)
      Print more debuggined
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • create

        public static NxsFile create(java.lang.String path)
                              throws NexusException,
                                     java.io.IOException
        Create a new H5 file (overwriting any existing one)
        Parameters:
        path -
        Returns:
        Nexus formatted H5 file
        Throws:
        NexusException
        java.io.IOException
      • create

        public static NxsFile create(java.lang.String path,
                                     boolean enableSWMR)
                              throws NexusException,
                                     java.io.IOException
        Create a new Nexus file (overwriting any existing one)
        Parameters:
        path -
        enableSWMR -
        Returns:
        Nexus file
        Throws:
        NexusException
        java.io.IOException
      • open

        public static NxsFile open(java.lang.String path)
                            throws NexusException
        Open an existing Nexus file to modify
        Parameters:
        path -
        Returns:
        Nexus file
        Throws:
        NexusException
      • reference

        public static NxsFile reference(java.lang.String path)
                                 throws NexusException
        Open an existing file read only
        Parameters:
        path -
        Returns:
        Nexus file
        Throws:
        NexusException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getFilePath

        public java.lang.String getFilePath()
        Returns:
        path to file
      • setDebug

        public void setDebug(boolean debug)
        Print more debuggined
        Parameters:
        debug -
      • getPath

        public java.lang.String getPath(Node node)
        Path of node
        Parameters:
        node -
        Returns:
        path
      • getRoot

        public java.lang.String getRoot()
        Root node path
        Returns:
        root
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getGroup

        public GroupNode getGroup(java.lang.String augmentedPath,
                                  boolean createPathIfNecessary)
                           throws NexusException
        Get/Create a group node.
        Parameters:
        augmentedPath -
        createPathIfNecessary -
        Returns:
        Throws:
        NexusException
      • getNode

        public Node getNode(java.lang.String augmentedPath)
                     throws NexusException
        Get any node of any type.
        Parameters:
        augmentedPath -
        Returns:
        Throws:
        NexusException
      • getGroup

        public GroupNode getGroup(GroupNode group,
                                  java.lang.String name,
                                  java.lang.String nxClass,
                                  boolean createPathIfNecessary)
                           throws NexusException
        Get group in group with given name and create path if necessary
        Parameters:
        group -
        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

        public DataNode getData(java.lang.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

        public DataNode getData(GroupNode group,
                                java.lang.String name)
                         throws NexusException
        Throws:
        NexusException
      • createData

        public DataNode createData(java.lang.String path,
                                   ILazyWriteableDataset data,
                                   int compression,
                                   boolean createPathIfNecessary)
                            throws NexusException
        Get data node in group with given name
        Parameters:
        group -
        name -
        Returns:
        node or null if data does not exist in group
        Throws:
        NexusException
      • createData

        public DataNode createData(java.lang.String path,
                                   java.lang.String name,
                                   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

        public DataNode createData(java.lang.String path,
                                   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

        public DataNode createData(java.lang.String path,
                                   java.lang.String name,
                                   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

        public DataNode createData(GroupNode group,
                                   ILazyWriteableDataset data,
                                   int compression)
                            throws NexusException
        Create data node in given group
        Parameters:
        group -
        data -
        compression -
        Returns:
        node
        Throws:
        NexusException - when node already exists
      • createData

        public DataNode createData(GroupNode group,
                                   java.lang.String name,
                                   ILazyWriteableDataset data,
                                   int compression)
                            throws NexusException
        Create data node with given name in given group
        Parameters:
        group - parent group
        data - dataset
        compression -
        Returns:
        node
        Throws:
        NexusException - when node already exists
      • createData

        public DataNode createData(GroupNode group,
                                   ILazyWriteableDataset data)
                            throws NexusException
        Create data node in given group
        Parameters:
        group - parent group
        data - dataset
        Returns:
        node
        Throws:
        NexusException - when node already exists
      • createData

        public DataNode createData(GroupNode group,
                                   java.lang.String name,
                                   ILazyWriteableDataset data)
                            throws NexusException
        Create data node with given name in given group
        Parameters:
        group - parent group
        name - name within group
        data - dataset
        Returns:
        node
        Throws:
        NexusException - when node already exists
      • createData

        public DataNode createData(java.lang.String path,
                                   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

        public DataNode createData(java.lang.String path,
                                   java.lang.String name,
                                   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

        public DataNode createData(GroupNode group,
                                   IDataset data)
                            throws NexusException
        Create data node in given group
        Parameters:
        group - parent group
        data - dataset
        Returns:
        node
        Throws:
        NexusException - when node already exists
      • createData

        public DataNode createData(GroupNode group,
                                   java.lang.String name,
                                   IDataset data)
                            throws NexusException
        Create data node with given name in given group
        Parameters:
        group - parent group
        name - name within group
        data - dataset
        Returns:
        Throws:
        NexusException
      • addNode

        public void addNode(GroupNode group,
                            java.lang.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 -
        name -
        node -
        Throws:
        NexusException - if node already exists in group with name
      • addNode

        public void addNode(java.lang.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
      • removeNode

        public void removeNode(GroupNode group,
                               java.lang.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
        name - name of node in parent group
        Throws:
        NexusException
      • createAttribute

        public Attribute createAttribute(IDataset attr)
        Create attribute
        Parameters:
        attr -
        Returns:
        attribute
      • addAttribute

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

        public void addAttribute(Node node,
                                 Attribute... attribute)
                          throws NexusException
        Add (and write) attribute(s) to given node
        Parameters:
        node -
        attribute -
        Throws:
        NexusException
      • getAttributeValue

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

        public void link(java.lang.String source,
                         java.lang.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

        public void linkExternal(java.net.URI source,
                                 java.lang.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
      • activateSwmrMode

        public 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
      • flush

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

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

        public void close()
                   throws NexusException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        NexusException
      • isPathValid

        public boolean isPathValid(java.lang.String path)
        Checks if a path within the file exists
        Parameters:
        path -
        Returns:
        true if path exists
      • setCacheDataset

        public 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 -
      • getTree

        public Tree getTree()
                     throws NexusException
        Get the complete tree of data.
        Returns:
        tree or null if none exists.
        Throws:
        NexusException
      • getDataset

        public ILazyDataset getDataset(java.lang.String path)
                                throws NexusException
        Read an ILazyDataset
        Parameters:
        path - to read
        Returns:
        lazy dataset which does not use local memory.
        Throws:
        NexusException - - if cannot read.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy