Package org.eclipse.dawnsci.nexus
Interface NexusFile
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
NexusFileHDF5
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidActivates SWMR mode.voidaddAttribute(String path, Attribute... attribute) Add (and write) attribute(s) to given pathvoidaddAttribute(Node node, Attribute... attribute) Add (and write) attribute(s) to given nodevoidAdd node to given path.voidAdd node to group.voidclose()Close filevoidCreate file and open to writecreateAttribute(org.eclipse.january.dataset.IDataset attr) Create attributecreateData(String path, String name, org.eclipse.january.dataset.IDataset data, boolean createPathIfNecessary) Create data node with given path to its group and create path if necessarycreateData(String path, String name, org.eclipse.january.dataset.ILazyWriteableDataset data, boolean createPathIfNecessary) Create data node with given name and path to its group and create path if necessary.createData(String path, String name, org.eclipse.january.dataset.ILazyWriteableDataset data, int compression, boolean createPathIfNecessary) Create data node with given name and path to its group and create path if necessarycreateData(String path, org.eclipse.january.dataset.IDataset data, boolean createPathIfNecessary) Create data node with given path to its group and create path if necessarycreateData(String path, org.eclipse.january.dataset.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.createData(String path, org.eclipse.january.dataset.ILazyWriteableDataset data, int compression, boolean createPathIfNecessary) Create data node with given path to its group and create path if necessarycreateData(GroupNode group, String name, org.eclipse.january.dataset.IDataset data) Create data node with given name in given groupcreateData(GroupNode group, String name, org.eclipse.january.dataset.ILazyWriteableDataset data) Create data node with given name in given groupcreateData(GroupNode group, String name, org.eclipse.january.dataset.ILazyWriteableDataset data, int compression) Create data node with given name in given groupcreateData(GroupNode group, org.eclipse.january.dataset.IDataset data) Create data node in given groupcreateData(GroupNode group, org.eclipse.january.dataset.ILazyWriteableDataset data) Create data node in given groupcreateData(GroupNode group, org.eclipse.january.dataset.ILazyWriteableDataset data, int compression) Create data node in given groupintflush()Flush data to filesystemvoidFlush datasets cached whensetCacheDataset(boolean)is set truegetAttributeValue(String path) The full attribute key is:@ e.g. Get data node with given pathGet data node in group with given nameReturns the file path of thisNexusFileGet group with given path and create path if necessaryGet group in group with given name and create path if necessaryGet Node with given path.Get path of node from internal treegetRoot()Get the path of root node from internal treebooleanisPathValid(String path) Checks if a path within the file existsvoidLink source to a destination.voidlinkExternal(URI source, String destination, boolean isGroup) Link source in another file to a destination.voidOpen file to only readvoidopenToWrite(boolean createIfNecessary) Open file to writevoidremoveNode(String path, String name) Remove node from given path.voidremoveNode(GroupNode group, String name) Remove node from given group.voidsetCacheDataset(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, callflushAllCachedDatasets()to flushvoidsetDebug(boolean debug) Set to instrument some method calls via logging at the DEBUG levelvoidsetWritesAsync(boolean async) Set to writes to be performed asynchronously for data nodes created after calling this
-
Field Details
-
NXCLASS
Deprecated.- See Also:
-
NXCLASS_SEPARATOR
- See Also:
-
COMPRESSION_NONE
static final int COMPRESSION_NONENo compression- See Also:
-
COMPRESSION_LZW_L1
static final int COMPRESSION_LZW_L1Compression using LZW level 1- See Also:
-
NX_URL_SCHEME
Scheme for NeXus URI used to refer to external files- See Also:
-
-
Method Details
-
getFilePath
String getFilePath()Returns the file path of thisNexusFile- Returns:
- file path
-
openToRead
Open file to only read- Throws:
IOExceptionNexusException
-
openToWrite
Open file to write- Parameters:
createIfNecessary- if true, then create file if it does not exist- Throws:
IOExceptionNexusException
-
createAndOpenToWrite
Create file and open to write- Throws:
IOExceptionNexusException
-
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, callflushAllCachedDatasets()to flush- Parameters:
cacheDataset-
-
flushAllCachedDatasets
void flushAllCachedDatasets()Flush datasets cached whensetCacheDataset(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
Get path of node from internal tree- Parameters:
node- (can be null for root)- Returns:
- (depth-first) path of node
-
getGroup
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
Get data node with given path- Parameters:
path-- Returns:
- node or null if data does not exist at specified path
- Throws:
NexusException
-
getData
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
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
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
Remove node from given path.Note, this will fail if the file is in SWMR node
- Parameters:
path- path to parent group of nodename- name of node in parent group- Throws:
NexusException
-
removeNode
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 groupdata-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 groupname- name within parent groupdata-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 groupdata- datacompression-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 groupname- name within parent groupdata- datasetcompression-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 groupdata- datasetcreatePathIfNecessary-- 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 groupname- name within parent groupdata- datasetcreatePathIfNecessary-- 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 groupdata- 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- datasetcompression-- 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 groupdata- dataset- Returns:
- Throws:
NexusException
-
createAttribute
Create attribute- Parameters:
attr-- Returns:
- attribute
-
getAttributeValue
The full attribute key is:@ e.g. /entry1/data@napimount - Parameters:
fullAttributeKey-- Returns:
- Throws:
NexusException
-
addAttribute
Add (and write) attribute(s) to given node- Parameters:
node- (can be null for root)attribute-- Throws:
NexusException
-
addAttribute
Add (and write) attribute(s) to given path- Parameters:
path-attribute-- Throws:
NexusException
-
link
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
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
Flush data to filesystem- Returns:
- the nexus int code for the flush or -1 if unsucessfull.
- Throws:
NexusException
-
close
Close file- Specified by:
closein interfaceAutoCloseable- Throws:
NexusException
-
isPathValid
Checks if a path within the file exists- Parameters:
path-- Returns:
- true if path exists
-
activateSwmrMode
Activates SWMR mode. The file must have been created as with SWMR enabled.- Throws:
NexusException- if SWMR mode could not be activated
-
getNode
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
-
NexusConstants.NXCLASS