1 package nom.tam.util;
2
3 /*
4 * #%L
5 * nom.tam FITS library
6 * %%
7 * Copyright (C) 1996 - 2024 nom-tam-fits
8 * %%
9 * This is free and unencumbered software released into the public domain.
10 *
11 * Anyone is free to copy, modify, publish, use, compile, sell, or
12 * distribute this software, either in source code form or as a compiled
13 * binary, for any purpose, commercial or non-commercial, and by any
14 * means.
15 *
16 * In jurisdictions that recognize copyright laws, the author or authors
17 * of this software dedicate any and all copyright interest in the
18 * software to the public domain. We make this dedication for the benefit
19 * of the public at large and to the detriment of our heirs and
20 * successors. We intend this dedication to be an overt act of
21 * relinquishment in perpetuity of all present and future rights to this
22 * software under copyright law.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
28 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30 * OTHER DEALINGS IN THE SOFTWARE.
31 * #L%
32 */
33
34 import java.io.Closeable;
35 import java.io.IOException;
36
37 import nom.tam.fits.FitsFactory;
38
39 /**
40 * Base interface for reading and writing FITS. It defines the necessary constants common for all reader and writers.
41 *
42 * @author ritchie
43 */
44 public interface FitsIO extends Closeable {
45
46 // AK: Since FITS has a fixed block size, it makes sense to align buffering to that.
47 /**
48 * default buffer size to use unless specified otherwise.
49 */
50 int DEFAULT_BUFFER_SIZE = 8 * FitsFactory.FITS_BLOCK_SIZE;
51
52 /**
53 * number of bits in one byte.
54 */
55 int BITS_OF_1_BYTE = 8;
56
57 /**
58 * number of bits in two byte.
59 */
60 int BITS_OF_2_BYTES = 16;
61
62 /**
63 * number of bits in three byte.
64 */
65 int BITS_OF_3_BYTES = 24;
66
67 /**
68 * number of bits in four byte.
69 */
70 int BITS_OF_4_BYTES = 32;
71
72 /**
73 * number of bits in five byte.
74 */
75 int BITS_OF_5_BYTES = 40;
76
77 /**
78 * number of bits in six byte.
79 */
80 int BITS_OF_6_BYTES = 48;
81
82 /**
83 * number of bits in seven byte.
84 */
85 int BITS_OF_7_BYTES = 56;
86
87 /**
88 * number of bytes occupied by a boolean.
89 */
90 int BYTES_IN_BOOLEAN = 1;
91
92 /**
93 * number of bytes occupied by a byte.
94 */
95 int BYTES_IN_BYTE = 1;
96
97 /**
98 * number of bytes occupied by a char.
99 */
100 int BYTES_IN_CHAR = 2;
101
102 /**
103 * number of bytes occupied by a short.
104 */
105 int BYTES_IN_SHORT = 2;
106
107 /**
108 * number of bytes occupied by a integer.
109 */
110 int BYTES_IN_INTEGER = 4;
111
112 /**
113 * number of bytes occupied by a long.
114 */
115 int BYTES_IN_LONG = 8;
116
117 /**
118 * number of bytes occupied by a float.
119 */
120 int BYTES_IN_FLOAT = 4;
121
122 /**
123 * number of bytes occupied by a double.
124 */
125 int BYTES_IN_DOUBLE = 8;
126
127 /**
128 * bit mask to get the lowest byte from an integer. Or to get an unsigned integer from a byte.
129 */
130 int BYTE_MASK = 0xFF;
131
132 /**
133 * bit mask to get the lowest short of a integer.
134 */
135 int SHORT_MASK = 0xffff;
136
137 /**
138 * bit mask to get the lowest short of a long.
139 */
140 long SHORT_OF_LONG_MASK = 0xffffL;
141
142 /**
143 * bit mask to get the lowest byte of a long.
144 */
145 long BYTE_1_OF_LONG_MASK = 0xffL;
146
147 /**
148 * bit mask to get the second lowest byte of a long.
149 */
150 long BYTE_2_OF_LONG_MASK = 0xff00L;
151
152 /**
153 * bit mask to get the third lowest byte of a long.
154 */
155 long BYTE_3_OF_LONG_MASK = 0xff0000L;
156
157 /**
158 * bit mask to get the fourth lowest byte of a long.
159 */
160 long BYTE_4_OF_LONG_MASK = 0xff000000L;
161
162 /**
163 * bit mask to get the lowest integer from an long.
164 */
165 long INTEGER_MASK = 0x00000000ffffffffL;
166
167 /**
168 * bit mask to get the highest integer from an long.
169 */
170 long HIGH_INTEGER_MASK = 0xFFFFFFFF00000000L;
171
172 @Override
173 void close() throws IOException;
174 }