org.orekit.data
Class ZipJarCrawler

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

public class ZipJarCrawler
extends Object
implements DataProvider

Helper class for loading data files from a zip/jar archive.

This class browses all entries in a zip/jar archive in filesystem or in classpath.

The organization of entries within the archive is unspecified. All entries are checked in turn. If several entries of the archive are supported by the data loader, all of them will be loaded.

Gzip-compressed files are supported.

Zip archives entries are supported recursively.

This is a simple application of the visitor design pattern for zip entries 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
ZipJarCrawler(ClassLoader classLoader, String resource)
          Build a zip crawler for an archive file in classpath.
ZipJarCrawler(File file)
          Build a zip crawler for an archive file on filesystem.
ZipJarCrawler(String resource)
          Build a zip crawler for an archive file in classpath.
ZipJarCrawler(URL url)
          Build a zip crawler for an archive file on network.
 
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

ZipJarCrawler

public ZipJarCrawler(File file)
Build a zip crawler for an archive file on filesystem.

Parameters:
file - zip file to browse

ZipJarCrawler

public ZipJarCrawler(String resource)
              throws OrekitException
Build a zip crawler for an archive file in classpath.

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

Parameters:
resource - name of the zip file to browse
Throws:
OrekitException - if resource name is malformed

ZipJarCrawler

public ZipJarCrawler(ClassLoader classLoader,
                     String resource)
              throws OrekitException
Build a zip crawler for an archive file in classpath.

Parameters:
classLoader - class loader to use to retrieve the resources
resource - name of the zip file to browse
Throws:
OrekitException - if resource name is malformed

ZipJarCrawler

public ZipJarCrawler(URL url)
              throws OrekitException
Build a zip crawler for an archive file on network.

Parameters:
url - URL of the zip file on network
Throws:
OrekitException - if url syntax is malformed
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 © 2017 CNES. All Rights Reserved.