Logo Search packages:      
Sourcecode: jhdf version File versions  Download package

static synchronized int ncsa::hdf::hdf5lib::H5::H5Dread ( int  dataset_id,
int  mem_type_id,
int  mem_space_id,
int  file_space_id,
int  xfer_plist_id,
Object  obj 
) throws HDF5Exception, HDF5LibraryException, NullPointerException [inline, static]

H5Dread reads a (partial) dataset, specified by its identifier dataset_id, from the file into the application data object.

Parameters:
dataset_id Identifier of the dataset read from.
mem_type_id Identifier of the memory datatype.
mem_space_id Identifier of the memory dataspace.
file_space_id Identifier of the dataset's dataspace in the file.
xfer_plist_id Identifier of a transfer property list for this I/O operation.
obj Object to store data read from the file.
Returns:
a non-negative value if successful
Exceptions:
HDF5Exception - Failure in the data conversion.
HDF5LibraryException - Error from the HDF-5 Library.
NullPointerException - data object is null.

Definition at line 850 of file H5.java.

References ncsa::hdf::hdf5lib::HDFArray::arrayify(), ncsa::hdf::hdf5lib::HDFArray::emptyBytes(), and H5Dread().

    {
        int status = -1;
        boolean is1D = false;

        Class dataClass = obj.getClass();
        if (!dataClass.isArray()) {
            throw (new HDF5JavaException("H5Dread: data is not an array"));
        }

        String cname = dataClass.getName();
        is1D = (cname.lastIndexOf('[') ==cname.indexOf('['));
        char dname = cname.charAt(cname.lastIndexOf("[")+1);

        if (is1D && (dname == 'B')) {
            status = H5Dread(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (byte[])obj);
        }
        else if (is1D && (dname == 'S')) {
            status = H5Dread_short(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (short[])obj);
        }
        else if (is1D && (dname == 'I')) {
            status = H5Dread_int(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (int[])obj);
        }
        else if (is1D && (dname == 'J')) {
            status = H5Dread_long(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (long[])obj);
        }
        else if (is1D && (dname == 'F')) {
            status = H5Dread_float(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (float[])obj);
        }
        else if (is1D && (dname == 'D')) {
            status = H5Dread_double(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (double[])obj);
        }
        else if (H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) {
            status = H5Dread_reg_ref(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (String[])obj);
        }
        else if (is1D && (dataClass.getComponentType() == String.class)) { 
            // Rosetta Biosoftware - add support for Strings (variable length) 
            if (H5.H5Tis_variable_str(mem_type_id)) {
                status = H5DreadVL(dataset_id, mem_type_id,mem_space_id, file_space_id, 
                        xfer_plist_id, (Object[])obj);
            } else {
                status = H5Dread_string(dataset_id, mem_type_id,mem_space_id, file_space_id,
                        xfer_plist_id, (String[])obj);
            }
        } else {
            // Create a data buffer to hold the data into a Java Array
            HDFArray theArray = new HDFArray(obj);
            byte[] buf = theArray.emptyBytes();

            // will raise exception if read fails
            status = H5Dread(dataset_id, mem_type_id, mem_space_id,
                    file_space_id, xfer_plist_id, buf);
            if (status >= 0) {
                // convert the data into a Java Array */
                obj = theArray.arrayify( buf);
            }

            // clean up these:  assign 'null' as hint to gc() */
            buf = null;
            theArray = null;
        }

        return status;
    }


Generated by  Doxygen 1.6.0   Back to index