Package nom.tam.util

Interface ArrayDataInput

All Superinterfaces:
AutoCloseable, Closeable, DataInput, FitsIO, InputReader
All Known Subinterfaces:
RandomAccess
All Known Implementing Classes:
BufferedDataInputStream, BufferedFile, FitsFile, FitsInputStream

public interface ArrayDataInput extends InputReader, DataInput, FitsIO
Interface for reading array data from inputs.
  • Method Details

    • mark

      void mark(int readlimit) throws IOException
      See the general contract of the mark method of InputStream.
      Parameters:
      readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid.
      Throws:
      IOException - if the operation failed
      See Also:
    • markSupported

      default boolean markSupported()
      See the general contract of the markSupported method of InputStream.
      Returns:
      true if this stream instance supports the mark and reset methods; false otherwise.
    • read

      int read(byte[] buf) throws EOFException, IOException
      Read an array of byte's. The call generally follows the contract of InputReader.read(byte[], int, int), for the full length of the array, starting from the first element (index 0).
      Parameters:
      buf - array of byte's.
      Returns:
      number of bytes read, or -1 if at the end of the file.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
      See Also:
    • read

      default int read(boolean[] buf) throws EOFException, IOException
      Read an array of boolean's.
      Parameters:
      buf - array of boolean's.
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      int read(boolean[] buf, int offset, int size) throws EOFException, IOException
      Read a segment of an array of boolean's.
      Parameters:
      buf - array of boolean's.
      offset - start index in the array
      size - number of array elements to read
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      default int read(Boolean[] buf) throws EOFException, IOException
      Read an array of booleans, possibly including legal null values.
      Parameters:
      buf - array of boolean's.
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
      Since:
      1.16
    • read

      default int read(Boolean[] buf, int offset, int size) throws EOFException, IOException
      Reads into an array of booleans, possibly including legal null values. The method has a default implementation, calls DataInput.readBoolean() element by element. Classes that implement this interface might want to replace that with a more efficient block read implementation and/or to add the desired translation for null values.
      Parameters:
      buf - array of boolean's.
      offset - start index in the array
      size - number of array elements to read
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
      Since:
      1.16
    • read

      default int read(char[] buf) throws EOFException, IOException
      Read an array of char's.
      Parameters:
      buf - array of char's.
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      int read(char[] buf, int offset, int size) throws EOFException, IOException
      Read a segment of an array of char's.
      Parameters:
      buf - array of char's.
      offset - start index in the array
      size - number of array elements to read
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      default int read(double[] buf) throws EOFException, IOException
      Read an array of double's.
      Parameters:
      buf - array of double's.
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      int read(double[] buf, int offset, int size) throws EOFException, IOException
      Read a segment of an array of double's.
      Parameters:
      buf - array of double's.
      offset - start index in the array
      size - number of array elements to read
      Returns:
      number of bytes read, or -1 if at the end of file/stream
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      default int read(float[] buf) throws EOFException, IOException
      Read an array of float's.
      Parameters:
      buf - array of float's.
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      int read(float[] buf, int offset, int size) throws EOFException, IOException
      Read a segment of an array of float's.
      Parameters:
      buf - array of float's.
      offset - start index in the array
      size - number of array elements to read
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      default int read(int[] buf) throws EOFException, IOException
      Read an array of int's.
      Parameters:
      buf - array of int's.
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      int read(int[] buf, int offset, int size) throws EOFException, IOException
      Read a segment of an array of int's.
      Parameters:
      buf - array of int's.
      offset - start index in the array
      size - number of array elements to read
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      default int read(long[] buf) throws EOFException, IOException
      Read a segment of an array of long's.
      Parameters:
      buf - array of long's.
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      int read(long[] buf, int offset, int size) throws EOFException, IOException
      Read a segment of an array of long's.
      Parameters:
      buf - array of long's.
      offset - start index in the array
      size - number of array elements to read
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      default int read(short[] buf) throws EOFException, IOException
      Read an array of short's.
      Parameters:
      buf - array of short's.
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • read

      int read(short[] buf, int offset, int size) throws EOFException, IOException
      Read a segment of an array of short's.
      Parameters:
      buf - array of short's.
      offset - start index in the array
      size - number of array elements to read
      Returns:
      number of bytes read.
      Throws:
      EOFException - if already at the end of file.
      IOException - if one of the underlying read operations failed
    • readArray

      Deprecated.
      Use readLArray(Object) instead.
      Parameters:
      o - a Java array object, including heterogeneous arrays of arrays. If null, nothing will be read from the output.
      Returns:
      the number of bytes read from the input.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error, other than the end-of-file, while reading from the input
      IllegalArgumentException - if the supplied object is not a Java array or if it contains Java types that are not supported by the decoder.
    • readLArray

      Reads a Java array from the input, translating it from its binary representation to Java data format. The argument may be a generic Java array, including multi-dimensional arrays and heterogeneous arrays of arrays. The implementation may not populate the supplied object fully. The caller may use the return value to check against the expected number of bytes to determine whether or not the argument was fully poupulated or not.
      Parameters:
      o - a Java array object, including heterogeneous arrays of arrays. If null, nothing will be read from the output.
      Returns:
      the number of bytes read from the input.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error, other than the end-of-file, while reading from the input
      IllegalArgumentException - if the supplied object is not a Java array or if it contains Java types that are not supported by the decoder.
      See Also:
    • readArrayFully

      default void readArrayFully(Object o) throws EOFException, IOException, IllegalArgumentException
      Reads a Java array from the input, populating all elements, or else throwing and EOFException.
      Parameters:
      o - a Java array object, including heterogeneous arrays of arrays. If null, nothing will be read from the output.
      Throws:
      EOFException - if already at the end of file.
      IOException - if there was an IO error.
      IllegalArgumentException - if the supplied object is not a Java array or if it contains Java types that are not supported by the decoder.
      Since:
      1.16
      See Also:
    • readImage

      default void readImage(Object o) throws IOException, IllegalArgumentException
      Like readArrayFully(Object) but strictly for numerical types only.
      Parameters:
      o - An any-dimensional array containing only numerical types
      Throws:
      EOFException - if already at the end of file.
      IllegalArgumentException - if the argument is not an array or if it contains an element that is not supported.
      IOException - if there was an IO error, uncluding end-of-file (EOFException, before all components of the supplied array were populated from the input.
      Since:
      1.18
      See Also:
    • reset

      void reset() throws IOException
      See the general contract of the reset method of InputStream.

      If markpos is -1 (no mark has been set or the mark has been invalidated), an IOException is thrown. Otherwise, pos is set equal to markpos.

      Throws:
      IOException - if this stream has not been marked or, if the mark has been invalidated, or the stream has been closed by invoking its FitsIO.close() method, or an I/O error occurs.
      See Also:
    • skip

      long skip(long distance) throws EOFException, IOException
      Skip the number of bytes. This differs from the skip method in that it will throw an EOF if a forward skip cannot be fully accomplished... (However that isn't supposed to happen with a random access file, so there is probably no operational difference).
      Parameters:
      distance - the number of bytes to skip. Negative arguments are generally allowed, and subclass implementations may support it or else return 0 when a negative distance is specified.
      Returns:
      the number of bytes actually skipped
      Throws:
      EOFException - if the end (or beginning) of the stream was reached before skipping the required number of bytes. This does not happen typically with forward skips on random access files, where positioning beyond the EOF is generally allowed for writing.
      IOException - if the underlying stream failed
      See Also:
    • skipAllBytes

      void skipAllBytes(long toSkip) throws EOFException, IOException
      Skips a number of bytes from the input. This differs from the skip(long) method in that it will throw an EOF if the skip cannot be fully accomplished as requested...
      Parameters:
      toSkip - the number of bytes to skip forward. Subclass implementations may support negative valued arguments for a backward skip also.
      Throws:
      EOFException - if the end (or beginning) of the stream was reached before skipping the required number of bytes. This does not happen typically with forward skips on random access files, where positioning beyond the EOF is generally allowed for writing.
      IOException - if there was an underlying IO failure.
      See Also:
    • skipAllBytes

      @Deprecated default void skipAllBytes(int toSkip) throws EOFException, IOException
      Deprecated.
      This call is handled by skipAllBytes(long), without the need for a separate implementation. Skips a number of bytes from the input. See skipAllBytes(long).
      Parameters:
      toSkip - the number of bytes to skip forward. Subclass implementations may support negative valued arguments for a backward skip also.
      Throws:
      EOFException - if the end (or beginning) of the stream was reached before skipping the required number of bytes. This does not happen typically with forward skips on random access files, where positioning beyond the EOF is generally allowed for writing.
      IOException - if there was an underlying IO failure.
    • readFully

      void readFully(byte[] b, int off, int len) throws IOException
      Specified by:
      readFully in interface DataInput
      Throws:
      IOException