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 public interface IHeaderAccess { 63 64 /** 65 * Returns the header that this class is providing access to. 66 * 67 * @return the Header that we access through this class 68 * 69 * @since 1.19 70 */ 71 Header getHeader(); 72 73 /** 74 * Sets a new integer value for the specified FITS keyword, adding it to the FITS header if necessary. 75 * 76 * @param key the standard or conventional FITS header keyword 77 * @param value the integer value to assign to the keyword 78 * 79 * @throws IllegalArgumentException if the value could not be set as requested. 80 * 81 * @deprecated Just add values to the header directly 82 */ 83 default void addValue(IFitsHeader key, int value) throws IllegalArgumentException { 84 getHeader().addValue(key, value); 85 } 86 87 /** 88 * Sets a new string value for the specified FITS keyword, adding it to the FITS header if necessary. 89 * 90 * @param key the standard or conventional FITS header keyword 91 * @param value the string value to assign to the keyword 92 * 93 * @throws IllegalArgumentException if the value could not be set as requested. 94 * 95 * @deprecated Just add values to the header directly 96 */ 97 default void addValue(IFitsHeader key, String value) throws IllegalArgumentException { 98 getHeader().addValue(key, value); 99 } 100 101 /** 102 * Returns the FITS header card for the given FITS keyword. It does not set a mark in the header for new additions, 103 * making it more similar to {@link Header#getCard(IFitsHeader)}. 104 * 105 * @param key the standard or conventional FITS header keyword 106 * 107 * @return the matching FITS header card, or <code>null</code> if there is no such card within out grasp. 108 * 109 * @deprecated Use {@link Header#getCard(IFitsHeader)} instead. 110 */ 111 default HeaderCard findCard(IFitsHeader key) { 112 return getHeader().findCard(key); 113 } 114 115 /** 116 * Returns the FITS header card for the given FITS keyword. It does not set a mark in the header for new additions, 117 * making it more similar to {@link Header#getCard(String)}. 118 * 119 * @param key the FITS header keyword 120 * 121 * @return the matching FITS header card, or <code>null</code> if there is no such card within out grasp. 122 * 123 * @deprecated Use {@link Header#getCard(String)} instead. 124 */ 125 default HeaderCard findCard(String key) { 126 return getHeader().findCard(key); 127 } 128 129 }