public class NexusFile extends java.lang.Object implements NeXusFileInterface
Modifier and Type | Field and Description |
---|---|
protected int |
handle
This is the handle to the NeXus file handle.
|
protected static int |
MAXNAMELEN
Maximum name length, must be VGNAMELENMAX in hlimits.h
|
static int |
NX_BINARY |
static int |
NX_BOOLEAN |
static int |
NX_CHAR |
static int |
NX_COMP_HUF |
static int |
NX_COMP_LZW |
static int |
NX_COMP_LZW_LVL0 |
static int |
NX_COMP_LZW_LVL1 |
static int |
NX_COMP_LZW_LVL2 |
static int |
NX_COMP_LZW_LVL3 |
static int |
NX_COMP_LZW_LVL4 |
static int |
NX_COMP_LZW_LVL5 |
static int |
NX_COMP_LZW_LVL6 |
static int |
NX_COMP_LZW_LVL7 |
static int |
NX_COMP_LZW_LVL8 |
static int |
NX_COMP_LZW_LVL9 |
static int |
NX_COMP_NONE
constants for compression schemes
|
static int |
NX_COMP_RLE |
static int |
NX_FLOAT32
constants for number types.
|
static int |
NX_FLOAT64 |
static int |
NX_INT16 |
static int |
NX_INT32 |
static int |
NX_INT64 |
static int |
NX_INT8 |
static int |
NX_UINT16 |
static int |
NX_UINT32 |
static int |
NX_UINT64 |
static int |
NX_UINT8 |
static int |
NX_UNLIMITED
constant denoting an unlimited dimension.
|
static int |
NXACC_CREATE |
static int |
NXACC_CREATE4 |
static int |
NXACC_CREATE5 |
static int |
NXACC_CREATEXML |
static int |
NXACC_NOSTRIP |
static int |
NXACC_RDWR |
static int |
NXACC_READ
possible access codes, @see #NexusFile.
|
Constructor and Description |
---|
NexusFile(java.lang.String filename,
int access)
constructs a new NexusFile Object.
|
Modifier and Type | Method and Description |
---|---|
java.util.Hashtable |
attrdir()
attrdir returns the attributes of the currently open dataset or
the file global attributes if no dataset is open.
|
void |
close()
close the NeXus file.
|
protected void |
close(int handle) |
void |
closedata()
closedata closes an opened dataset.
|
void |
closegroup()
closegroup closes access to the current group and steps down one
step in group hierarchy.
|
void |
compmakedata(java.lang.String name,
int type,
int rank,
int[] dim,
int compression_type,
int[] iChunk)
compmakedata creates a new dataset with the specified characteristics
in the current group.
|
void |
compmakedata(java.lang.String name,
int type,
int rank,
long[] dim,
int compression_type,
long[] iChunk)
compmakedata creates a new dataset with the specified characteristics
in the current group.
|
void |
compress(int compression_type)
causes the currently open dataset to be compressed on file.
|
void |
debugstop()
debugstop is a debugging helper function which goes into an
endless loop in the dynamic link library.
|
void |
finalize()
removes all NeXus file data structures and closes the file.
|
void |
flush()
flushes all pending data to disk.
|
void |
getattr(java.lang.String name,
java.lang.Object array,
int[] args)
getattr retrieves the data associated with the attribute
name.
|
void |
getdata(java.lang.Object array)
getdata reads the data from an previously openend dataset into
array.
|
NXlink |
getdataID()
getdataID gets the data necessary for linking the current dataset
somewhere else.
|
NXlink |
getgroupID()
getgroupID gets the data necessary for linking the current vGroup
somewhere else.
|
void |
getinfo(int[] iDim,
int[] args)
getinfo retrieves information about a previously opened dataset.
|
void |
getinfo(long[] iDim,
int[] args)
getinfo retrieves information about a previously opened dataset.
|
java.lang.String |
getpath()
return the current path into the NeXus file in the
form of a Unix path string.
|
void |
getslab(int[] start,
int[] size,
java.lang.Object array)
getslab reads a subset of a large dataset into array.
|
void |
getslab(long[] start,
long[] size,
java.lang.Object array)
getslab reads a subset of a large dataset into array.
|
java.util.Hashtable |
groupdir()
groupdir will retrieve the content of the currently open vGroup.
|
protected int |
init(java.lang.String filename,
int access) |
protected void |
initattrdir(int handle) |
protected void |
initgroupdir(int handle) |
java.lang.String |
inquirefile()
inquirefile inquires which file we are currently in.
|
java.lang.String |
isexternaldataset(java.lang.String name)
nxisexternaldataset if the named dataset is is linked externally
|
java.lang.String |
isexternalgroup(java.lang.String name,
java.lang.String nxclass)
nxisexternalgroup test the group name, nxclass if it is linked externally
|
void |
linkexternal(java.lang.String name,
java.lang.String nxclass,
java.lang.String nxurl)
linkexternal links group name, nxclass to the URL nxurl
|
void |
linkexternaldataset(java.lang.String name,
java.lang.String nxurl)
linkexternaldataset links dataset name to the URL nxurl
|
void |
makedata(java.lang.String name,
int type,
int rank,
int[] dim)
makedata creates a new dataset with the specified characteristics
in the current group.
|
void |
makedata(java.lang.String name,
int type,
int rank,
long[] dim)
makedata creates a new dataset with the specified characteristics
in the current group.
|
void |
makegroup(java.lang.String name,
java.lang.String nxclass)
makegroup creates a new group below the current group within
the NeXus file hierarchy.
|
void |
makelink(NXlink target)
makelink links the object described by target into the current
vGroup.
|
void |
makenamedlink(java.lang.String name,
NXlink target)
makenamedlink links the object described by target into the current
vGroup.
|
protected int |
nextattr(int handle,
java.lang.String[] names,
int[] args) |
protected int |
nextentry(int handle,
java.lang.String[] names) |
protected void |
nxclosedata(int handle) |
protected void |
nxclosegroup(int handle) |
protected void |
nxcompress(int handle,
int compression_type) |
protected int |
nxflush(int handle) |
protected void |
nxgetattr(int handle,
java.lang.String name,
byte[] bdata,
int[] args) |
protected void |
nxgetdata(int handle,
byte[] bdata) |
protected void |
nxgetdataid(int handle,
NXlink link) |
protected void |
nxgetgroupid(int handle,
NXlink link) |
protected void |
nxgetinfo(int handle,
int[] iDim,
int[] args) |
protected void |
nxgetinfo64(int handle,
long[] iDim,
int[] args) |
protected java.lang.String |
nxgetpath(int handle) |
protected void |
nxgetslab(int handle,
int[] Start,
int[] size,
byte[] bdata) |
protected void |
nxgetslab64(int handle,
long[] Start,
long[] size,
byte[] bdata) |
protected void |
nxinquirefile(int handle,
java.lang.String[] names) |
protected int |
nxisexternaldataset(int handle,
java.lang.String name,
java.lang.String[] nxurl) |
protected int |
nxisexternalgroup(int handle,
java.lang.String name,
java.lang.String nxclass,
java.lang.String[] nxurl) |
protected void |
nxlinkexternal(int handle,
java.lang.String name,
java.lang.String nxclass,
java.lang.String nxurl) |
protected void |
nxlinkexternaldataset(int handle,
java.lang.String name,
java.lang.String nxurl) |
protected void |
nxmakecompdata(int handle,
java.lang.String name,
int type,
int rank,
int[] dim,
int iCompress,
int[] iChunk) |
protected void |
nxmakecompdata64(int handle,
java.lang.String name,
int type,
int rank,
long[] dim,
int iCompress,
long[] iChunk) |
protected void |
nxmakedata(int handle,
java.lang.String name,
int type,
int rank,
int[] dim) |
protected void |
nxmakedata64(int handle,
java.lang.String name,
int type,
int rank,
long[] dim) |
protected void |
nxmakegroup(int handle,
java.lang.String name,
java.lang.String nxclass) |
protected void |
nxmakelink(int handle,
NXlink target) |
protected void |
nxmakenamedlink(int handle,
java.lang.String name,
NXlink target) |
protected void |
nxopendata(int handle,
java.lang.String name) |
protected void |
nxopengroup(int handle,
java.lang.String name,
java.lang.String nxclass) |
protected void |
nxopengrouppath(int handle,
java.lang.String path) |
protected void |
nxopenpath(int handle,
java.lang.String path) |
protected void |
nxopensourcepath(int handle) |
protected void |
nxputattr(int handle,
java.lang.String name,
byte[] array,
int type) |
protected void |
nxputdata(int handle,
byte[] array) |
protected void |
nxputslab(int handle,
byte[] array,
int[] start,
int[] size) |
protected void |
nxputslab64(int handle,
byte[] array,
long[] start,
long[] size) |
protected void |
nxsetnumberformat(int handle,
int type,
java.lang.String format) |
void |
opendata(java.lang.String name)
opendata opens an existing dataset for access.
|
void |
opengroup(java.lang.String name,
java.lang.String nxclass)
opengroup opens the group name with class nxclass.
|
void |
opengrouppath(java.lang.String path)
opengrouppath opens groups and datsets accroding to the path string
given.
|
void |
openpath(java.lang.String path)
openpath opens groups and datsets accroding to the path string
given.
|
void |
opensourcepath()
opensourcepath opens the group from which the current item was linked
Returns an error if the current item is not linked.
|
void |
putattr(java.lang.String name,
java.lang.Object array,
int iType)
putattr adds a named attribute to a previously opened dataset or
a global attribute if no dataset is open.
|
void |
putdata(java.lang.Object array)
putdata writes the data from array into a previously opened
dataset.
|
void |
putslab(java.lang.Object array,
int[] start,
int[] size)
putslab writes a subset of a larger dataset to a previously opened
dataset.
|
void |
putslab(java.lang.Object array,
long[] start,
long[] size)
putslab writes a subset of a larger dataset to a previously opened
dataset.
|
void |
setnumberformat(int type,
java.lang.String format)
setnumberformat sets the number format for printing number when
using the XML-NeXus format.
|
public static final int NXACC_READ
public static final int NXACC_RDWR
public static final int NXACC_CREATE
public static final int NXACC_CREATE4
public static final int NXACC_CREATE5
public static final int NXACC_CREATEXML
public static final int NXACC_NOSTRIP
public static final int NX_UNLIMITED
public static final int NX_FLOAT32
public static final int NX_FLOAT64
public static final int NX_INT8
public static final int NX_BINARY
public static final int NX_UINT8
public static final int NX_BOOLEAN
public static final int NX_INT16
public static final int NX_UINT16
public static final int NX_INT32
public static final int NX_UINT32
public static final int NX_INT64
public static final int NX_UINT64
public static final int NX_CHAR
public static final int NX_COMP_NONE
public static final int NX_COMP_LZW
public static final int NX_COMP_RLE
public static final int NX_COMP_HUF
public static final int NX_COMP_LZW_LVL0
public static final int NX_COMP_LZW_LVL1
public static final int NX_COMP_LZW_LVL2
public static final int NX_COMP_LZW_LVL3
public static final int NX_COMP_LZW_LVL4
public static final int NX_COMP_LZW_LVL5
public static final int NX_COMP_LZW_LVL6
public static final int NX_COMP_LZW_LVL7
public static final int NX_COMP_LZW_LVL8
public static final int NX_COMP_LZW_LVL9
protected static final int MAXNAMELEN
protected int handle
public NexusFile(java.lang.String filename, int access) throws NexusException
filename
- The name of the NeXus file to access.access
- The access mode for the file. Can only be one
of the predefined NeXus access code NXACC.... These are:
NexusException
- when the file could not be found or
an HDF error occurred.protected int init(java.lang.String filename, int access)
protected void close(int handle)
protected int nxflush(int handle)
public void flush() throws NexusException
flush
in interface NeXusFileInterface
NexusException
- if an HDF error occurs.public void close() throws NexusException
close
in interface NeXusFileInterface
NexusException
public void finalize() throws java.lang.Throwable
finalize
in interface NeXusFileInterface
finalize
in class java.lang.Object
java.lang.Throwable
- because it is required by the definition of
finalize.protected void nxmakegroup(int handle, java.lang.String name, java.lang.String nxclass)
protected void nxopengroup(int handle, java.lang.String name, java.lang.String nxclass)
protected void nxopenpath(int handle, java.lang.String path)
protected void nxopengrouppath(int handle, java.lang.String path)
protected void nxclosegroup(int handle)
protected java.lang.String nxgetpath(int handle)
public void makegroup(java.lang.String name, java.lang.String nxclass) throws NexusException
NeXusFileInterface
makegroup
in interface NeXusFileInterface
name
- The name of the group to create.nxclass
- The classname of the group.NexusException
- if an error occurs during this operation.public void opengroup(java.lang.String name, java.lang.String nxclass) throws NexusException
NeXusFileInterface
opengroup
in interface NeXusFileInterface
name
- the name of the group to open.nxclass
- the classname of the group to open.NexusException
- when something goes wrong.public void openpath(java.lang.String path) throws NexusException
NeXusFileInterface
openpath
in interface NeXusFileInterface
path
- The path stringNexusException
- when something goes wrong.public void opengrouppath(java.lang.String path) throws NexusException
NeXusFileInterface
opengrouppath
in interface NeXusFileInterface
path
- The path stringNexusException
- when something goes wrong.public java.lang.String getpath() throws NexusException
NeXusFileInterface
getpath
in interface NeXusFileInterface
NexusException
public void closegroup() throws NexusException
NeXusFileInterface
closegroup
in interface NeXusFileInterface
NexusException
- when an HDF error occurs during this
operation.protected void nxmakedata(int handle, java.lang.String name, int type, int rank, int[] dim)
protected void nxmakedata64(int handle, java.lang.String name, int type, int rank, long[] dim)
protected void nxmakecompdata(int handle, java.lang.String name, int type, int rank, int[] dim, int iCompress, int[] iChunk)
protected void nxmakecompdata64(int handle, java.lang.String name, int type, int rank, long[] dim, int iCompress, long[] iChunk)
protected void nxopendata(int handle, java.lang.String name)
protected void nxclosedata(int handle)
protected void nxcompress(int handle, int compression_type)
public void compmakedata(java.lang.String name, int type, int rank, int[] dim, int compression_type, int[] iChunk) throws NexusException
NeXusFileInterface
compmakedata
in interface NeXusFileInterface
name
- The name of the dataset.type
- The number type of the dataset. Usually a constant from
a selection of values.rank
- The rank or number of dimensions of the dataset.dim
- An array containing the length of each dimension. dim must
have at least rank entries. Dimension passed as -1 denote an
unlimited dimension.compression_type
- determines the compression type.iChunk
- With HDF-5, slabs can be written to compressed data
sets. The size of these slabs is specified through the chunk array.
This must have the rank values for the size of the chunk to
be written in each dimension.NexusException
- when the dataset could not be created.public void compmakedata(java.lang.String name, int type, int rank, long[] dim, int compression_type, long[] iChunk) throws NexusException
NeXusFileInterface
compmakedata
in interface NeXusFileInterface
name
- The name of the dataset.type
- The number type of the dataset. Usually a constant from
a selection of values.rank
- The rank or number of dimensions of the dataset.dim
- An array containing the length of each dimension. dim must
have at least rank entries. Dimension passed as -1 denote an
unlimited dimension.compression_type
- determines the compression type.iChunk
- With HDF-5, slabs can be written to compressed data
sets. The size of these slabs is specified through the chunk array.
This must have the rank values for the size of the chunk to
be written in each dimension.NexusException
- when the dataset could not be created.public void makedata(java.lang.String name, int type, int rank, int[] dim) throws NexusException
NeXusFileInterface
makedata
in interface NeXusFileInterface
name
- The name of the dataset.type
- The number type of the dataset. Usually a constant from
a selection of values.rank
- The rank or number of dimensions of the dataset.dim
- An array containing the length of each dimension. dim must
have at least rank entries. Dimension passed as -1 denote an
unlimited dimension.NexusException
- when the dataset could not be created.public void makedata(java.lang.String name, int type, int rank, long[] dim) throws NexusException
NeXusFileInterface
makedata
in interface NeXusFileInterface
name
- The name of the dataset.type
- The number type of the dataset. Usually a constant from
a selection of values.rank
- The rank or number of dimensions of the dataset.dim
- An array containing the length of each dimension. dim must
have at least rank entries. Dimension passed as -1 denote an
unlimited dimension.NexusException
- when the dataset could not be created.public void opendata(java.lang.String name) throws NexusException
NeXusFileInterface
opendata
in interface NeXusFileInterface
name
- The name of the dataset to open.NexusException
- when the dataset does not exist or
something else is wrong.public void closedata() throws NexusException
NeXusFileInterface
closedata
in interface NeXusFileInterface
NexusException
- when an HDF error occurrs.public void compress(int compression_type) throws NexusException
NeXusFileInterface
compress
in interface NeXusFileInterface
compression_type
- determines the type of compression
to use.NexusException
- when no dataset is open or an HDF error
occurs.protected void nxgetdata(int handle, byte[] bdata)
protected void nxgetslab(int handle, int[] Start, int[] size, byte[] bdata)
protected void nxgetslab64(int handle, long[] Start, long[] size, byte[] bdata)
protected void nxgetattr(int handle, java.lang.String name, byte[] bdata, int[] args)
public void getdata(java.lang.Object array) throws NexusException
NeXusFileInterface
getdata
in interface NeXusFileInterface
array
- An n-dimensional array of the appropriate number
type for the dataset. Make sure to have the right type and size
here.NexusException
- when either an HDF error occurs or
no dataset is open or array is not of the right type to hold
the data.public void getslab(int[] start, int[] size, java.lang.Object array) throws NexusException
NeXusFileInterface
getslab
in interface NeXusFileInterface
start
- An array of dimension rank which contains the start
position in the dataset from where to start reading.size
- An array of dimension rank which contains the size
in each dimension of the data subset to read.array
- An array for holding the returned data values.NexusException
- when either an HDF error occurs or
no dataset is open or array is not of the right type to hold
the data.public void getslab(long[] start, long[] size, java.lang.Object array) throws NexusException
NeXusFileInterface
getslab
in interface NeXusFileInterface
start
- An array of dimension rank which contains the start
position in the dataset from where to start reading.size
- An array of dimension rank which contains the size
in each dimension of the data subset to read.array
- An array for holding the returned data values.NexusException
- when either an HDF error occurs or
no dataset is open or array is not of the right type to hold
the data.public void getattr(java.lang.String name, java.lang.Object array, int[] args) throws NexusException
NeXusFileInterface
getattr
in interface NeXusFileInterface
name
- The name of the attribute.array
- an array with sufficient space for holding the attribute
data.args
- An integer array holding the number of data elements
in data as args[0], and the type as args[1]. Both values will be
updated while reading.NexusException
- when either an HDF error occurs or
the attribute could not be found.protected void nxputdata(int handle, byte[] array)
protected void nxputslab(int handle, byte[] array, int[] start, int[] size)
protected void nxputslab64(int handle, byte[] array, long[] start, long[] size)
protected void nxputattr(int handle, java.lang.String name, byte[] array, int type)
public void putdata(java.lang.Object array) throws NexusException
NeXusFileInterface
putdata
in interface NeXusFileInterface
array
- The data to write.NexusException
- when an HDF error occurs.public void putslab(java.lang.Object array, int[] start, int[] size) throws NexusException
NeXusFileInterface
putslab
in interface NeXusFileInterface
array
- The data to write.start
- An integer array of dimension rank which holds the
startcoordinates of the data subset in the larger dataset.size
- An integer array of dimension rank whidh holds the
size in each dimension of the data subset to write.NexusException
- when an HDF error occurs.public void putslab(java.lang.Object array, long[] start, long[] size) throws NexusException
NeXusFileInterface
putslab
in interface NeXusFileInterface
array
- The data to write.start
- An integer array of dimension rank which holds the
startcoordinates of the data subset in the larger dataset.size
- An integer array of dimension rank whidh holds the
size in each dimension of the data subset to write.NexusException
- when an HDF error occurs.public void putattr(java.lang.String name, java.lang.Object array, int iType) throws NexusException
NeXusFileInterface
putattr
in interface NeXusFileInterface
name
- The name of the attribute.array
- The data of the attribute.iType
- The number type of the attribute.NexusException
- if an HDF error occurs.protected void nxgetinfo(int handle, int[] iDim, int[] args)
protected void nxgetinfo64(int handle, long[] iDim, int[] args)
protected void nxsetnumberformat(int handle, int type, java.lang.String format)
protected int nextentry(int handle, java.lang.String[] names)
protected int nextattr(int handle, java.lang.String[] names, int[] args)
protected void initattrdir(int handle)
protected void initgroupdir(int handle)
public void setnumberformat(int type, java.lang.String format) throws NexusException
NeXusFileInterface
setnumberformat
in interface NeXusFileInterface
type
- The NeXus type to set the format for.format
- The new format to use.NexusException
public void getinfo(int[] iDim, int[] args) throws NexusException
NeXusFileInterface
getinfo
in interface NeXusFileInterface
iDim
- An array which will be filled with the size of
the dataset in each dimension.args
- An integer array which will hold more information about
the dataset after return. The fields: args[0] is the rank, args[1] is
the number type.NexusException
- when an HDF error occurs.public void getinfo(long[] iDim, int[] args) throws NexusException
NeXusFileInterface
getinfo
in interface NeXusFileInterface
iDim
- An array which will be filled with the size of
the dataset in each dimension.args
- An integer array which will hold more information about
the dataset after return. The fields: args[0] is the rank, args[1] is
the number type.NexusException
- when an HDF error occurs.public java.util.Hashtable groupdir() throws NexusException
NeXusFileInterface
groupdir
in interface NeXusFileInterface
NexusException
- if an HDF error occurspublic java.util.Hashtable attrdir() throws NexusException
NeXusFileInterface
attrdir
in interface NeXusFileInterface
NexusException
- when an HDF error occurs.protected void nxgetgroupid(int handle, NXlink link)
protected void nxgetdataid(int handle, NXlink link)
protected void nxmakelink(int handle, NXlink target)
protected void nxmakenamedlink(int handle, java.lang.String name, NXlink target)
protected void nxopensourcepath(int handle)
public NXlink getgroupID() throws NexusException
NeXusFileInterface
getgroupID
in interface NeXusFileInterface
NexusException
- if an HDF error occurs.public NXlink getdataID() throws NexusException
NeXusFileInterface
getdataID
in interface NeXusFileInterface
NexusException
- if an HDF error occurs.public void makelink(NXlink target) throws NexusException
NeXusFileInterface
makelink
in interface NeXusFileInterface
target
- The Object to link into the current group.NexusException
- if an error occurs.public void makenamedlink(java.lang.String name, NXlink target) throws NexusException
NeXusFileInterface
makenamedlink
in interface NeXusFileInterface
name
- The name of this object in the current grouptarget
- The Object to link into the current group.NexusException
- if an error occurs.public void opensourcepath() throws NexusException
NeXusFileInterface
opensourcepath
in interface NeXusFileInterface
NexusException
- if an error occurs.protected void nxinquirefile(int handle, java.lang.String[] names)
protected void nxlinkexternal(int handle, java.lang.String name, java.lang.String nxclass, java.lang.String nxurl)
protected void nxlinkexternaldataset(int handle, java.lang.String name, java.lang.String nxurl)
protected int nxisexternalgroup(int handle, java.lang.String name, java.lang.String nxclass, java.lang.String[] nxurl)
protected int nxisexternaldataset(int handle, java.lang.String name, java.lang.String[] nxurl)
public java.lang.String inquirefile() throws NexusException
NeXusFileInterface
inquirefile
in interface NeXusFileInterface
NexusException
- when things are wrongpublic void linkexternal(java.lang.String name, java.lang.String nxclass, java.lang.String nxurl) throws NexusException
NeXusFileInterface
linkexternal
in interface NeXusFileInterface
name
- The name of the vgroup to link tonxclass
- The class name of the linked vgroupnxurl
- The URL to the linked external fileNexusException
- if things are wrongpublic void linkexternaldataset(java.lang.String name, java.lang.String nxurl) throws NexusException
NeXusFileInterface
linkexternaldataset
in interface NeXusFileInterface
name
- The name of the dataset to link tonxurl
- The URL to the linked external fileNexusException
- if things are wrongpublic java.lang.String isexternalgroup(java.lang.String name, java.lang.String nxclass) throws NexusException
NeXusFileInterface
isexternalgroup
in interface NeXusFileInterface
name
- of the group to testnxclass
- class of the group to testNexusException
- if things are wrongpublic java.lang.String isexternaldataset(java.lang.String name) throws NexusException
NeXusFileInterface
isexternaldataset
in interface NeXusFileInterface
name
- of the dataset to testNexusException
- if things are wrongpublic void debugstop()