Package nom.tam.fits
Class FitsHeap
java.lang.Object
nom.tam.fits.FitsHeap
- All Implemented Interfaces:
FitsElement
Heap for storing variable-length entries in binary tables. FITS binary tables store variable length arrays on a heap,
following the regular array data. The newer implementation of the heap now provides proper random access to the byte
buffer as of version 1.16.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Gets data for a Java array from the heap.long
Returns the byte offset at which this element starts ina file.long
getSize()
Returns the size of this elements in the FITS representation.void
read
(ArrayDataInput str) Read a FITS element from the input, starting at the current position.boolean
reset()
Reset the input stream to point to the beginning of this elementvoid
rewrite()
Rewrite the contents of the element in place.boolean
Checks if we can write this element back to its source.int
size()
Returns the current heap size.void
write
(ArrayDataOutput str) Writes the contents of the element to a data sink, adding padding as necessary if the element (such as a header or data segment) is expected to complete the FITS block of 2880 bytes.
-
Method Details
-
getData
Gets data for a Java array from the heap. The array may be a multi-dimensional array of arrays.- Parameters:
offset
- the heap byte offset at which the data begins.array
- The array of primitives to be extracted.- Throws:
FitsException
- if the operation failed
-
getFileOffset
public long getFileOffset()Description copied from interface:FitsElement
Returns the byte offset at which this element starts ina file. If the element was not obtained from an input, then 0 is returned.- Specified by:
getFileOffset
in interfaceFitsElement
- Returns:
- the byte at which this element begins. This is only available if the data is originally read from a random access medium. Otherwise 0 is returned.
-
getSize
public long getSize()Description copied from interface:FitsElement
Returns the size of this elements in the FITS representation. This may include padding if the element (such as a header or data segment) is expected to complete a FITS block of 2880 bytes.- Specified by:
getSize
in interfaceFitsElement
- Returns:
- The size of this element in bytes, or 0 if the element is empty or invalid.
-
read
Description copied from interface:FitsElement
Read a FITS element from the input, starting at the current position. Ater the read, the implementations should leave the input position aligned to the start of the next FITS block.- Specified by:
read
in interfaceFitsElement
- Parameters:
str
- The input data stream- Throws:
FitsException
- if the read was unsuccessful.
-
reset
public boolean reset()Description copied from interface:FitsElement
Reset the input stream to point to the beginning of this element- Specified by:
reset
in interfaceFitsElement
- Returns:
- True if the reset succeeded.
-
rewrite
Description copied from interface:FitsElement
Rewrite the contents of the element in place. The data must have been originally read from a random access device, and the size of the element may not have changed.- Specified by:
rewrite
in interfaceFitsElement
- Throws:
IOException
- if the rewrite was unsuccessful.FitsException
- if the rewrite was unsuccessful.
-
rewriteable
public boolean rewriteable()Description copied from interface:FitsElement
Checks if we can write this element back to its source. An element can only be written back if it is associated to a random accessible input and the current size FITS within the old block size.- Specified by:
rewriteable
in interfaceFitsElement
- Returns:
true
if this element can be rewritten?
-
size
public int size()Returns the current heap size.- Returns:
- the size of the heap in bytes
-
write
Description copied from interface:FitsElement
Writes the contents of the element to a data sink, adding padding as necessary if the element (such as a header or data segment) is expected to complete the FITS block of 2880 bytes.- Specified by:
write
in interfaceFitsElement
- Parameters:
str
- The data sink.- Throws:
FitsException
- if the write was unsuccessful.
-