File: IHDF5Writer.java

package info (click to toggle)
libsis-jhdf5-java 19.04.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,668 kB
  • sloc: java: 79,644; ansic: 18,986; sh: 309; makefile: 49; xml: 12
file content (267 lines) | stat: -rw-r--r-- 8,090 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*
 * Copyright 2007 - 2018 ETH Zuerich, CISD and SIS.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package ch.systemsx.cisd.hdf5;

/**
 * An interface for writing HDF5 files (HDF5 1.6.x, HDF5 1.8.x or HDF5 1.10.x).
 * <p>
 * Obtain an object implementing this interface by calling {@link HDF5Factory#open(String)} or 
 * {@link IHDF5WriterConfigurator#writer()}.
 * <p>
 * The interface focuses on ease of use instead of completeness. As a consequence not all features
 * of HDF5 are supported by this class, however it covers a large subset.
 * <p>
 * The functionality is being made available in two ways:
 * <ol>
 * <li>{@link IHDF5SimpleWriter} contains the most important methods in one interface. If you are
 * new to the library, this is a good starting point, see the example code below.</li>
 * <li>The hierarchical ("quasi-fluent") API provides the full functionality. It is designed along
 * the data types supported by JHDF5.
 * <ul>
 * <li>{@link #file()}: File-level information and operations, has e.g. the
 * {@link IHDF5FileLevelReadWriteHandler#close()} and {@link IHDF5FileLevelReadWriteHandler#flush()}
 * methods.</li>
 * <li>{@link #object()}: Object-level information, where "objects" can be data sets, links, groups
 * or data types, following the concept of an HDF5 object. Here you can find methods like
 * {@link IHDF5ObjectReadWriteInfoProviderHandler#createGroup(String)} for creating a new group, or
 * {@link IHDF5ObjectReadWriteInfoProviderHandler#createSoftLink(String, String)} for creating a
 * symbolic link.</li>
 * <li>{@link #bool()}: Writer methods for boolean data sets, including bit fields.</li>
 * <li>{@link #int8()} / {@link #int16()} / {@link #int16()} / {@link #int32()} / {@link #int64()}:
 * Writer methods for signed integer data sets, where the number as part of the method name denotes
 * the size of the integer type.</li>
 * <li>{@link #uint8()} / {@link #uint16()} / {@link #uint16()} / {@link #uint32()} /
 * {@link #int64()}: Writer methods for unsigned integer data sets, where the number as part of the
 * name sets the size of the integer type. While the data sets take signed integer values due to
 * Java's lack of unsigned integer types, they <i>represent</i> them as unsigned values in the HDF5
 * file. See {@link UnsignedIntUtils} for conversion methods, e.g.
 * <code>uint32().write("myint", UnsignedIntUtils.toInt16(50000))</code> will write a 16-bit
 * unsigned integer with value 50000.</li>
 * <li>{@link #float32()} / {@link #float64()}: Writer methods for float data sets, where the number
 * as part of the name sets the size of the float type.</li>
 * <li>{@link #time()} / {@link #duration()}: Writer methods for time stamp (or date) and for time
 * duration data sets.</li>
 * <li>{@link #string()}: Writer methods for string data sets.</li>
 * <li>{@link #enumeration()}: Writer methods for enumeration data sets.</li>
 * <li>{@link #compound()}: Writer methods for compound data sets.</li>
 * <li>{@link #opaque()}: Writer methods for data sets that are "black boxes" to HDF5 which are
 * called "opaque data sets" in HDF5 jargon. Here you can also find methods of reading arbitrary
 * data sets as byte arrays.</li>
 * <li>{@link #reference()}: Writer methods for HDF5 object references. Note that object references,
 * though similar to hard links and symbolic links on the first glance, are quite different for
 * HDF5.</li>
 * </ul>
 * </li>
 * </ol>
 * <p>
 * Simple usage example:
 * 
 * <pre>
 * float[] f = new float[100];
 * ...
 * IHDF5Writer writer = HDF5FactoryProvider.get().open(new File(&quot;test.h5&quot;));
 * writer.writeFloatArray(&quot;/some/path/dataset&quot;, f);
 * writer.setStringAttribute(&quot;some key&quot;, &quot;some value&quot;);
 * writer.close();
 * </pre>
 * 
 * @author Bernd Rinn
 */
