Enum Bitpix

java.lang.Object
java.lang.Enum<Bitpix>
nom.tam.fits.header.Bitpix
All Implemented Interfaces:
Serializable, Comparable<Bitpix>, java.lang.constant.Constable

public enum Bitpix extends Enum<Bitpix>
Standard BITPIX values and associated functions. Since the FITS BITPIX keyword has only a handful of legal values, an enum provides ideal type-safe representation. It also allows to interface the value for the type of data it represents in a natural way.
Since:
1.16
Author:
Attila Kovacs
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    For FITS data stored as bytes
    For FITS data stored as 64-bit double-precision floating point values
    For FITS data stored as 32-bit single-precision floating point values
    For FITS data stored as 32-bit integers
    For FITS data stored as 64-bit integers
    For FITS data stored as 16-bit integers
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    BITPIX value for byte type data
    static final int
    BITPIX value for double type data
    static final int
    BITPIX value for float type data
    static final int
    BITPIX value for int type data
    static final int
    BITPIX value for long type data
    static final int
    BITPIX value for short type data
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    Returns the size of a data element, in bytes, for this BITPIX instance
    static Bitpix
    forArrayID(char id)
    Returns the standard BITPIX object for the given Java array ID.
    static Bitpix
    forNumberType(Class<? extends Number> dataType)
    Returns the standard BITPIX object for a number type.
    static Bitpix
    forPrimitiveType(Class<?> dataType)
    Returns the standard BITPIX object for a primitive type.
    static Bitpix
    forValue(int ival)
    Returns the standard BITPIX enum value for a given integer value, such as 8, 16, 32, 64, -32, or -64.
    static Bitpix
    forValue(int ival, boolean allowRepair)
    Returns the standard BITPIX enum value for a given integer value, such as 8, 16, 32, 64, -32, or -64.
    static Bitpix
    Returns the standard BITPIX object based on the value assigned to the BITPIX keyword in the header
    static Bitpix
    fromHeader(Header h, boolean allowRepair)
    Returns the standard BITPIX object based on the value assigned to the BITPIX keyword in the header
    final char
    Returns the Java letter ID for this BITPIX instance, such as the letter ID used in the Java array representation of that class.
    final String
    Returns a concise description of the data type represented by this BITPIX instance.
    final ElementType<?>
    Returns the FITS element type corresponding to this bitpix value
    Returns the standard FITS header card for this BITPIX instance.
    final int
    Returns the FITS standard BITPIX header value for this instance.
    final Class<? extends Number>
    Returns the sublass of Number corresponding for this BITPIX value.
    final Class<?>
    Returns the primitive built-in Java number type corresponding for this BITPIX value.
    static Bitpix
    Returns the enum constant of this type with the specified name.
    static Bitpix[]
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Enum

    compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • BYTE

      public static final Bitpix BYTE
      For FITS data stored as bytes
    • SHORT

      public static final Bitpix SHORT
      For FITS data stored as 16-bit integers
    • INTEGER

      public static final Bitpix INTEGER
      For FITS data stored as 32-bit integers
    • LONG

      public static final Bitpix LONG
      For FITS data stored as 64-bit integers
    • FLOAT

      public static final Bitpix FLOAT
      For FITS data stored as 32-bit single-precision floating point values
    • DOUBLE

      public static final Bitpix DOUBLE
      For FITS data stored as 64-bit double-precision floating point values
  • Field Details

    • VALUE_FOR_BYTE

      public static final int VALUE_FOR_BYTE
      BITPIX value for byte type data
      See Also:
    • VALUE_FOR_SHORT

      public static final int VALUE_FOR_SHORT
      BITPIX value for short type data
      See Also:
    • VALUE_FOR_INT

      public static final int VALUE_FOR_INT
      BITPIX value for int type data
      See Also:
    • VALUE_FOR_LONG

      public static final int VALUE_FOR_LONG
      BITPIX value for long type data
      See Also:
    • VALUE_FOR_FLOAT

      public static final int VALUE_FOR_FLOAT
      BITPIX value for float type data
      See Also:
    • VALUE_FOR_DOUBLE

      public static final int VALUE_FOR_DOUBLE
      BITPIX value for double type data
      See Also:
  • Method Details

    • values

      public static Bitpix[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static Bitpix valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getElementType

      public final ElementType<?> getElementType()
      Returns the FITS element type corresponding to this bitpix value
      Returns:
      the FITS element type that corresponds to this bitpix value.
    • getNumberType

      public final Class<? extends Number> getNumberType()
      Returns the sublass of Number corresponding for this BITPIX value.
      Returns:
      the number class for this BITPIX instance.
      See Also:
    • getPrimitiveType

      public final Class<?> getPrimitiveType()
      Returns the primitive built-in Java number type corresponding for this BITPIX value.
      Returns:
      the primitive class for this BITPIX instance, such as int.class, or double.class.
      See Also:
    • getHeaderValue

      public final int getHeaderValue()
      Returns the FITS standard BITPIX header value for this instance.
      Returns:
      the standard FITS BITPIX value, such as 8, 16, 32, 64, -32, or -64.
      See Also:
    • getArrayID

      public final char getArrayID()
      Returns the Java letter ID for this BITPIX instance, such as the letter ID used in the Java array representation of that class. For example, an int[] array has class I[, so the letter ID is I.
      Returns:
      The Java letter ID for arrays corresponding to this BITPIX instance.
      See Also:
    • getDescription

      public final String getDescription()
      Returns a concise description of the data type represented by this BITPIX instance.
      Returns:
      a brief description of the corresponding data type.
    • byteSize

      public final int byteSize()
      Returns the size of a data element, in bytes, for this BITPIX instance
      Returns:
      the size of a data element in bytes.
    • getHeaderCard

      public final HeaderCard getHeaderCard()
      Returns the standard FITS header card for this BITPIX instance.
      Returns:
      the standard FITS header card with the BITPIX keyword and the corresponding value for this instance.
      See Also:
    • forPrimitiveType

      public static Bitpix forPrimitiveType(Class<?> dataType) throws FitsException
      Returns the standard BITPIX object for a primitive type.
      Parameters:
      dataType - the primitive class, such as int.class.
      Returns:
      the standard BITPIX associated to the number type
      Throws:
      FitsException - if the class is not a primitive class, or if its not one that has a corresponding BITPIX value (e.g. boolean.class).
      See Also:
    • forNumberType

      public static Bitpix forNumberType(Class<? extends Number> dataType) throws FitsException
      Returns the standard BITPIX object for a number type.
      Parameters:
      dataType - the class of number, such as Integer.TYPE.
      Returns:
      the standard BITPIX associated to the number type
      Throws:
      FitsException - if there is no standard BITPIX value corresponding to the number type (e.g. BigDecimal).
      See Also:
    • fromHeader

      public static Bitpix fromHeader(Header h) throws FitsException
      Returns the standard BITPIX object based on the value assigned to the BITPIX keyword in the header
      Parameters:
      h - the FITS header
      Returns:
      the standard BITPIX enum that matches the header description, or is inferred from an invalid header description (provided FitsFactory.setAllowHeaderRepairs(boolean) is enabled).
      Throws:
      FitsException - if the header does not contain a BITPIX value or it is invalid and cannot or will not be repaired.
      See Also:
    • fromHeader

      public static Bitpix fromHeader(Header h, boolean allowRepair) throws FitsException
      Returns the standard BITPIX object based on the value assigned to the BITPIX keyword in the header
      Parameters:
      h - the FITS header
      allowRepair - if we can try repair non-standard (invalid) BITPIX values.
      Returns:
      the standard BITPIX enum that matches the header description, or is inferred from an invalid header description.
      Throws:
      FitsException - if the header does not contain a BITPIX value or it is invalid and cannot or will not be repaired.
      See Also:
    • forValue

      public static Bitpix forValue(int ival) throws FitsException
      Returns the standard BITPIX enum value for a given integer value, such as 8, 16, 32, 64, -32, or -64. If the value is not one of the standard values, then depending on whether header repairs are enabled either an exception is thrown, or else the value the value is 'repaired' and a loh entry is made to the logger of Header.
      Parameters:
      ival - The integer value of BITPIX in the FITS header.
      Returns:
      The standard value as a Java object.
      Throws:
      FitsException - if the value was invalid or irreparable.
      See Also:
    • forValue

      public static Bitpix forValue(int ival, boolean allowRepair) throws FitsException
      Returns the standard BITPIX enum value for a given integer value, such as 8, 16, 32, 64, -32, or -64. If the value is not one of the standard values, then depending on whether repairs are enabled either an exception is thrown, or else the value the value is 'repaired' and a loh entry is made to the logger of Header.
      Parameters:
      ival - The integer value of BITPIX in the FITS header.
      allowRepair - Whether we can fix up invalid values to make them valid.
      Returns:
      The standard value as a Java object.
      Throws:
      FitsException - if the value was invalid or irreparable.
      See Also:
    • forArrayID

      public static Bitpix forArrayID(char id) throws FitsException
      Returns the standard BITPIX object for the given Java array ID. The array ID is the same letter code as Java uses for identifying ptrimitive array types. For example a Java array of long[][] has a class name of J[[, so so the array ID for long arrays is J.
      Parameters:
      id - The Java letter ID for arrays of the underlying primitive type. E.g. J for long.
      Returns:
      The standard BITPIX enum corresponding to the data type.
      Throws:
      FitsException - if the data type is unknown or does not have a BITPIX ewquivalent.