EopParserLoader.java

  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. import java.io.IOException;
  19. import java.io.InputStream;
  20. import java.text.ParseException;
  21. import java.util.ArrayList;
  22. import java.util.Collection;
  23. import java.util.List;

  24. import org.orekit.data.DataLoader;

  25. /**
  26.  * Implementation of {@link DataLoader} based on {@link EopHistoryLoader.Parser} that
  27.  * loads all files and compiles the results into one data structure.
  28.  *
  29.  * @author Evan Ward
  30.  * @since 10.1
  31.  */
  32. class EopParserLoader implements DataLoader {

  33.     /** Parser for EOP data files. */
  34.     private final EopHistoryLoader.Parser parser;

  35.     /** History entries. */
  36.     private final List<EOPEntry> history;

  37.     /**
  38.      * Create a {@link DataLoader} based on a {@link EopHistoryLoader.Parser}. Loads
  39.      * all EOP data into a single collection.
  40.      *
  41.      * @param parser for the EOP data files.
  42.      */
  43.     EopParserLoader(final EopHistoryLoader.Parser parser) {
  44.         this.parser = parser;
  45.         this.history = new ArrayList<>();
  46.     }

  47.     /**
  48.      * Get the parsed EOP entries.
  49.      *
  50.      * @return the parsed EOP data. The returned collection is a reference, not a
  51.      * copy. It is not guaranteed to be sorted.
  52.      */
  53.     public Collection<EOPEntry> getEop() {
  54.         return history;
  55.     }

  56.     /** {@inheritDoc} */
  57.     public boolean stillAcceptsData() {
  58.         return true;
  59.     }

  60.     @Override
  61.     public void loadData(final InputStream input, final String name)
  62.             throws IOException, ParseException {
  63.         history.addAll(parser.parse(input, name));
  64.     }

  65. }