|
||||||||||
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.h4.H4File
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 | |
H4File()
Creates an H4File with read only access. |
|
H4File(java.lang.String pathname)
Creates an H4File with read only access. |
|
H4File(java.lang.String pathname,
int access)
Creates an H4File with specific full 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 an object to a group. |
FileFormat |
create(java.lang.String fileName)
Creates a new HDF4 file. |
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. |
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 interlace,
java.lang.Object data)
Create a new image at given parent group in this file. |
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. |
java.lang.String |
getFilePath()
Returns the full path of the file: file path + file name. |
java.lang.String |
getLibversion()
Returns the version of the HDF4 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 HDF4 file. |
boolean |
isThisType(java.lang.String filename)
Checks if the given file is an HDF4 file or netCDF. |
int |
open()
Opens access to the file resource and returns the file identifier. |
FileFormat |
open(java.lang.String pathname,
int access)
Open a file and returns an instance of implementing class of the FileFormat. |
void |
writeAttribute(HObject obj,
Attribute attr,
boolean isSDglobalAttr)
Creates a new attribute and attached to the object if attribute does not exist. |
Methods inherited from class ncsa.hdf.object.FileFormat |
addFileExtension, addFileFormat, createDatatype, createLink, 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 H4File()
public H4File(java.lang.String pathname)
public H4File(java.lang.String pathname, int access)
pathname
- the full path of the file name.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
FileFormat
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 HDFException
FileFormat
close
in class FileFormat
HDFException
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
fileName
- the name of the file to create.
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 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 interlace, 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
delete
in class FileFormat
obj
- the data object to delete.
java.lang.Exception
public javax.swing.tree.TreeNode copy(HObject srcObj, Group dstGroup) throws java.lang.Exception
copy
in class FileFormat
srcObj
- the object to copy.dstGroup
- the destination group.
java.lang.Exception
public void writeAttribute(HObject obj, Attribute attr, boolean isSDglobalAttr) throws HDFException
writeAttribute
in class FileFormat
obj
- the object which the attribute is to be attached to.attr
- the atribute to attach.isSDglobalAttr
- The indicator if the given attribute exists.
HDFException
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 |