Class FitsDatatype

Object
hdf.object.HObject
hdf.object.Datatype
hdf.object.fits.FitsDatatype
All Implemented Interfaces:
MetaDataContainer, Serializable

public class FitsDatatype
extends Datatype
Datatype encapsulates information of a datatype. Information includes the class, size, endian of a datatype.

Version:
1.1 9/4/2007
Author:
Peter X. Cao
See Also:
Serialized Form
  • Constructor Details

    • FitsDatatype

      public FitsDatatype​(int tclass, int tsize, int torder, int tsign) throws Exception
      Create an Datatype with specified class, size, byte order and sign. The following list a few example of how to create a Datatype.
      1. to create unsigned native integer
        FitsDatatype type = new H5Dataype(Datatype.CLASS_INTEGER, Datatype.NATIVE, Datatype.NATIVE, Datatype.SIGN_NONE);
      2. to create 16-bit signed integer with big endian
        FitsDatatype type = new H5Dataype(Datatype.CLASS_INTEGER, 2, Datatype.ORDER_BE, Datatype.NATIVE);
      3. to create native float
        FitsDatatype type = new H5Dataype(Datatype.CLASS_FLOAT, Datatype.NATIVE, Datatype.NATIVE, Datatype.NATIVE);
      4. to create 64-bit double
        FitsDatatype type = new H5Dataype(Datatype.CLASS_FLOAT, 8, Datatype.NATIVE, Datatype.NATIVE);
      Parameters:
      tclass - the class of the datatype.
      tsize - the size of the datatype in bytes.
      torder - the order of the datatype.
      tsign - the sign of the datatype.
      Throws:
      Exception - if there is an error
    • FitsDatatype

      public FitsDatatype​(long theType) throws Exception
      Create a Datatype with a given fits native datatype.
      Parameters:
      theType - the fits native datatype.
      Throws:
      Exception - if there is an error
  • Method Details

    • hasAttribute

      public boolean hasAttribute()
      Description copied from interface: MetaDataContainer
      Check if the object has any attributes attached.
      Returns:
      true if it has any attributes, false otherwise.
    • allocateArray

      public static Object allocateArray​(long dtype, int size) throws OutOfMemoryError
      Allocate an one-dimensional array of byte, short, int, long, float, double, or String to store data retrieved from an fits file based on the given fits datatype and dimension sizes.
      Parameters:
      dtype - the fits datatype.
      size - the total size of the array.
      Returns:
      the array object if successful and null otherwise.
      Throws:
      OutOfMemoryError
    • fromNative

      public void fromNative()
      Translate fits datatype identifier into FitsDatatype.
    • fromNative

      public void fromNative​(long dtype)
      Translate fits datatype identifier into FitsDatatype.
      Specified by:
      fromNative in class Datatype
      Parameters:
      dtype - the fits native datatype.
    • getDescription

      public String getDescription()
      Description copied from class: Datatype
      Returns a short text description of this datatype.
      Overrides:
      getDescription in class Datatype
      Returns:
      a short text description of this datatype
    • isText

      public boolean isText()
      Specified by:
      isText in class Datatype
    • isUnsigned

      public boolean isUnsigned()
      Description copied from class: Datatype
      Checks if this datatype is unsigned.
      Overrides:
      isUnsigned in class Datatype
      Returns:
      true if the datatype is unsigned; otherwise, returns false.
    • createNative

      public long createNative()
      Description copied from class: Datatype
      Converts the datatype object to a native datatype. Subclasses must implement it so that this datatype will be converted accordingly. Use close() to close the native identifier; otherwise, the datatype will be left open.

      For example, a HDF5 datatype created from

       H5Dataype dtype = new H5Datatype(CLASS_INTEGER, 4, NATIVE, SIGN_NONE);
       int tid = dtype.createNative();
       
      The "tid" will be the HDF5 datatype id of a 64-bit unsigned integer, which is equivalent to
       int tid = H5.H5Tcopy(HDF5Constants.H5T_NATIVE_UNINT32);
       
      Specified by:
      createNative in class Datatype
      Returns:
      the identifier of the native datatype.
    • close

      public void close​(long id)
      Description copied from class: Datatype
      Closes a datatype identifier.

      Sub-classes must replace this default implementation.

      Specified by:
      close in class Datatype
      Parameters:
      id - the datatype identifier to close.
    • getMetadata

      public List getMetadata​(int... attrPropList) throws Exception
      Throws:
      Exception