Package nom.tam.fits

Class FitsHeap

java.lang.Object
nom.tam.fits.FitsHeap
All Implemented Interfaces:
FitsElement

public class FitsHeap extends Object implements 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 Type
    Method
    Description
    void
    getData(int offset, Object array)
    Gets data for a Java array from the heap.
    long
    Returns the byte offset at which this element starts ina file.
    long
    Returns the size of this elements in the FITS representation.
    void
    Read a FITS element from the input, starting at the current position.
    boolean
    Reset the input stream to point to the beginning of this element
    void
    Rewrite the contents of the element in place.
    boolean
    Checks if we can write this element back to its source.
    int
    Returns the current heap size.
    void
    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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getData

      public void getData(int offset, Object array) throws FitsException
      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 interface FitsElement
      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 interface FitsElement
      Returns:
      The size of this element in bytes, or 0 if the element is empty or invalid.
    • read

      public void read(ArrayDataInput str) throws FitsException
      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 interface FitsElement
      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 interface FitsElement
      Returns:
      True if the reset succeeded.
    • rewrite

      public void rewrite() throws IOException, FitsException
      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 interface FitsElement
      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 interface FitsElement
      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

      public void write(ArrayDataOutput str) throws FitsException
      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 interface FitsElement
      Parameters:
      str - The data sink.
      Throws:
      FitsException - if the write was unsuccessful.