Package nom.tam.fits
Interface FitsElement
- All Known Implementing Classes:
AbstractTableData
,AsciiTable
,AsciiTableHDU
,BasicHDU
,BinaryTable
,BinaryTableHDU
,CompressedImageData
,CompressedImageHDU
,CompressedTableData
,CompressedTableHDU
,Data
,FitsHeap
,Header
,ImageData
,ImageHDU
,NullData
,NullDataHDU
,RandomGroupsData
,RandomGroupsHDU
,StreamingTileImageData
,TableHDU
,UndefinedData
,UndefinedHDU
public interface FitsElement
I/O interface for various FITS file elements.
-
Method Summary
Modifier and TypeMethodDescriptionlong
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 in) 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.void
write
(ArrayDataOutput out) 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
-
getFileOffset
long getFileOffset()Returns the byte offset at which this element starts ina file. If the element was not obtained from an input, then 0 is returned.- 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
long getSize()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.- Returns:
- The size of this element in bytes, or 0 if the element is empty or invalid.
-
read
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.- Parameters:
in
- The input data stream- Throws:
FitsException
- if the read was unsuccessful.IOException
- if the read was unsuccessful.
-
reset
boolean reset()Reset the input stream to point to the beginning of this element- Returns:
- True if the reset succeeded.
-
rewrite
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.- Throws:
FitsException
- if the rewrite was unsuccessful.IOException
- if the rewrite was unsuccessful.
-
rewriteable
boolean rewriteable()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.- Returns:
true
if this element can be rewritten?
-
write
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.- Parameters:
out
- The data sink.- Throws:
FitsException
- if the write was unsuccessful.
-