View Javadoc
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      @Deprecated
72      protected HeaderCardCountingArrayDataInput(ArrayDataInput input) {
73          this.input = input;
74      }
75  
76      /**
77       * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be removed
78       *                 entirely.
79       * 
80       * @return     the number of cards realy read form the stream
81       */
82      @Deprecated
83      protected int getPhysicalCardsRead() {
84          return physicalCardsRead;
85      }
86  
87      /**
88       * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be removed
89       *                 entirely.
90       * 
91       * @return     the stream to read the cards from
92       */
93      @Deprecated
94      protected ArrayDataInput in() {
95          return input;
96      }
97  
98      /**
99       * report a readed card.
100      * 
101      * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be removed
102      *                 entirely.
103      */
104     @Deprecated
105     public void cardRead() {
106         physicalCardsRead++;
107     }
108 
109     /**
110      * indicate whether mark/reset functionality is supported
111      *
112      * @deprecated (<i>for internal use</i>) Visibility will be reduced to the package level, or will be removed
113      *                 entirely.
114      * 
115      * @return     true iff mark/reset will work
116      */
117     @Deprecated
118     public boolean markSupported() {
119         return input.markSupported();
120     }
121 
122     /**
123      * mark the current position in the stream.
124      * 
125      * @deprecated             (<i>for internal use</i>) Visibility will be reduced to the package level, or will be
126      *                             removed entirely.
127      *
128      * @throws     IOException if the underlaying stream does not allow the mark.
129      */
130     @Deprecated
131     public void mark() throws IOException {
132         input.mark(HeaderCard.FITS_HEADER_CARD_SIZE);
133         markedPhysicalCardsRead = physicalCardsRead;
134     }
135 
136     /**
137      * reset the stream th the last marked prosition.
138      * 
139      * @deprecated             (<i>for internal use</i>) Visibility will be reduced to the package level, or will be
140      *                             removed entirely.
141      * 
142      * @throws     IOException if the underlaying stream does not allow the mark.
143      */
144     @Deprecated
145     public void reset() throws IOException {
146         input.reset();
147         physicalCardsRead = markedPhysicalCardsRead;
148     }
149 
150 }