1 package nom.tam.fits;
2
3 import java.nio.Buffer;
4
5 /*-
6 * #%L
7 * nom.tam FITS library
8 * %%
9 * Copyright (C) 1996 - 2024 nom-tam-fits
10 * %%
11 * This is free and unencumbered software released into the public domain.
12 *
13 * Anyone is free to copy, modify, publish, use, compile, sell, or
14 * distribute this software, either in source code form or as a compiled
15 * binary, for any purpose, commercial or non-commercial, and by any
16 * means.
17 *
18 * In jurisdictions that recognize copyright laws, the author or authors
19 * of this software dedicate any and all copyright interest in the
20 * software to the public domain. We make this dedication for the benefit
21 * of the public at large and to the detriment of our heirs and
22 * successors. We intend this dedication to be an overt act of
23 * relinquishment in perpetuity of all present and future rights to this
24 * software under copyright law.
25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
29 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
30 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
31 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
32 * OTHER DEALINGS IN THE SOFTWARE.
33 * #L%
34 */
35
36 import nom.tam.fits.header.Bitpix;
37 import nom.tam.util.ArrayDataInput;
38 import nom.tam.util.ArrayDataOutput;
39
40 import static nom.tam.fits.header.Standard.EXTEND;
41 import static nom.tam.fits.header.Standard.GCOUNT;
42 import static nom.tam.fits.header.Standard.PCOUNT;
43
44 /**
45 * A subclass of <code>Data</code> containing no actual data. It wraps an underlying data of <code>null</code>.
46 *
47 * @author Attila Kovacs
48 *
49 * @since 1.18
50 *
51 * @see NullDataHDU
52 */
53 public final class NullData extends ImageData {
54
55 /**
56 * Instantiates an empty data object for a header-only HDU.
57 */
58 public NullData() {
59 }
60
61 @SuppressWarnings("deprecation")
62 @Override
63 protected void fillHeader(Header head) {
64 head.setSimple(true);
65 head.setBitpix(Bitpix.INTEGER);
66 head.setNaxes(0);
67
68 // Just in case!
69 head.addValue(EXTEND, true);
70 head.addValue(GCOUNT, 1);
71 head.addValue(PCOUNT, 0);
72 }
73
74 @Override
75 protected void loadData(ArrayDataInput in) {
76 return;
77 }
78
79 @Override
80 protected Void getCurrentData() {
81 return null;
82 }
83
84 @Override
85 protected long getTrueSize() {
86 return 0;
87 }
88
89 @Override
90 public void read(ArrayDataInput in) {
91 setFileOffset(in);
92 }
93
94 @Override
95 public void write(ArrayDataOutput o) {
96 }
97
98 @Override
99 public void setBuffer(Buffer data) {
100 // Nothing to do.
101 }
102
103 }