Package nom.tam.fits
Class BinaryTable.ColumnDesc
java.lang.Object
nom.tam.fits.BinaryTable.ColumnDesc
- All Implemented Interfaces:
Cloneable
- Enclosing class:
- BinaryTable
Describes the data type and shape stored in a binary table column.
-
Constructor Summary
ConstructorDescriptionColumnDesc
(Class<?> base, int... dim) Creates a new column descriptor for the specified boxed Java type, and fixed array shape. -
Method Summary
Modifier and TypeMethodDescriptionclone()
static BinaryTable.ColumnDesc
createForDelimitedStringArrays
(byte delim) Creates a new column descriptor for variable-length arrays of delimited string entries.static BinaryTable.ColumnDesc
createForFixedArrays
(Class<?> type, int... dim) Creates a new column descriptor for fixed-shape non-string arrays.static BinaryTable.ColumnDesc
createForScalars
(Class<?> type) Creates a new column descriptor for a non-string based scalar column.static BinaryTable.ColumnDesc
createForStrings
(int len) Creates a new column descriptor for single string entries of fixed maximum length.static BinaryTable.ColumnDesc
createForStrings
(int len, int... outerDims) Creates a new column descriptor for arrays of string entries of fixed maximum length.static BinaryTable.ColumnDesc
createForVariableSize
(Class<?> type) Creates a new column descriptor for variable length 1D arrays or strings.static BinaryTable.ColumnDesc
createForVariableStringArrays
(int len) Creates a new column descriptor for variable-length arrays of fixed-length string entries.Class<?>
getBase()
Deprecated.int[]
Deprecated.(for internal use) UsegetEntryShape()
instead.final Class<?>
Returns the boxed Java type of elements stored in a column.final int
Returns the number of 'boxed' elements as returned byBinaryTable.get(int, int)
or expected byBinaryTable.set(int, int, Object)
.final int
Returns the number of primitive elements (sych as bytes) that constitute a Java element (such as a String) in this table.final int
Returns the dimensionality of the 'boxed' elements as returned byBinaryTable.get(int, int)
or expected byBinaryTable.set(int, int, Object)
.final int[]
Returns the array shape of the 'boxed' elements as returned byBinaryTable.get(int, int)
or expected byBinaryTable.set(int, int, Object)
.Class<?>
Returns the Java array element type that is used in Java to represent data in this column for the legacy table access methods.Returns the conversion between decimal and integer data representations for the column data.final byte
Returns the string delimiter that separates packed substrings in variable-length string arrays.final int
Returns the maximum length of string elements contained in this colum, or -1 if this is not a string based column, or if there is no limit set to string size (e.g. in a variable-length column)final int
Returns the number of regular primitive table elements in this column.boolean
Checks if this column used 64-bit heap pointers.final boolean
isBits()
Checks if this column contains only true boolean values (bits).final boolean
Checks if this column contains complex values.final boolean
Checks if this column contains logical values.final boolean
Checks if this column contains numerical values, such as any primitive number type (e.g.final boolean
Checks if this column contains single (scalar / non-array) elements only, including single strings or single complex values.final boolean
isString()
Checks if this column stores ASCII strings.final boolean
Checks if this column contains entries of different size.name()
Returns the name of this column, as it was stored or would be stored by a TTYPEn value in the FITS header.Sets a user-specified name for this column.newInstance
(int nRow) Deprecated.(for internal use) This method should be private in the future.int
rowLen()
Deprecated.(for internal use) It may be reduced to private visibility in the future.void
Sets the conversion between decimal and integer data representations for the column data.
-
Constructor Details
-
ColumnDesc
Creates a new column descriptor for the specified boxed Java type, and fixed array shape. The type may be any primitive type, or elseString.class
,Boolean.class
(for FITS logicals),ComplexValue.class
orComplexValue.Float.class
(for complex values with 64-bit and 32-bit precision, respectively). WhereasBoolean
type columns will be stored as FITS logicals (1 element per byte),boolean
types will be stored as packed bits (with up to 8 bits per byte).- Parameters:
base
- The Java type of base elements that this column is designated to contain. For exampleint.class
if the column will contain integers or arrays of integers.dim
- the fixed dimensions of the table entries. For strings the trailing dimension must specify the fixed length of strings.- Throws:
FitsException
- if the base type is not one that can be used in binary table columns.- Since:
- 1.18
- See Also:
-
-
Method Details
-
name
Sets a user-specified name for this column. The specified name will be used as the TTYPEn value for this column.- Parameters:
value
- The new name for this column.- Returns:
- itself, to support builder patterns.
- Throws:
IllegalArgumentException
- If the name contains characters outside of the ASCII range of 0x20 - 0x7F allowed by FITS.- Since:
- 1.20
- See Also:
-
name
Returns the name of this column, as it was stored or would be stored by a TTYPEn value in the FITS header.- Returns:
- the name of this column
- Since:
- 1.20
- See Also:
-
getQuantizer
Returns the conversion between decimal and integer data representations for the column data.- Returns:
- the quantizer that converts between floating-point and integer data representations, which may be
null
. - Since:
- 1.20
- See Also:
-
setQuantizer
Sets the conversion between decimal and integer data representations for the column data. If the table is read from a FITS input, the column's quantizer is automatically set if the Table HDU's header defines any of the TSCALn, TZEROn, or TNULLn keywords for the column. Users can override that by specifying another quatizer to use for the column, or dicard qunatizing by calling this method with anull
argument.- Parameters:
q
- the quantizer that converts between floating-point and integer data representations, ornull
to not use any quantization, and instead rely on the generic rounding for decimal-integer conversions for this column.- Since:
- 1.20
- See Also:
-
getStringLength
public final int getStringLength()Returns the maximum length of string elements contained in this colum, or -1 if this is not a string based column, or if there is no limit set to string size (e.g. in a variable-length column)- Returns:
- the maximum length of string values stored in this column, or -1 if it is not as string column, or if its a string column containing strings of unconstrained variable length.
- Since:
- 1.18
- See Also:
-
getStringDelimiter
public final byte getStringDelimiter()Returns the string delimiter that separates packed substrings in variable-length string arrays.- Returns:
- the delimiter byte value (usually between 0x20 and 0x7e) or 0 if no delimiter was set.
- See Also:
-
createForScalars
public static BinaryTable.ColumnDesc createForScalars(Class<?> type) throws IllegalArgumentException, FitsException Creates a new column descriptor for a non-string based scalar column. The type may be any primitive type, orBoolean.class
(for FITS logicals),ComplexValue.class
orComplexValue.Float.class
(for complex values with 64-bit and 32-bit precision, respectively). WhereasBoolean
type columns will be stored as FITS logicals (1 element per byte),boolean
types will be stored as packed bits (with up to 8 bits per byte).- Parameters:
type
- The Java type of base elements that this column is designated to contain. For exampleint.class
if the column will contain integers or arrays of integers. It must not beString.class
. To create scalarString
columns usecreateForStrings(int)
instead.- Returns:
- the new column descriptor.
- Throws:
IllegalArgumentException
- if the type isString.class
, for which you should be usingcreateForStrings(int)
instead.FitsException
- if the base type is not one that can be used in binary table columns.- Since:
- 1.18
- See Also:
-
createForFixedArrays
public static BinaryTable.ColumnDesc createForFixedArrays(Class<?> type, int... dim) throws IllegalArgumentException, FitsException Creates a new column descriptor for fixed-shape non-string arrays. The type may be any primitive type, or elseBoolean.class
(for FITS logicals),ComplexValue.class
orComplexValue.Float.class
(for complex values with 64-bit and 32-bit precision, respectively). WhereasBoolean
type columns will be stored as FITS logicals (1 element per byte),boolean
types will be stored as packed bits (with up to 8 bits per byte).- Parameters:
type
- The Java type of base elements that this column is designated to contain. For exampleint.class
if the column will contain integers or arrays of integers. It must not beString.class
. To create scalarString
columns usecreateForStrings(int)
instead.dim
- the fixed dimensions of the table entries. For strings the trailing dimension must specify the fixed length of strings.- Returns:
- the new column descriptor.
- Throws:
IllegalArgumentException
- if the type isString.class
, for which you should be usingcreateForStrings(int, int[])
instead.FitsException
- if the base type is not one that can be used in binary table columns.- Since:
- 1.18
- See Also:
-
createForStrings
Creates a new column descriptor for single string entries of fixed maximum length.- Parameters:
len
- The fixed string length in bytes.- Returns:
- the new column descriptor
- Throws:
FitsException
- if the base type is not one that can be used in binary table columns.- Since:
- 1.18
- See Also:
-
createForStrings
public static BinaryTable.ColumnDesc createForStrings(int len, int... outerDims) throws FitsException Creates a new column descriptor for arrays of string entries of fixed maximum length.- Parameters:
len
- The fixed string length in bytes.outerDims
- The shape of string arrays- Returns:
- the new column descriptor
- Throws:
FitsException
- if the base type is not one that can be used in binary table columns.- Since:
- 1.18
- See Also:
-
createForVariableStringArrays
Creates a new column descriptor for variable-length arrays of fixed-length string entries. Each string component will occupy exactlylen
bytes.- Parameters:
len
- The fixed string storage length in bytes.- Returns:
- the new column descriptor
- Throws:
FitsException
- if the column could not be created.- Since:
- 1.18
- See Also:
-
createForDelimitedStringArrays
public static BinaryTable.ColumnDesc createForDelimitedStringArrays(byte delim) throws FitsException Creates a new column descriptor for variable-length arrays of delimited string entries.- Parameters:
delim
- the byte value that delimits strings that are shorter than the storage length. It should be in the ASCII range of 0x20 through 0x7e.- Returns:
- the new column descriptor
- Throws:
FitsException
- if the column could not be created.- Since:
- 1.18
- See Also:
-
createForVariableSize
Creates a new column descriptor for variable length 1D arrays or strings. The type may be any primitive type, or elseString.class
,Boolean.class
(for FITS logicals),ComplexValue.class
orComplexValue.Float.class
(for complex values with 64-bit and 32-bit precision, respectively). WhereasBoolean
type columns will be stored as FITS logicals (1 element per byte),boolean
types will be stored as packed bits (with up to 8 elements per byte).- Parameters:
type
- The Java type of base elements that this column is designated to contain. For exampleint.class
if the column will contain integers or arrays of integers.- Returns:
- the new column descriptor
- Throws:
FitsException
- if the base type is not one that can be used in binary table columns.- Since:
- 1.18
- See Also:
-
clone
-
isSingleton
public final boolean isSingleton()Checks if this column contains single (scalar / non-array) elements only, including single strings or single complex values.- Returns:
true
if the column contains individual elements of its type, or elsefalse
if it contains arrays.- Since:
- 1.18
-
isLogical
public final boolean isLogical()Checks if this column contains logical values. FITS logicals can each hvetrue
,false
ornull
(undefined) values. It is the support for these undefined values that set it apart from typical booleans. Also, logicals are stored as one byte per element. So if using onlytrue
,false
values withoutnull
bits will offer more compact storage (by up to a factor of 8). You can convert existing logical columns to bits viaBinaryTable.convertToBits(int)
.- Returns:
true
if this column contains logical values.- Since:
- 1.18
- See Also:
-
isBits
public final boolean isBits()Checks if this column contains only true boolean values (bits). Unlike logicals, bits can have onlytrue
,false
values with no support fornull
, but offer more compact storage (by up to a factor of 8) than logicals. You can convert existing logical columns to bits viaBinaryTable.convertToBits(int)
.- Returns:
true
if this column containstrue
/false
bits only.- Since:
- 1.18
- See Also:
-
isString
public final boolean isString()Checks if this column stores ASCII strings.- Returns:
true
if this column contains only strings.- See Also:
-
isComplex
public final boolean isComplex()Checks if this column contains complex values. You can convert suitable columns offloat
ordouble
elements to complex usingBinaryTable.setComplexColumn(int)
, as long as the last dimension is 2, ir if the variable-length columns contain even-number of values exclusively.- Returns:
true
if this column contains complex values.
-
isNumeric
public final boolean isNumeric()Checks if this column contains numerical values, such as any primitive number type (e.g.nt.class
ordouble.class
) or else aComplexValue
type. type.- Returns:
true
if this column contains numerical data, including complex-valued data. String, bits, and FITS logicals are not numerical (but all other column types are).- Since:
- 1.20
-
getBase
Deprecated.Ambiguous, usegetLegacyBase()
instead. It can be confusing since it is not clear if it refers to array element types used in FITS storage or on the java side when using the older array access, or if it refers to the class of entries in the main table, which may be heap pointers. It is also distinct fromgetElementClass()
, which returns the boxed type used byBinaryTable.get(int, int)
orBinaryTable.set(int, int, Object)
.Returns the Java array element type that is used in Java to represent data in this column. When accessing columns or their elements in the old way, through arrays, this is the type that arrays from the Java side will expect or provide. For example, when storingString
values (regular or variable-sized), this will returnString.class
. Arrays returned byBinaryTable.getColumn(int)
,BinaryTable.getRow(int)
, andBinaryTable.getElement(int, int)
will return arrays of this type, and the equivalent methods for setting data will expect arrays of this type as their argument.- Returns:
- the Java class, arrays of which, packaged data for this column on the Java side.
-
getLegacyBase
Returns the Java array element type that is used in Java to represent data in this column for the legacy table access methods. When accessing columns or their elements in the old way, through arrays, this is the type that arrays from the Java side will expect or provide. For example, when storing complex values (regular or variable-sized), this will return
float.class
ordouble.class
. Arrays returned byBinaryTable.getColumn(int)
,BinaryTable.getRow(int)
, andBinaryTable.getElement(int, int)
will return arrays of this type.This is different from
getElementClass()
, which in turn returns the boxed type of objects returned byBinaryTable.get(int, int)
.- Returns:
- the Java class, arrays of which, packaged data for this column on the Java side.
- Since:
- 1.18
- See Also:
-
getDimens
public int[] getDimens()Deprecated.(for internal use) UsegetEntryShape()
instead. Not useful to users since it returns the dimensions of the primitive storage types, which is not always the dimension of table entries on the Java side.Returns the dimensions of elements in this column. As of 1.18, this method returns a copy ot the array used internally, which is safe to modify.- Returns:
- an array with the element dimensions.
-
getElementClass
Returns the boxed Java type of elements stored in a column.- Returns:
- The java type of elements in the columns. For columns containing strings, FITS logicals, or complex
values it will be
String.class
,Boolean.class
orComplexValue.class
respectively. For all other column types the primitive class of the elements contained (e.g.char.class
,float.class
) is returned. - Since:
- 1.18
- See Also:
-
getEntryDimension
public final int getEntryDimension()Returns the dimensionality of the 'boxed' elements as returned byBinaryTable.get(int, int)
or expected byBinaryTable.set(int, int, Object)
. That is it returns the dimnesion of 'boxed' elements, such as strings or complex values, rather than the dimension of characters or real components stored in the FITS for these.- Returns:
- the number of array dimensions in the 'boxed' Java type for this column. Variable-sized columns will always return 1.
- Since:
- 1.18
- See Also:
-
getEntryShape
public final int[] getEntryShape()Returns the array shape of the 'boxed' elements as returned byBinaryTable.get(int, int)
or expected byBinaryTable.set(int, int, Object)
. That is it returns the array shape of 'boxed' elements, such as strings or complex values, rather than the shape of characters or real components stored in the FITS for these.- Returns:
- the array sized along each of the dimensions in the 'boxed' Java type for this column, or
null
if the data is stored as variable-sized one-dimensional arrays of the boxed element type. (Note, that accordingly variable-length string columns containing single strings will thus return{1}
, notnull
). - Since:
- 1.18
- See Also:
-
getElementWidth
public final int getElementWidth()Returns the number of primitive elements (sych as bytes) that constitute a Java element (such as a String) in this table.- Returns:
- The number of primitives per Java element in the column, that is 1 for columns of primitive types, 2 for complex-valued columns, or the number of bytes (characters) in a String element. Variable-length strings will return -1.
- Since:
- 1.18
- See Also:
-
getElementCount
public final int getElementCount()Returns the number of 'boxed' elements as returned byBinaryTable.get(int, int)
or expected byBinaryTable.set(int, int, Object)
. That is it returns the number of strings or complex values per table entry, rather than the number of of characters or real components stored in the FITS for these.- Returns:
- the number of array elements in the 'boxed' Java type for this column, or -1 if the column contains elements of varying size.
- Since:
- 1.18
- See Also:
-
getTableBaseCount
public final int getTableBaseCount()Returns the number of regular primitive table elements in this column. For example, variable-length columns will always return 2, and complex-valued columns will return twice the number of complex values stored in each table entry.- Returns:
- the number of primitive table elements
- Since:
- 1.18
-
isVariableSize
public final boolean isVariableSize()Checks if this column contains entries of different size. Data for variable length coulmns is stored on the heap as one-dimemnsional arrays. As such information about the 'shape' of data is lost when they are stored that way.- Returns:
true
if the column contains elements of variable size, or elsefalse
if all entries have the same size and shape.
-
newInstance
Deprecated.(for internal use) This method should be private in the future.- Parameters:
nRow
- the number of rows to allocate the array for- Returns:
- new instance of the array with space for the specified number of rows.
-
rowLen
public int rowLen()Deprecated.(for internal use) It may be reduced to private visibility in the future. Returns the number of bytes that each element occupies in its FITS serialized form in the stored row data.- Returns:
- the number of bytes an element occupies in the FITS binary table data representation
-
hasLongPointers
public boolean hasLongPointers()Checks if this column used 64-bit heap pointers.- Returns:
true
if the column uses 64-bit heap pointers, otherwisefalse
- Since:
- 1.18
- See Also:
-
getLegacyBase()
instead.