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