1 /* Copyright 2024-2025 The Johns Hopkins University Applied Physics Laboratory
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.files.iirv;
18
19 import java.io.IOException;
20
21 /**
22 * Writer class that outputs {@link IIRVMessage} data to an output stream.
23 *
24 * @author Nick LaFarge
25 * @see IIRVFileWriter
26 * @since 13.0
27 */
28 public class StreamingIIRVFileWriter {
29
30 /** Output stream. */
31 private final Appendable writer;
32
33 /** Setting for when message metadata terms appear in the created IIRV message. */
34 private final IIRVMessage.IncludeMessageMetadata includeMessageMetadataSetting;
35
36 /**
37 * Create an IIRV writer that streams data to the given output stream.
38 *
39 * @param writer the output stream for the IIRV file.
40 * @param includeMessageMetadataSetting Setting for when message metadata terms appear in the created IIRV message
41 */
42 public StreamingIIRVFileWriter(final Appendable writer, final IIRVMessage.IncludeMessageMetadata includeMessageMetadataSetting) {
43 this.writer = writer;
44 this.includeMessageMetadataSetting = includeMessageMetadataSetting;
45 }
46
47 /**
48 * Write the passed in {@link IIRVMessage} using the passed in {@link Appendable}.
49 *
50 * @param iirvMessage a an {@link IIRVMessage} instance populated with {@link IIRVVector} terms.
51 * @throws IOException if any buffer writing operations fail
52 */
53 public void writeIIRVMessage(final IIRVMessage iirvMessage) throws IOException {
54 writer.append(iirvMessage.toMessageString(includeMessageMetadataSetting));
55 }
56
57 /**
58 * Gets the setting for when message metadata terms appear in the created IIRV message.
59 *
60 * @return setting for when message metadata terms appear in the created IIRV message
61 */
62 public IIRVMessage.IncludeMessageMetadata getIncludeMessageMetadataSetting() {
63 return includeMessageMetadataSetting;
64 }
65 }