org.orekit.data
Class ClasspathCrawler

java.lang.Object
  extended by org.orekit.data.ClasspathCrawler
All Implemented Interfaces:
DataProvider

public class ClasspathCrawler
extends Object
implements DataProvider

Provider for data files stored as resources in the classpath.

This class handles a list of data files or zip/jar archives located in the classpath. Since the classpath is not a tree structure the list elements cannot be whole directories recursively browsed as in DirectoryCrawler, they must be data files or zip/jar archives.

A typical use case is to put all data files in a single zip or jar archive and to build an instance of this class with the single name of this zip/jar archive. Two different instances may be used one for user or project specific data and another one for system-wide or general data.

Gzip-compressed files are supported.

Zip archives entries are supported recursively.

This is a simple application of the visitor design pattern for list browsing.

Author:
Luc Maisonobe
See Also:
DataProvidersManager

Field Summary
 
Fields inherited from interface org.orekit.data.DataProvider
GZIP_FILE_PATTERN, ZIP_ARCHIVE_PATTERN
 
Constructor Summary
ClasspathCrawler(ClassLoader classLoader, String... list)
          Build a data classpath crawler.
ClasspathCrawler(String... list)
          Build a data classpath crawler.
 
Method Summary
 boolean feed(Pattern supported, DataLoader visitor)
          Feed a data file loader by browsing the data collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClasspathCrawler

public ClasspathCrawler(String... list)
                 throws OrekitException
Build a data classpath crawler.

Calling this constructor has the same effect as calling ClasspathCrawler(ClassLoader, String...) with ClasspathCrawler.class.getClassLoader() as first argument.

Parameters:
list - list of data file names within the classpath
Throws:
OrekitException - if a list elements is not an existing resource

ClasspathCrawler

public ClasspathCrawler(ClassLoader classLoader,
                        String... list)
                 throws OrekitException
Build a data classpath crawler.

Parameters:
classLoader - class loader to use to retrieve the resources
list - list of data file names within the classpath
Throws:
OrekitException - if a list elements is not an existing resource
Method Detail

feed

public boolean feed(Pattern supported,
                    DataLoader visitor)
             throws OrekitException
Feed a data file loader by browsing the data collection.

The method crawls all files referenced in the instance (for example all files in a directories tree) and for each file supported by the file loader it asks the file loader to load it.

If the method completes without exception, then the data loader is considered to have been fed successfully and the top level data providers manager will return immediately without attempting to use the next configured providers.

If the method completes abruptly with an exception, then the top level data providers manager will try to use the next configured providers, in case another one can feed the data loader.

Specified by:
feed in interface DataProvider
Parameters:
supported - pattern for file names supported by the visitor
visitor - data file visitor to use
Returns:
true if some data has been loaded
Throws:
OrekitException - if the data loader cannot be fed (read error ...)


Copyright © 2016 CNES. All Rights Reserved.