1 package nom.tam.fits;
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.IOException;
35
36 import nom.tam.util.ArrayDataInput;
37
38 /**
39 * <p>
40 * A helper class to keep track of the number of physical cards for a logical card.
41 * </p>
42 *
43 * @deprecated (<i>for internal use</i>) This class should not have public visibility. And really, the counting should
44 * be completely internalized by {@link HeaderCard}. Perhaps remove in a future major release.
45 *
46 * @author Richard van Nieuwenhoven
47 */
48 @Deprecated
49 public class HeaderCardCountingArrayDataInput {
50
51 /**
52 * the input stream.
53 */
54 private final ArrayDataInput input;
55
56 /**
57 * the number of 80 byte cards read.
58 */
59 private int physicalCardsRead;
60
61 private int markedPhysicalCardsRead;
62
63 /**
64 * Creates a new instance of this class for counting the number of 80-character header records.
65 *
66 * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be removed
67 * entirely.
68 *
69 * @param input The input from which we read the header cards.
70 */
71 protected HeaderCardCountingArrayDataInput(ArrayDataInput input) {
72 this.input = input;
73 }
74
75 /**
76 * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be removed
77 * entirely.
78 *
79 * @return the number of cards realy read form the stream
80 */
81 protected int getPhysicalCardsRead() {
82 return physicalCardsRead;
83 }
84
85 /**
86 * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be removed
87 * entirely.
88 *
89 * @return the stream to read the cards from
90 */
91 protected ArrayDataInput in() {
92 return input;
93 }
94
95 /**
96 * report a readed card.
97 *
98 * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be removed
99 * entirely.
100 */
101 public void cardRead() {
102 physicalCardsRead++;
103 }
104
105 /**
106 * indicate whether mark/reset functionality is supported
107 *
108 * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be removed
109 * entirely.
110 *
111 * @return true iff mark/reset will work
112 */
113 public boolean markSupported() {
114 return input.markSupported();
115 }
116
117 /**
118 * mark the current position in the stream.
119 *
120 * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be
121 * removed entirely.
122 *
123 * @throws IOException if the underlaying stream does not allow the mark.
124 */
125 public void mark() throws IOException {
126 input.mark(HeaderCard.FITS_HEADER_CARD_SIZE);
127 markedPhysicalCardsRead = physicalCardsRead;
128 }
129
130 /**
131 * reset the stream th the last marked prosition.
132 *
133 * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be
134 * removed entirely.
135 *
136 * @throws IOException if the underlaying stream does not allow the mark.
137 */
138 public void reset() throws IOException {
139 input.reset();
140 physicalCardsRead = markedPhysicalCardsRead;
141 }
142
143 }