Package nom.tam.util

Class FitsDecoder

Direct Known Subclasses:
BufferDecoder

public class FitsDecoder extends InputDecoder
Decodes FITS-formatted binary data into Java arrays (primarily for internal use)
Since:
1.16
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class nom.tam.util.InputDecoder

    InputDecoder.InputBuffer
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Instantiates a new decoder of FITS binary data to Java arrays.
     
    Instantiates a new FITS binary data decoder for converting FITS data representations into Java arrays.
  • Method Summary

    Modifier and Type
    Method
    Description
    static final boolean
    booleanFor(int c)
    Gets the boolean equivalent for a FITS byte value representing a logical value.
    static final Boolean
    Gets the boolean equivalent for a FITS byte value representing a logical value.
    protected int
    read(boolean[] b, int start, int length)
    See ArrayDataInput.read(boolean[], int, int) for the general contract of this method.
    protected int
    read(char[] c, int start, int length)
    See ArrayDataInput.read(char[], int, int) for the general contract of this method.
    protected int
    read(double[] d, int start, int length)
    See ArrayDataInput.read(double[], int, int) for a contract of this method.
    protected int
    read(float[] f, int start, int length)
    See ArrayDataInput.read(float[], int, int) for a contract of this method.
    protected int
    read(int[] j, int start, int length)
    See ArrayDataInput.read(int[], int, int) for a contract of this method.
    protected int
    read(long[] l, int start, int length)
    See ArrayDataInput.read(long[], int, int) for a contract of this method.
    protected int
    read(short[] s, int start, int length)
    See ArrayDataInput.read(short[], int, int) for a contract of this method.
    protected int
    read(Boolean[] b, int start, int length)
    See ArrayDataInput.read(Boolean[], int, int) for the general contract of this method.
    long
    protected String
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected boolean
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected final byte
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected char
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected double
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected float
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected int
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected long
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected final short
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected int
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
    protected int
    Deprecated.
    (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.

    Methods inherited from class nom.tam.util.InputDecoder

    getInputBuffer, read, read, readArrayFully, readFully, readImage, setInput

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FitsDecoder

      protected FitsDecoder()
      Instantiates a new decoder of FITS binary data to Java arrays. To be used by subclass constructors only.
    • FitsDecoder

      public FitsDecoder(InputReader i)
      Instantiates a new FITS binary data decoder for converting FITS data representations into Java arrays.
      Parameters:
      i - the FITS input.
  • Method Details

    • booleanFor

      public static final boolean booleanFor(int c)
      Gets the boolean equivalent for a FITS byte value representing a logical value. This call does not support null values, which are allowed by the FITS standard, but the similar booleanObjectFor(int) does. FITS defines 'T' as true, 'F' as false, and 0 as null. However, prior versions of this library have used the value 1 for true, and 0 for false. Therefore, this implementation will recognise both 'T' and 1 as true, and will return false for all other byte values.
      Parameters:
      c - The FITS byte that defines a boolean value
      Returns:
      true if and only if the byte is the ASCII character 'T' or has the value of 1, otherwise false.
      See Also:
    • booleanObjectFor

      public static final Boolean booleanObjectFor(int c)
      Gets the boolean equivalent for a FITS byte value representing a logical value. This call supports null values, which are allowed by the FITS standard. FITS defines 'T' as true, 'F' as false, and 0 as null. Prior versions of this library have used the value 1 for true, and 0 for false. Therefore, this implementation will recognise both 'T' and 1 as true, but 0 will map to null and everything else will return false.
      Parameters:
      c - The FITS byte that defines a boolean value
      Returns:
      true if and only if the byte is the ASCII character 'T' or has the value of 1, null it the byte is 0, otherwise false.
      See Also:
    • readBoolean

      @Deprecated protected boolean readBoolean() throws EOFException, IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next boolean value from the input.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error reading from the input.
    • readChar

      @Deprecated protected char readChar() throws EOFException, IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next character value from the input.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error reading from the input.
    • readByte

      @Deprecated protected final byte readByte() throws IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next byte the input.
      Throws:
      IOException - if there was an IO error reading from the input.
    • readUnsignedByte

      @Deprecated protected int readUnsignedByte() throws IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next unsigned byte from the input, or -1 if there is no more bytes available.
      Throws:
      IOException - if there was an IO error reading from the input, other than the end-of-file.
    • readShort

      @Deprecated protected final short readShort() throws EOFException, IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next 16-bit integer value from the input.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error reading from the input.
    • readUnsignedShort

      @Deprecated protected int readUnsignedShort() throws IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next unsigned 16-bit integer value from the input, or -1 if reached the end of stream
      Throws:
      IOException - if there was an IO error reading from the input.
    • readInt

      @Deprecated protected int readInt() throws EOFException, IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next 32-bit integer value from the input.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error reading from the input.
    • readLong

      @Deprecated protected long readLong() throws EOFException, IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next 64-bit integer value from the input.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error reading from the input.
    • readFloat

      @Deprecated protected float readFloat() throws EOFException, IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next single-precision (32-bit) floating point value from the input.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error reading from the input.
    • readDouble

      @Deprecated protected double readDouble() throws EOFException, IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next double-precision (64-bit) floating point value from the input.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error reading from the input.
    • readAsciiLine

      @Deprecated protected String readAsciiLine() throws EOFException, IOException
      Deprecated.
      (for internal use) Low-level reading/writing should be handled internally as arrays by this library only.
      Returns:
      the next line of 1-byte ASCII characters, terminated by a LF or EOF.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error reading from the input.
    • read

      protected int read(boolean[] b, int start, int length) throws EOFException, IOException
      See ArrayDataInput.read(boolean[], int, int) for the general contract of this method. In FITS, true values are represented by the ASCII byte for 'T', whereas false is represented by the ASCII byte for 'F'.
      Parameters:
      b - an array of boolean values.
      start - the buffer index at which to start reading data
      length - the total number of elements to read.
      Returns:
      the number of bytes successfully read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error before, before requested number of bytes could be read
    • read

      protected int read(Boolean[] b, int start, int length) throws EOFException, IOException
      See ArrayDataInput.read(Boolean[], int, int) for the general contract of this method. In FITS, true values are represented by the ASCII byte for 'T', false is represented by the ASCII byte for 'F', while null values are represented by the value 0.
      Parameters:
      b - an array of boolean values.
      start - the buffer index at which to start reading data
      length - the total number of elements to read.
      Returns:
      the number of bytes successfully read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error before, before requested number of bytes could be read
    • read

      protected int read(char[] c, int start, int length) throws EOFException, IOException
      See ArrayDataInput.read(char[], int, int) for the general contract of this method. In FITS characters are usually represented as 1-byte ASCII, not as the 2-byte Java types. However, previous implementations if this library have erroneously written 2-byte characters into the FITS. For compatibility both the FITS standard -1-byte ASCII and the old 2-byte behaviour are supported, and can be selected via FitsFactory.setUseUnicodeChars(boolean).
      Parameters:
      c - a character array.
      start - the buffer index at which to start reading data
      length - the total number of elements to read.
      Returns:
      the number of bytes successfully read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error before, before requested number of bytes could be read
      See Also:
    • read

      protected int read(short[] s, int start, int length) throws EOFException, IOException
      See ArrayDataInput.read(short[], int, int) for a contract of this method.
      Parameters:
      s - an array of 16-bit integer values.
      start - the buffer index at which to start reading data
      length - the total number of elements to read.
      Returns:
      the number of bytes successfully read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error before, before requested number of bytes could be read
    • read

      protected int read(int[] j, int start, int length) throws EOFException, IOException
      See ArrayDataInput.read(int[], int, int) for a contract of this method.
      Parameters:
      j - an array of 32-bit integer values.
      start - the buffer index at which to start reading data
      length - the total number of elements to read.
      Returns:
      the number of bytes successfully read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error before, before requested number of bytes could be read
    • read

      protected int read(long[] l, int start, int length) throws EOFException, IOException
      See ArrayDataInput.read(long[], int, int) for a contract of this method.
      Parameters:
      l - an array of 64-bit integer values.
      start - the buffer index at which to start reading data
      length - the total number of elements to read.
      Returns:
      the number of bytes successfully read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error before, before requested number of bytes could be read
    • read

      protected int read(float[] f, int start, int length) throws EOFException, IOException
      See ArrayDataInput.read(float[], int, int) for a contract of this method.
      Parameters:
      f - an array of single-precision (32-bit) floating point values.
      start - the buffer index at which to start reading data
      length - the total number of elements to read.
      Returns:
      the number of bytes successfully read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error before, before requested number of bytes could be read
    • read

      protected int read(double[] d, int start, int length) throws EOFException, IOException
      See ArrayDataInput.read(double[], int, int) for a contract of this method.
      Parameters:
      d - an array of double-precision (64-bit) floating point values.
      start - the buffer index at which to start reading data
      length - the total number of elements to read.
      Returns:
      the number of bytes successfully read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error before, before requested number of bytes could be read
    • readArray

      public long readArray(Object o) throws IOException, IllegalArgumentException
      Description copied from class: InputDecoder
      Specified by:
      readArray in class InputDecoder
      Parameters:
      o - an array, to be populated
      Returns:
      the actual number of bytes read from the input, or -1 if already at the end-of-file.
      Throws:
      IOException - if there was an IO error reading from the input
      IllegalArgumentException - if the argument is not an array or if it contains an element that is not supported for decoding.
      See Also: