1 /* Contributed in the public domain.
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.frames;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import org.orekit.data.DataLoader;
25 import org.orekit.data.DataSource;
26
27 /**
28 * Implementation of {@link DataLoader} based on {@link EopHistoryLoader.Parser} that
29 * loads all files and compiles the results into one data structure.
30 *
31 * @author Evan Ward
32 * @since 10.1
33 */
34 class EopParserLoader implements DataLoader {
35
36 /** Parser for EOP data files. */
37 private final EopHistoryLoader.Parser parser;
38
39 /** History entries. */
40 private final List<EOPEntry> history;
41
42 /**
43 * Create a {@link DataLoader} based on a {@link EopHistoryLoader.Parser}. Loads
44 * all EOP data into a single collection.
45 *
46 * @param parser for the EOP data files.
47 */
48 EopParserLoader(final EopHistoryLoader.Parser parser) {
49 this.parser = parser;
50 this.history = new ArrayList<>();
51 }
52
53 /**
54 * Get the parsed EOP entries.
55 *
56 * @return the parsed EOP data. The returned collection is a reference, not a
57 * copy. It is not guaranteed to be sorted.
58 */
59 public List<EOPEntry> getEop() {
60 return history;
61 }
62
63 /** {@inheritDoc} */
64 public boolean stillAcceptsData() {
65 return true;
66 }
67
68 @Override
69 public void loadData(final InputStream input, final String name) throws IOException {
70 history.addAll(parser.parse(new DataSource(name, () -> input)));
71 }
72
73 }