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

static synchronized int ncsa::hdf::hdf5lib::H5::H5Dwrite ( 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]

H5Dwrite writes a (partial) dataset, specified by its identifier dataset_id, from the application memory data object into the file.

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 with data to be written to 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 1000 of file H5.java.

References ncsa::hdf::hdf5lib::HDFArray::byteify(), H5Dwrite(), and H5DwriteString().

    {
        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 = H5Dwrite(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (byte[])obj);
        }
        else if (is1D && (dname == 'S')) {
            status = H5Dwrite_short(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (short[])obj);
        }
        else if (is1D && (dname == 'I')) {
            status = H5Dwrite_int(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (int[])obj);
        }
        else if (is1D && (dname == 'J')) {
            status = H5Dwrite_long(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (long[])obj);
        }
        else if (is1D && (dname == 'F')) {
            status = H5Dwrite_float(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (float[])obj);
        }
        else if (is1D && (dname == 'D')) {
            status = H5Dwrite_double(dataset_id, mem_type_id,mem_space_id, file_space_id,
                    xfer_plist_id, (double[])obj);
        }

        // Rosetta Biosoftware - call into H5DwriteString for variable length Strings 
        else if ((H5.H5Tget_class(mem_type_id) == HDF5Constants.H5T_STRING) && H5.H5Tis_variable_str(mem_type_id) 
                && dataClass.isArray() && (dataClass.getComponentType() == String.class) && is1D) { 
            status = H5DwriteString(dataset_id, mem_type_id, 
                    mem_space_id, file_space_id, xfer_plist_id, (String[])obj); 

        } else {
            HDFArray theArray = new HDFArray(obj);
            byte[] buf = theArray.byteify();

            /* will raise exception on error */
            status = H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, 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