DataProvider.java

  1. /* Copyright 2002-2019 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.data;

  18. import java.util.regex.Pattern;

  19. /** Interface for providing data files to {@link DataLoader file loaders}.
  20.  * <p>
  21.  * This interface defines a generic way to explore some collection holding
  22.  * data files and load some of them. The collection may be a list of resources
  23.  * in the classpath, a directories tree in filesystem, a zip or jar archive,
  24.  * a database, a connexion to a remote server ...
  25.  * </p>
  26.  * <p>
  27.  * The proper way to use this interface is to configure one or more
  28.  * implementations and register them in the {@link DataProvidersManager data
  29.  * providers manager singleton}, or to let this manager use its default
  30.  * configuration. Once registered, they will be used automatically whenever
  31.  * some data needs to be loaded. This allow high level applications developers
  32.  * to customize Orekit data loading mechanism and get a tighter intergation of
  33.  * the library within their application.
  34.  * </p>
  35.  * @see DataLoader
  36.  * @see DataProvidersManager
  37.  * @author Luc Maisonobe
  38.  */
  39. public interface DataProvider {

  40.     /** Pattern for name of gzip files.
  41.      * @deprecated as of 9.2, replaced with {@link GzipFilter}
  42.      */
  43.     @Deprecated
  44.     Pattern GZIP_FILE_PATTERN = Pattern.compile("(.*)\\.gz$");

  45.     /** Pattern for name of zip/jar archives. */
  46.     Pattern ZIP_ARCHIVE_PATTERN = Pattern.compile("(.*)(?:(?:\\.zip)|(?:\\.jar))$");

  47.     /** Feed a data file loader by browsing the data collection.
  48.      * <p>
  49.      * The method crawls all files referenced in the instance (for example
  50.      * all files in a directories tree) and for each file supported by the
  51.      * file loader it asks the file loader to load it.
  52.      * </p>
  53.      * <p>
  54.      * If the method completes without exception, then the data loader
  55.      * is considered to have been fed successfully and the top level
  56.      * {@link DataProvidersManager data providers manager} will return
  57.      * immediately without attempting to use the next configured providers.
  58.      * </p>
  59.      * <p>
  60.      * If the method completes abruptly with an exception, then the top level
  61.      * {@link DataProvidersManager data providers manager} will try to use
  62.      * the next configured providers, in case another one can feed the
  63.      * {@link DataLoader data loader}.
  64.      * </p>
  65.      * @param supported pattern for file names supported by the visitor
  66.      * @param visitor data file visitor to use
  67.      * @return true if some data has been loaded
  68.      */
  69.     boolean feed(Pattern supported, DataLoader visitor);

  70. }