Package nom.tam.fits.header
Enum Bitpix
- All Implemented Interfaces:
Serializable,Comparable<Bitpix>,java.lang.constant.Constable
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 ConstantsEnum ConstantDescriptionFor FITS data stored as bytesFor FITS data stored as 64-bit double-precision floating point valuesFor FITS data stored as 32-bit single-precision floating point valuesFor FITS data stored as 32-bit integersFor FITS data stored as 64-bit integersFor FITS data stored as 16-bit integers -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBITPIX value forbytetype datastatic final intBITPIX value fordoubletype datastatic final intBITPIX value forfloattype datastatic final intBITPIX value forinttype datastatic final intBITPIX value forlongtype datastatic final intBITPIX value forshorttype data -
Method Summary
Modifier and TypeMethodDescriptionfinal intbyteSize()Returns the size of a data element, in bytes, for this BITPIX instancestatic BitpixforArrayID(char id) Returns the standard BITPIX object for the given Java array ID.static BitpixforNumberType(Class<? extends Number> dataType) Returns the standard BITPIX object for a number type.static BitpixforPrimitiveType(Class<?> dataType) Returns the standard BITPIX object for a primitive type.static BitpixforValue(int ival) Returns the standard BITPIX enum value for a given integer value, such as 8, 16, 32, 64, -32, or -64.static BitpixforValue(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 BitpixfromHeader(Header h) Returns the standard BITPIX object based on the value assigned to the BITPIX keyword in the headerstatic BitpixfromHeader(Header h, boolean allowRepair) Returns the standard BITPIX object based on the value assigned to the BITPIX keyword in the headerfinal charReturns the Java letter ID for this BITPIX instance, such as the letter ID used in the Java array representation of that class.final StringReturns a concise description of the data type represented by this BITPIX instance.final ElementType<?> Returns the FITS element type corresponding to this bitpix valuefinal HeaderCardReturns the standard FITS header card for this BITPIX instance.final intReturns the FITS standard BITPIX header value for this instance.Returns the sublass ofNumbercorresponding for this BITPIX value.final Class<?> Returns the primitive built-in Java number type corresponding for this BITPIX value.static BitpixReturns the enum constant of this type with the specified name.static Bitpix[]values()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
-
Enum Constant Details
-
BYTE
For FITS data stored as bytes -
SHORT
For FITS data stored as 16-bit integers -
INTEGER
For FITS data stored as 32-bit integers -
LONG
For FITS data stored as 64-bit integers -
FLOAT
For FITS data stored as 32-bit single-precision floating point values -
DOUBLE
For FITS data stored as 64-bit double-precision floating point values
-
-
Field Details
-
VALUE_FOR_BYTE
public static final int VALUE_FOR_BYTEBITPIX value forbytetype data- See Also:
-
VALUE_FOR_SHORT
public static final int VALUE_FOR_SHORTBITPIX value forshorttype data- See Also:
-
VALUE_FOR_INT
public static final int VALUE_FOR_INTBITPIX value forinttype data- See Also:
-
VALUE_FOR_LONG
public static final int VALUE_FOR_LONGBITPIX value forlongtype data- See Also:
-
VALUE_FOR_FLOAT
public static final int VALUE_FOR_FLOATBITPIX value forfloattype data- See Also:
-
VALUE_FOR_DOUBLE
public static final int VALUE_FOR_DOUBLEBITPIX value fordoubletype data- See Also:
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
getElementType
Returns the FITS element type corresponding to this bitpix value- Returns:
- the FITS element type that corresponds to this bitpix value.
-
getNumberType
Returns the sublass ofNumbercorresponding for this BITPIX value.- Returns:
- the number class for this BITPIX instance.
- See Also:
-
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, ordouble.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, anint[]array has classI[, so the letter ID isI.- Returns:
- The Java letter ID for arrays corresponding to this BITPIX instance.
- See Also:
-
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
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
Returns the standard BITPIX object for a primitive type.- Parameters:
dataType- the primitive class, such asint.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
Returns the standard BITPIX object for a number type.- Parameters:
dataType- the class of number, such asInteger.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
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
Returns the standard BITPIX object based on the value assigned to the BITPIX keyword in the header- Parameters:
h- the FITS headerallowRepair- 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
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 ofHeader.- 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
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 ofHeader.- 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
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 oflong[][]has a class name ofJ[[, so so the array ID forlongarrays isJ.- Parameters:
id- The Java letter ID for arrays of the underlying primitive type. E.g.Jforlong.- 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.
-