public interface IHDF5Writer extends IHDF5Reader, IHDF5SimpleWriter
{
    // /////////////////////
    // File
    // /////////////////////

    /**
     * Returns the handler for file-level information and status.
     */
    @Override
    public IHDF5FileLevelReadWriteHandler file();

    // /////////////////////////////////
    // Objects, links, groups and types
    // /////////////////////////////////

    /**
     * Returns an info provider and handler for HDF5 objects like links, groups, data sets and data
     * types.
     */
    @Override
    public IHDF5ObjectReadWriteInfoProviderHandler object();

    // /////////////////////
    // Opaque
    // /////////////////////

    /**
     * Returns the full writer for opaque values.
     */
    @Override
    public IHDF5OpaqueWriter opaque();

    // /////////////////////
    // Boolean
    // /////////////////////

    /**
     * Returns the full writer for boolean values.
     */
    @Override
    public IHDF5BooleanWriter bool();

    // /////////////////////
    // Bytes
    // /////////////////////

    /**
     * Returns the full writer for byte / int8.
     */
    @Override
    public IHDF5ByteWriter int8();

    /**
     * Returns the full writer for unsigned byte / uint8.
     */
    @Override
    public IHDF5ByteWriter uint8();

    // /////////////////////
    // Short
    // /////////////////////

    /**
     * Returns the full writer for short / int16.
     */
    @Override
    public IHDF5ShortWriter int16();

    /**
     * Returns the full writer for unsigned short / uint16.
     */
    @Override
    public IHDF5ShortWriter uint16();

    // /////////////////////
    // Int
    // /////////////////////

    /**
     * Returns the full writer for int / int32.
     */
    @Override
    public IHDF5IntWriter int32();

    /**
     * Returns the full writer for unsigned int / uint32.
     */
    @Override
    public IHDF5IntWriter uint32();

    // /////////////////////
    // Long
    // /////////////////////

    /**
     * Returns the full writer for long / int64.
     */
    @Override
    public IHDF5LongWriter int64();

    /**
     * Returns the full writer for unsigned long / uint64.
     */
    @Override
    public IHDF5LongWriter uint64();

    // /////////////////////
    // Float
    // /////////////////////

    /**
     * Returns the full writer for float / float32.
     */
    @Override
    public IHDF5FloatWriter float32();

    // /////////////////////
    // Double
    // /////////////////////

    /**
     * Returns the full writer for long / float64.
     */
    @Override
    public IHDF5DoubleWriter float64();

    // /////////////////////
    // Enums
    // /////////////////////

    /**
     * Returns the full writer for enumerations.
     */
    @Override
    public IHDF5EnumWriter enumeration();

    // /////////////////////
    // Compounds
    // /////////////////////

    /**
     * Returns the full reader for compounds.
     */
    @Override
    public IHDF5CompoundWriter compound();

    // /////////////////////
    // Strings
    // /////////////////////

    /**
     * Returns the full writer for strings.
     */
    @Override
    public IHDF5StringWriter string();

    // /////////////////////
    // Date & Time
    // /////////////////////

    /**
     * Returns the full writer for date and times.
     */
    @Override
    public IHDF5DateTimeWriter time();

    /**
     * Returns the full writer for time durations.
     */
    @Override
    public IHDF5TimeDurationWriter duration();

    // /////////////////////
    // Object references
    // /////////////////////

    /**
     * Returns the full reader for object references.
     */
    @Override
    public IHDF5ReferenceWriter reference();

}