Debian Codegraph @

src/main/java/nom/tam/fits/compression/provider/param/base/CompressParameter.java

raw
1 package nom.tam.fits.compression.provider.param.base;
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 /**
35 * (<i>for internal use</i>) A parameter stored in the FITS header or compressed table that is linked to a compression
36 * option. When writing compressed data, the parameter ensures that the compression options that were used to generate
37 * the compressed data are stored in the FITS (headers of compressed table) along with the compressed data themselves.
38 * When reading compressed data, the parameter acts to apply the options stored in the FITS along with the data to set
39 * the appropriate options for decompression.
40 *
41 * @see nom.tam.fits.compression.algorithm.api.ICompressOption
42 *
43 * @param <OPTION> The generic type of the compression option that is linked to this parameter.
44 */
45 public class CompressParameter<OPTION> implements Cloneable {
46
47 private final String name;
48
49 private OPTION option;
50
51 /**
52 * Creates a new compression parameter with the name it is recorded in the FITS and the compression options it is to
53 * be linked with.
54 *
55 * @param name the FITS header keyword or binary table column name that records this parameter in the FITS.
56 * @param option the compression option instance that this parameter is linked to.
57 */
58 protected CompressParameter(String name, OPTION option) {
59 this.name = name;
60 this.option = option;
61 }
62
63 /**
64 * Returns an independent copy of these parameters to associate with the specific instance of compression options.
65 * As a result, updating these parameters in the copy will affect only the specified compression options, but not
66 * the compression options associated to this originating instance.
67 *
68 * @param opt The compression options that are linked to the copy of the parameters
69 *
70 * @return A copy of these parameters, linked to the specified compression options.
71 *
72 * @since 1.18
73 */
74 public CompressParameter<OPTION> copy(OPTION opt) {
75 try {
76 @SuppressWarnings("unchecked")
77 CompressParameter<OPTION> p = (CompressParameter<OPTION>) super.clone();
78 p.option = opt;
79 return p;
80 } catch (CloneNotSupportedException e) {
81 return null;
82 }
83 }
84
85 /**
86 * Returns the name of this parameter as it is recorded in the FITS
87 *
88 * @return the FITS header keyword or binary table column name that records this parameter in the FITS.
89 */
90 public final String getName() {
91 return name;
92 }
93
94 /**
95 * Returns the compression options that are linked to this parameter
96 *
97 * @return the compression option instance that this parameter is linked to.
98 */
99 protected final OPTION getOption() {
100 return option;
101 }
102
103 }