View Javadoc
1   package nom.tam.fits.compression.provider.param.api;
2   
3   import nom.tam.fits.Header;
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.HeaderCard;
37  import nom.tam.fits.HeaderCardException;
38  import nom.tam.fits.header.IFitsHeader;
39  
40  /**
41   * <p>
42   * (<i>for internal use</i>) Interface for accessing FITS header values with runtime exceptions only. Regular header
43   * access throws {@link HeaderCardException}s, which are hard exceptions. They really should have been softer runtime
44   * exceptions from the start, but unfortunately that was choice this library made a very long time ago, and we therefore
45   * stick to it, at least until the next major code revision (major version 2 at the earliest). So this class provides an
46   * alternative access to headers converting any <code>HeaderCardException</code>s to {@link IllegalArgumentException}.
47   * </p>
48   * <p>
49   * This is really just a rusty rail implementation, and rather incopmlete at it too. It has very limited support for
50   * header access, geared very specifically towards supporting the compression classes of this library, and not mean for
51   * use beyond.
52   * </p>
53   * 
54   * @see        Header
55   * 
56   * @deprecated This internal interface serves no purpose since 1.19. Will remove in some future. Prior to 1.19
57   *                 {@link Header} threw hard {@link HeaderCardException}, and this class was added so we can convert
58   *                 these into soft {@link IllegalArgumentException} instead. However, now that we demoted
59   *                 <code>HeaderCardException</code> to be soft exceptions itself, there is no reason to convert. It just
60   *                 adds confusion.
61   */
62  @Deprecated
63  public interface IHeaderAccess {
64  
65      /**
66       * Returns the header that this class is providing access to.
67       * 
68       * @return the Header that we access through this class
69       * 
70       * @since  1.19
71       */
72      @Deprecated
73      Header getHeader();
74  
75      /**
76       * Sets a new integer value for the specified FITS keyword, adding it to the FITS header if necessary.
77       * 
78       * @param      key                      the standard or conventional FITS header keyword
79       * @param      value                    the integer value to assign to the keyword
80       * 
81       * @throws     IllegalArgumentException if the value could not be set as requested.
82       * 
83       * @deprecated                          Just add values to the header directly
84       */
85      @Deprecated
86      default void addValue(IFitsHeader key, int value) throws IllegalArgumentException {
87          getHeader().addValue(key, value);
88      }
89  
90      /**
91       * Sets a new string value for the specified FITS keyword, adding it to the FITS header if necessary.
92       * 
93       * @param      key                      the standard or conventional FITS header keyword
94       * @param      value                    the string value to assign to the keyword
95       * 
96       * @throws     IllegalArgumentException if the value could not be set as requested.
97       * 
98       * @deprecated                          Just add values to the header directly
99       */
100     @Deprecated
101     default void addValue(IFitsHeader key, String value) throws IllegalArgumentException {
102         getHeader().addValue(key, value);
103     }
104 
105     /**
106      * Returns the FITS header card for the given FITS keyword. It does not set a mark in the header for new additions,
107      * making it more similar to {@link Header#getCard(IFitsHeader)}.
108      * 
109      * @param      key the standard or conventional FITS header keyword
110      * 
111      * @return         the matching FITS header card, or <code>null</code> if there is no such card within out grasp.
112      * 
113      * @deprecated     Use {@link Header#getCard(IFitsHeader)} instead.
114      */
115     @Deprecated
116     default HeaderCard findCard(IFitsHeader key) {
117         return getHeader().findCard(key);
118     }
119 
120     /**
121      * Returns the FITS header card for the given FITS keyword. It does not set a mark in the header for new additions,
122      * making it more similar to {@link Header#getCard(String)}.
123      * 
124      * @param      key the FITS header keyword
125      * 
126      * @return         the matching FITS header card, or <code>null</code> if there is no such card within out grasp.
127      * 
128      * @deprecated     Use {@link Header#getCard(String)} instead.
129      */
130     @Deprecated
131     default HeaderCard findCard(String key) {
132         return getHeader().findCard(key);
133     }
134 
135 }