|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.File
ncsa.hdf.object.FileFormat
ncsa.hdf.object.h5.H5File
This class provides file level APIs. File access APIs include retrieving the file hierarchy, opening and closing file, and writing file content to disk.
Field Summary |
Fields inherited from class ncsa.hdf.object.FileFormat |
CREATE, fid, FILE_TYPE_HDF4, FILE_TYPE_HDF5, FILE_TYPE_JPEG, FILE_TYPE_PNG, FILE_TYPE_TIFF, READ, WRITE |
Fields inherited from class java.io.File |
pathSeparator, pathSeparatorChar, separator, separatorChar |
Constructor Summary | |
H5File()
Constructs an empty H5File with read-only access. |
|
H5File(java.lang.String pathname)
Constructs an H5File object of given file name with read-only access. |
|
H5File(java.lang.String pathname,
int access)
Constructs an H5File object with given file name and access flag. |
Method Summary | |
void |
close()
Closes access to the file resource. |
javax.swing.tree.TreeNode |
copy(HObject srcObj,
Group dstGroup)
Copy a data object to a group. |
void |
copyAttributes(HObject src,
HObject dst)
Copy attributes of the source object to the destination object. |
void |
copyAttributes(int src_id,
int dst_id)
Copy attributes of the source object to the destination object. |
FileFormat |
create(java.lang.String fileName)
Creates a new HDF5 file with given file name. |
Dataset |
createCompoundDS(java.lang.String name,
Group pgroup,
long[] dims,
java.lang.String[] memberNames,
Datatype[] memberDatatypes,
int[] memberSizes,
java.lang.Object data)
Create a new compound dataset in this file. |
Datatype |
createDatatype(int tclass,
int tsize,
int torder,
int tsign)
Create a new datatype based on this FileFormat. |
Datatype |
createDatatype(int tclass,
int tsize,
int torder,
int tsign,
java.lang.String name)
|
Group |
createGroup(java.lang.String name,
Group pgroup)
Create a new group with given group name and a parent in this file. |
Dataset |
createImage(java.lang.String name,
Group pgroup,
Datatype type,
long[] dims,
long[] maxdims,
long[] chunks,
int gzip,
int ncomp,
int intelace,
java.lang.Object data)
Create a new image at given parent group in this file. |
static void |
createImageAttributes(Dataset dataset,
int interlace)
Creates required atriubtes for HDF5 image. |
HObject |
createLink(Group parentGroup,
java.lang.String name,
HObject currentObj)
|
Dataset |
createScalarDS(java.lang.String name,
Group pgroup,
Datatype type,
long[] dims,
long[] maxdims,
long[] chunks,
int gzip,
java.lang.Object data)
Create a new dataset in this file. |
void |
delete(HObject obj)
Delete an object from the file. |
HObject |
get(java.lang.String path)
Get an individual HObject with a given path. |
static java.util.List |
getAttribute(int objID)
Returns a list of attriubtes for the given object location. |
java.lang.String |
getFilePath()
Returns the full path of the file: file path + file name. |
java.lang.String |
getLibversion()
Returns the version of the HDF5 library. |
javax.swing.tree.TreeNode |
getRootNode()
Returns the root node of the file. |
boolean |
isReadOnly()
Returns the true if the file is read-only, otherwise returns false. |
boolean |
isThisType(FileFormat fileformat)
Checks if the given file format is an HDF5 file. |
boolean |
isThisType(java.lang.String filename)
Checks if a given file is an HDF5 file. |
int |
open()
Opens access to the file resource and returns the file identifier. |
FileFormat |
open(java.lang.String pathname,
int access)
Creates an instance of an H5File with given file name and access flag. |
void |
reloadTree(Group g)
reload the sub-tree structure. |
static void |
updateReferenceDataset(H5File srcFile,
H5File newFile)
Update values of reference datasets. |
void |
writeAttribute(HObject obj,
Attribute attr,
boolean attrExisted)
Creates a new attribute and attached to the object if attribute does not exist. |
Methods inherited from class ncsa.hdf.object.FileFormat |
addFileExtension, addFileFormat, getFID, getFileExtensions, getFileFormat, getFileFormatKeys, getFileFormats, getHObject, getHObject, getInstance, getMaxMembers, getStartMembers, setMaxMembers, setStartMembers |
Methods inherited from class java.io.File |
canRead, canWrite, compareTo, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public H5File()
public H5File(java.lang.String pathname)
public H5File(java.lang.String pathname, int access)
pathname
- the full path name of the file.Method Detail |
public boolean isThisType(FileFormat fileformat)
isThisType
in class FileFormat
fileformat
- the fileformat to be checked.
public boolean isThisType(java.lang.String filename)
isThisType
in class FileFormat
filename
- the file to be checked.
public FileFormat open(java.lang.String pathname, int access) throws java.lang.Exception
open
in class FileFormat
pathname
- the full path name of the file.
java.lang.Exception
public int open() throws java.lang.Exception
FileFormat
open
in class FileFormat
java.lang.Exception
public void close() throws HDF5Exception
FileFormat
close
in class FileFormat
HDF5Exception
public javax.swing.tree.TreeNode getRootNode()
FileFormat
getRootNode
in class FileFormat
public java.lang.String getFilePath()
FileFormat
getFilePath
in class FileFormat
public boolean isReadOnly()
FileFormat
isReadOnly
in class FileFormat
public FileFormat create(java.lang.String fileName) throws java.lang.Exception
create
in class FileFormat
java.lang.Exception
public Group createGroup(java.lang.String name, Group pgroup) throws java.lang.Exception
FileFormat
createGroup
in class FileFormat
name
- the name fo the new group.pgroup
- the parent group.
java.lang.Exception
public Datatype createDatatype(int tclass, int tsize, int torder, int tsign) throws java.lang.Exception
FileFormat
For example, the following code creates an instance of H5Datatype.
FileFormat file = FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5); H5Datatype dtype = file.createDatatype(Datatype.CLASS_INTEGER, Datatype.NATIVE, Datatype.NATIVE, Datatype.NATIVE);
createDatatype
in class FileFormat
tclass
- the class of datatype, such as Integer, Floattsize
- the size of the datatype in bytes
java.lang.Exception
public Datatype createDatatype(int tclass, int tsize, int torder, int tsign, java.lang.String name) throws java.lang.Exception
createDatatype
in class FileFormat
java.lang.Exception
public HObject createLink(Group parentGroup, java.lang.String name, HObject currentObj) throws java.lang.Exception
createLink
in class FileFormat
java.lang.Exception
public Dataset createScalarDS(java.lang.String name, Group pgroup, Datatype type, long[] dims, long[] maxdims, long[] chunks, int gzip, java.lang.Object data) throws java.lang.Exception
FileFormat
String name = "2D integer"; Group pgroup = (Group)((DefaultMutableTreeNode)getRootNode).getUserObject(); Datatype dtype = new H5Datatype(Datatype.CLASS_INTEGER, Datatype.NATIVE, Datatype.NATIVE, Datatype.NATIVE); long[] dims = {100, 50}; long[] maxdims = dims; long[] chunks = null; // no chunking int gzip = 0; // no compression Object data = null; // no initial data values Dataset d = (H5File)file.createScalarDS(name, pgroup, dtype, dims, maxdims, chunks, gzip, data);
createScalarDS
in class FileFormat
name
- the name of the new datasetpgroup
- the parent group where the new dataset is created.type
- the datatype of the new dataset.dims
- dimension sizes of the new dataset.maxdims
- the maximum dimension sizes of the new dataset.chunks
- the chunk sizes of the new dataset.gzip
- the compression level.data
- the data of the new dataset.
java.lang.Exception
public Dataset createCompoundDS(java.lang.String name, Group pgroup, long[] dims, java.lang.String[] memberNames, Datatype[] memberDatatypes, int[] memberSizes, java.lang.Object data) throws java.lang.Exception
FileFormat
String name = "2D compound"; Group pgroup = (Group)((DefaultMutableTreeNode)getRootNode).getUserObject(); long[] dims = {100, 50}; String[] memberNames = {"x", "y"} Datatype[] memberDatatypes = { new H5Datatype(Datatype.CLASS_INTEGER, Datatype.NATIVE, Datatype.NATIVE, Datatype.NATIVE) new H5Datatype(Datatype.CLASS_FLOAT, Datatype.NATIVE, Datatype.NATIVE, Datatype.NATIVE)); int[] memberSizes = {1, 10}; Object data = null; // no initial data values Dataset d = (H5File)file.createCompoundDS(name, pgroup, dims, memberNames, memberDatatypes, memberSizes, null);
createCompoundDS
in class FileFormat
name
- the name of the new datasetpgroup
- the parent group where the new dataset is created.dims
- dimension sizes of the new dataset.memberNames
- the names of the members.memberDatatypes
- the datatypes of the members.memberSizes
- the array size of the member.data
- the data of the new dataset.
java.lang.Exception
public Dataset createImage(java.lang.String name, Group pgroup, Datatype type, long[] dims, long[] maxdims, long[] chunks, int gzip, int ncomp, int intelace, java.lang.Object data) throws java.lang.Exception
FileFormat
String name = "2D image"; Group pgroup = (Group)((DefaultMutableTreeNode)getRootNode).getUserObject(); Datatype dtype = new H5Datatype(Datatype.CLASS_INTEGER, 1, Datatype.NATIVE, Datatype.SIGN_NONE); long[] dims = {100, 50}; long[] maxdims = dims; long[] chunks = null; // no chunking int gzip = 0; // no compression int ncomp = 2; int interlace = ScalarDS.INTERLACE_PIXEL; Object data = null; // no initial data values Dataset d = (H5File)file.createScalarDS(name, pgroup, dtype, dims, maxdims, chunks, gzip, ncomp, interlace, data);
createImage
in class FileFormat
name
- the name of the new imagepgroup
- the parent group where the new image is created.type
- the datatype of the new image.dims
- dimension sizes of the new image.maxdims
- the maximum dimension sizes of the new image.chunks
- the chunk sizes of the new image.gzip
- the compression level.ncomp
- the number of components of the new imagedata
- the data of the new image.
java.lang.Exception
public void delete(HObject obj) throws java.lang.Exception
FileFormat
delete
in class FileFormat
obj
- the data object to delete.
java.lang.Exception
public void reloadTree(Group g)
public javax.swing.tree.TreeNode copy(HObject srcObj, Group dstGroup) throws java.lang.Exception
FileFormat
copy
in class FileFormat
srcObj
- the object to copy.dstGroup
- the destination group.
java.lang.Exception
public void copyAttributes(HObject src, HObject dst)
public void copyAttributes(int src_id, int dst_id)
public static void updateReferenceDataset(H5File srcFile, H5File newFile) throws java.lang.Exception
java.lang.Exception
public static java.util.List getAttribute(int objID) throws HDF5Exception
objID
- the object identifier.
HDF5Exception
public void writeAttribute(HObject obj, Attribute attr, boolean attrExisted) throws HDF5Exception
writeAttribute
in class FileFormat
obj
- the object which the attribute is to be attached to.attr
- the atribute to attach.attrExisted
- The indicator if the given attribute exists.
HDF5Exception
public static void createImageAttributes(Dataset dataset, int interlace) throws java.lang.Exception
dataset
- the image dataset which the attributes are added to.interlace
- interlace the interlace mode of image data.
java.lang.Exception
public java.lang.String getLibversion()
getLibversion
in class FileFormat
public HObject get(java.lang.String path) throws java.lang.Exception
get
in class FileFormat
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |