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
Interface for reading array data from inputs.
-
Field Summary
Fields inherited from interface nom.tam.util.FitsIO
BITS_OF_1_BYTE, BITS_OF_2_BYTES, BITS_OF_3_BYTES, BITS_OF_4_BYTES, BITS_OF_5_BYTES, BITS_OF_6_BYTES, BITS_OF_7_BYTES, BYTE_1_OF_LONG_MASK, BYTE_2_OF_LONG_MASK, BYTE_3_OF_LONG_MASK, BYTE_4_OF_LONG_MASK, BYTE_MASK, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_FLOAT, BYTES_IN_INTEGER, BYTES_IN_LONG, BYTES_IN_SHORT, DEFAULT_BUFFER_SIZE, HIGH_INTEGER_MASK, INTEGER_MASK, SHORT_MASK, SHORT_OF_LONG_MASK
-
Method Summary
Modifier and TypeMethodDescriptionvoid
mark
(int readlimit) See the general contract of themark
method ofInputStream
.default boolean
See the general contract of themarkSupported
method ofInputStream
.default int
read
(boolean[] buf) Read an array of boolean's.int
read
(boolean[] buf, int offset, int size) Read a segment of an array of boolean's.int
read
(byte[] buf) Read an array of byte's.default int
read
(char[] buf) Read an array of char's.int
read
(char[] buf, int offset, int size) Read a segment of an array of char's.default int
read
(double[] buf) Read an array of double's.int
read
(double[] buf, int offset, int size) Read a segment of an array of double's.default int
read
(float[] buf) Read an array of float's.int
read
(float[] buf, int offset, int size) Read a segment of an array of float's.default int
read
(int[] buf) Read an array of int's.int
read
(int[] buf, int offset, int size) Read a segment of an array of int's.default int
read
(long[] buf) Read a segment of an array of long's.int
read
(long[] buf, int offset, int size) Read a segment of an array of long's.default int
read
(short[] buf) Read an array of short's.int
read
(short[] buf, int offset, int size) Read a segment of an array of short's.default int
Read an array of booleans, possibly including legalnull
values.default int
Reads into an array of booleans, possibly including legalnull
values.default int
Deprecated.default void
Reads a Java array from the input, populating all elements, or else throwing andEOFException
.void
readFully
(byte[] b, int off, int len) default void
LikereadArrayFully(Object)
but strictly for numerical types only.long
readLArray
(Object o) Reads a Java array from the input, translating it from its binary representation to Java data format.void
reset()
See the general contract of thereset
method ofInputStream
.long
skip
(long distance) Skip the number of bytes.default void
skipAllBytes
(int toSkip) Deprecated.This call is handled byskipAllBytes(long)
, without the need for a separate implementation.void
skipAllBytes
(long toSkip) Skips a number of bytes from the input.Methods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
Methods inherited from interface nom.tam.util.InputReader
read, read
-
Method Details
-
mark
See the general contract of themark
method ofInputStream
.- 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 themarkSupported
method ofInputStream
.- Returns:
- true if this stream instance supports the mark and reset methods; false otherwise.
-
read
Read an array of byte's. The call generally follows the contract ofInputReader.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
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
Read a segment of an array of boolean's.- Parameters:
buf
- array of boolean's.offset
- start index in the arraysize
- 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
Read an array of booleans, possibly including legalnull
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
Reads into an array of booleans, possibly including legalnull
values. The method has a default implementation, callsDataInput.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 fornull
values.- Parameters:
buf
- array of boolean's.offset
- start index in the arraysize
- 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
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
Read a segment of an array of char's.- Parameters:
buf
- array of char's.offset
- start index in the arraysize
- 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
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
Read a segment of an array of double's.- Parameters:
buf
- array of double's.offset
- start index in the arraysize
- 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
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
Read a segment of an array of float's.- Parameters:
buf
- array of float's.offset
- start index in the arraysize
- 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
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
Read a segment of an array of int's.- Parameters:
buf
- array of int's.offset
- start index in the arraysize
- 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
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
Read a segment of an array of long's.- Parameters:
buf
- array of long's.offset
- start index in the arraysize
- 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
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
Read a segment of an array of short's.- Parameters:
buf
- array of short's.offset
- start index in the arraysize
- 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 default int readArray(Object o) throws EOFException, IOException, IllegalArgumentException Deprecated.UsereadLArray(Object)
instead.- Parameters:
o
- a Java array object, including heterogeneous arrays of arrays. Ifnull
, 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 inputIllegalArgumentException
- 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. Ifnull
, 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 inputIllegalArgumentException
- 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
Reads a Java array from the input, populating all elements, or else throwing andEOFException
.- Parameters:
o
- a Java array object, including heterogeneous arrays of arrays. Ifnull
, 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
LikereadArrayFully(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
See the general contract of thereset
method ofInputStream
.If
markpos
is-1
(no mark has been set or the mark has been invalidated), anIOException
is thrown. Otherwise,pos
is set equal tomarkpos
.- Throws:
IOException
- if this stream has not been marked or, if the mark has been invalidated, or the stream has been closed by invoking itsFitsIO.close()
method, or an I/O error occurs.- See Also:
-
skip
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
Skips a number of bytes from the input. This differs from theskip(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.This call is handled byskipAllBytes(long)
, without the need for a separate implementation. Skips a number of bytes from the input. SeeskipAllBytes(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
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readLArray(Object)
instead.