Package nom.tam.util
Class FitsDecoder
java.lang.Object
nom.tam.util.InputDecoder
nom.tam.util.FitsDecoder
- Direct Known Subclasses:
BufferDecoder
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
ConstructorsModifierConstructorDescriptionprotected
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 TypeMethodDescriptionstatic final boolean
booleanFor
(int c) Gets theboolean
equivalent for a FITS byte value representing a logical value.static final Boolean
booleanObjectFor
(int c) Gets theboolean
equivalent for a FITS byte value representing a logical value.protected int
read
(boolean[] b, int start, int length) SeeArrayDataInput.read(boolean[], int, int)
for the general contract of this method.protected int
read
(char[] c, int start, int length) SeeArrayDataInput.read(char[], int, int)
for the general contract of this method.protected int
read
(double[] d, int start, int length) SeeArrayDataInput.read(double[], int, int)
for a contract of this method.protected int
read
(float[] f, int start, int length) SeeArrayDataInput.read(float[], int, int)
for a contract of this method.protected int
read
(int[] j, int start, int length) SeeArrayDataInput.read(int[], int, int)
for a contract of this method.protected int
read
(long[] l, int start, int length) SeeArrayDataInput.read(long[], int, int)
for a contract of this method.protected int
read
(short[] s, int start, int length) SeeArrayDataInput.read(short[], int, int)
for a contract of this method.protected int
SeeArrayDataInput.read(Boolean[], int, int)
for the general contract of this method.long
See the contract ofArrayDataInput.readLArray(Object)
.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
readByte()
Deprecated.(for internal use) Low-level reading/writing should be handled internally as arrays by this library only.protected char
readChar()
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
readInt()
Deprecated.(for internal use) Low-level reading/writing should be handled internally as arrays by this library only.protected long
readLong()
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
-
Constructor Details
-
FitsDecoder
protected FitsDecoder()Instantiates a new decoder of FITS binary data to Java arrays. To be used by subclass constructors only. -
FitsDecoder
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 theboolean
equivalent for a FITS byte value representing a logical value. This call does not supportnull
values, which are allowed by the FITS standard, but the similarbooleanObjectFor(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 astrue
, and will returnfalse
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, otherwisefalse
.- See Also:
-
booleanObjectFor
Gets theboolean
equivalent for a FITS byte value representing a logical value. This call supportsnull
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 astrue
, but 0 will map tonull
and everything else will returnfalse
.- 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, otherwisefalse
.- See Also:
-
readBoolean
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.(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.(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.(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.(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.(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.(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.(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.(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.(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.(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
SeeArrayDataInput.read(boolean[], int, int)
for the general contract of this method. In FITS,true
values are represented by the ASCII byte for 'T', whereasfalse
is represented by the ASCII byte for 'F'.- Parameters:
b
- an array of boolean values.start
- the buffer index at which to start reading datalength
- 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
SeeArrayDataInput.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', whilenull
values are represented by the value 0.- Parameters:
b
- an array of boolean values.start
- the buffer index at which to start reading datalength
- 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
SeeArrayDataInput.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 viaFitsFactory.setUseUnicodeChars(boolean)
.- Parameters:
c
- a character array.start
- the buffer index at which to start reading datalength
- 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
SeeArrayDataInput.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 datalength
- 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
SeeArrayDataInput.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 datalength
- 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
SeeArrayDataInput.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 datalength
- 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
SeeArrayDataInput.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 datalength
- 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
SeeArrayDataInput.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 datalength
- 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
Description copied from class:InputDecoder
See the contract ofArrayDataInput.readLArray(Object)
.- Specified by:
readArray
in classInputDecoder
- 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 inputIllegalArgumentException
- if the argument is not an array or if it contains an element that is not supported for decoding.- See Also:
-