1 package nom.tam.fits.compression.provider.param.api;
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 * <p>
36 * (<i>for internal use</i>) Compression parameters that are stored in the table along with the compressed data. Each
37 * parameter is associated to a comlumn in the table, and the parameter takes the value that is stored in the same row
38 * as the compressed data themselves.
39 * </p>
40 * <p>
41 * It is possible to make independent copies of a set of such parameters, e.g. for parallel processing. In such cases
42 * all copies share their underlying column data with the original, so changing the sotrage array of column data in
43 * either the original or any of its decendants will affect the original and all decendans equally.
44 * </p>
45 */
46 public interface ICompressColumnParameter extends ICompressParameter {
47 /**
48 * Returns the data column, in which each entry stores the parameter value for the compressed data of the
49 * corresponding row in the table.
50 *
51 * @return The array that contains the data for each compressed row.
52 *
53 * @see #setColumnData(Object, int)
54 * @see #getValueFromColumn(int)
55 * @see #setValueInColumn(int)
56 *
57 * @since 1.18
58 */
59 Object getColumnData();
60
61 /**
62 * @deprecated Provided for back compatibility only. Use {@link #getColumnData()} instead.
63 *
64 * @return The array that contains the data for each compressed row.
65 */
66 @Deprecated
67 default Object column() {
68 return getColumnData();
69 }
70
71 /**
72 * @deprecated Provided for back compatibility only. Use {@link #getColumnData()} instead. Returns the existing
73 * columm data for this parameter, or if there is no data specified yet, it returns the freshly
74 * created column data initialized to the default value of this parameters.
75 *
76 * @return a valid instance of the column data, either as previously specified, or initialized with the default
77 * values.
78 */
79 @Deprecated
80 default Object initializedColumn() {
81 return getColumnData();
82 }
83
84 /**
85 * Sets new parameter data for each compressed row to be stored along as a separate parameter column in the
86 * compressed table. To discard prior column data with no replacement, you can call this as
87 * <code>setColumnData(null, 0)</code>.
88 *
89 * @param column The array that contains the data for each compressed row. If not <code>null</code> the
90 * <code>size</code> parameter is ignored, and the size of the array is used instead.
91 * @param size The number of compressed rows in the table, if the <code>column</code> argument is
92 * <code>null</code>. If <code>size</code> is zero or negative, any prior column data will be
93 * discarded and <code>null</code> will be set.
94 *
95 * @see #getColumnData()
96 *
97 * @deprecated Use {@link #setColumnData(Object)} or {@link #createColumnData(int)} or
98 * {@link #setColumnSize(int)} instead.
99 */
100 @Deprecated
101 void setColumnData(Object column, int size);
102
103 /**
104 * Sets new parameter data for each compressed row to be stored along as a separate parameter column in the
105 * compressed table.
106 *
107 * @param data The array that contains the data for each compressed row or <code>null</code> to discard prior data.
108 *
109 * @see #getColumnData()
110 *
111 * @since 1.23
112 */
113 void setColumnData(Object data);
114
115 /**
116 * Creates new data for this column parameter. All parameters in the new column data will be initialized to its
117 * default value, and all previously defined column parameters will be discarded.
118 *
119 * @param size The number of compressed rows in the table. It it is zero or negative, any prior column data will be
120 * discarded and <code>null</code> will be set.
121 *
122 * @see #setColumnSize(int)
123 * @see #getColumnData()
124 *
125 * @since 1.23
126 */
127 void createColumnData(int size);
128
129 /**
130 * Ensures that the column has the right number of parameters, creating new data or resizing the existing data as
131 * necessary. If the column data is resized, the existing elements will be preserved up to the new size. Any
132 * parameters that were not previously present will be initialized to their default value.
133 *
134 * @param size The number of compressed rows in the table. It it is zero or negative, any prior column data will be
135 * discarded and <code>null</code> will be set.
136 *
137 * @see #createColumnData(int)
138 * @see #getColumnData()
139 *
140 * @since 1.23
141 */
142 void setColumnSize(int size);
143
144 /**
145 * @deprecated Provided for back compatibility only. Use {@link #setColumnData(Object, int)} instead.
146 *
147 * @param column The array that contains the data for each compressed row. If not <code>null</code> the
148 * <code>size</code> parameter is ignored, and the size of the array is used instead.
149 * @param size The number of compressed rows in the table, if the <code>column</code> argument is
150 * <code>null</code>
151 */
152 @Deprecated
153 default void column(Object column, int size) {
154 setColumnData(column, size);
155 }
156
157 /**
158 * Updates the associated compression options to use the parameter value defined to the compressed tile of the
159 * specified index.
160 *
161 * @param index the tile index, a.k.a. row index in the compressed data table.
162 *
163 * @see #setValueInColumn(int)
164 * @see #setColumnData(Object, int)
165 */
166 void getValueFromColumn(int index);
167
168 /**
169 * Stores the current parameter value of the associated compression options for the tile of the specified index.
170 *
171 * @param index the tile index, a.k.a. row index in the compressed data table.
172 *
173 * @see #getValueFromColumn(int)
174 * @see #setColumnData(Object, int)
175 */
176 void setValueInColumn(int index);
177
178 /**
179 * @deprecated Provided for back compatibility only. Use {@link #setValueInColumn(int)} instead.
180 *
181 * @param index the tile index, a.k.a. row index in the compressed data table.
182 */
183 @Deprecated
184 default void setValueFromColumn(int index) {
185 setValueInColumn(index);
186 }
187
188 }