org.orekit.data
Class DataProvidersManager

java.lang.Object
  extended by org.orekit.data.DataProvidersManager
All Implemented Interfaces:
java.io.Serializable

public class DataProvidersManager
extends java.lang.Object
implements java.io.Serializable

Singleton class managing all supported data providers.

This class is the single point of access for all data loading features. It is used for example to load Earth Orientation Parameters used by IERS frames, to load UTC leap seconds used by time scales, to load planetary ephemerides ...

It is user-customizable: users can add their own data providers at will. This allows them for example to use a database or an existing data loading library in order to embed an Orekit enabled application in a global system with its own data handling mechanisms. There is no upper limitation on the number of providers, but often each application will use only a few.

If the list of providers is empty when attempting to feed a file loader, the addDefaultProviders() method is called automatically to set up a default configuration. This default configuration contains one data provider for each component of the path-like list specified by the java property orekit.data.path. See the feed method documentation for further details. The default providers configuration is not set up if the list is not empty. If users want to have both the default providers and additional providers, they must call explicitly the addDefaultProviders() method.

Version:
$Revision: 3027 $ $Date: 2010-01-19 11:36:25 +0100 (mar. 19 janv. 2010) $
Author:
Luc Maisonobe
See Also:
DirectoryCrawler, ClasspathCrawler, Serialized Form

Field Summary
static java.lang.String OREKIT_DATA_PATH
          Name of the property defining the root directories or zip/jar files path for default configuration.
 
Method Summary
 void addDefaultProviders()
          Add the default providers configuration.
 void addProvider(DataProvider provider)
          Add a data provider to the supported list.
 void clearProviders()
          Remove all data providers.
 boolean feed(java.lang.String supportedNames, DataLoader loader)
          Feed a data file loader by browsing all data providers.
static DataProvidersManager getInstance()
          Get the unique instance.
 java.util.List<DataProvider> getProviders()
          Get an unmodifiable view of the list of supported providers.
 boolean isSupported(java.lang.Class<? extends DataProvider> providerClass)
          Check if some type of provider is supported.
 DataProvider removeProvider(java.lang.Class<? extends DataProvider> providerClass)
          Remove one provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OREKIT_DATA_PATH

public static final java.lang.String OREKIT_DATA_PATH
Name of the property defining the root directories or zip/jar files path for default configuration.

See Also:
Constant Field Values
Method Detail

getInstance

public static DataProvidersManager getInstance()
Get the unique instance.

Returns:
unique instance of the manager.

addDefaultProviders

public void addDefaultProviders()
                         throws OrekitException
Add the default providers configuration.

The default configuration contains one data provider for each component of the path-like list specified by the java property orekit.data.path.

If the property is not set or is null, no data will be available to the library (for example no pole corrections will be applied and only predefined UTC steps will be taken into account). No errors will be triggered in this case.

If the property is set, it must contains a list of existing directories or zip/jar archives. One DirectoryCrawler instance will be set up for each directory and one ZipJarCrawler instance (configured to look for the archive in the filesystem) will be set up for each zip/jar archive. The list elements in the java property are separated using the standard path separator for the operating system as returned by System.getProperty("path.separator"). This standard path separator is ":" on Linux and Unix type systems and ";" on Windows types systems.

Throws:
OrekitException - if an element of the list does not exist or exists but is neither a directory nor a zip/jar archive

addProvider

public void addProvider(DataProvider provider)
Add a data provider to the supported list.

Parameters:
provider - data provider to add
See Also:
removeProvider(Class), clearProviders(), isSupported(Class), getProviders()

removeProvider

public DataProvider removeProvider(java.lang.Class<? extends DataProvider> providerClass)
Remove one provider.

The first supported provider extending the specified class (or implementing the interface) is removed and returned. For example, removing the default provider that loads data from files located somewhere in a directory hierarchy can be done by calling:

   DataProvidersManager.getInstance().remove(DataDirectoryCrawler.class);
 

Parameters:
providerClass - class (or one of the superclass's) of the provider to remove
Returns:
instance removed (null if no provider of the given class was supported)
See Also:
addProvider(DataProvider), clearProviders(), isSupported(Class), getProviders()

clearProviders

public void clearProviders()
Remove all data providers.

See Also:
addProvider(DataProvider), removeProvider(Class), isSupported(Class), getProviders()

isSupported

public boolean isSupported(java.lang.Class<? extends DataProvider> providerClass)
Check if some type of provider is supported.

Parameters:
providerClass - class (or one of the superclass's) of the provider to check
Returns:
true if one provider of the given class is already in the supported list
See Also:
addProvider(DataProvider), removeProvider(Class), clearProviders(), getProviders()

getProviders

public java.util.List<DataProvider> getProviders()
Get an unmodifiable view of the list of supported providers.

Returns:
unmodifiable view of the list of supported providers
See Also:
addProvider(DataProvider), removeProvider(Class), clearProviders(), isSupported(Class)

feed

public boolean feed(java.lang.String supportedNames,
                    DataLoader loader)
             throws OrekitException
Feed a data file loader by browsing all data providers.

If this method is called with an empty list of providers, a default providers configuration is set up. This default configuration contains only one data provider: a DirectoryCrawler instance that loads data from files located somewhere in a directory hierarchy. This default provider is not added if the list is not empty. If users want to have both the default provider and other providers, they must add it explicitly.

The providers are used in the order in which they were added. As soon as one provider is able to feed the data loader, the loop is stopped. If no provider is able to feed the data loader, then the last error triggered is thrown.

Parameters:
supportedNames - regular expression for file names supported by the visitor
loader - data loader to use
Returns:
true if some data has been loaded
Throws:
OrekitException - if the data loader cannot be fed (read error ...) or if the default configuration cannot be set up


Copyright © 2002-2010 CS Communication & Systèmes. All Rights Reserved.