All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.gov.nasa.worldwindx.applications.dataimporter.FileStoreDataSetFinder Maven / Gradle / Ivy

Go to download

World Wind is a collection of components that interactively display 3D geographic information within Java applications or applets.

There is a newer version: 2.0.0-986
Show newest version
/*
 * Copyright (C) 2013 United States Government as represented by the Administrator of the
 * National Aeronautics and Space Administration.
 * All Rights Reserved.
 */

package gov.nasa.worldwindx.applications.dataimporter;

import gov.nasa.worldwind.cache.FileStore;
import gov.nasa.worldwind.util.*;

import java.io.File;
import java.util.*;

/**
 * Finds all the data sets within a filestore.
 *
 * @author tag
 * @version $Id: FileStoreDataSetFinder.java 1180 2013-02-15 18:40:47Z tgaskins $
 */
public class FileStoreDataSetFinder
{
    public List findDataSets(FileStore fileStore)
    {
        final List dataSets = new ArrayList();

        for (File file : fileStore.getLocations())
        {
            if (!file.exists())
                continue;

            if (!fileStore.isInstallLocation(file.getPath()))
                continue;

            dataSets.addAll(this.findDataSets(file));
        }

        return dataSets;
    }

    protected List findDataSets(File cacheRoot)
    {
        if (cacheRoot == null)
        {
            String message = Logging.getMessage("nullValue.FileStorePathIsNull");
            Logging.logger().severe(message);
            throw new IllegalArgumentException(message);
        }

        String[] configFilePaths = WWIO.listDescendantFilenames(cacheRoot, new DataConfigurationFilter(), false);
        if (configFilePaths == null || configFilePaths.length == 0)
            return Collections.emptyList();

        List dataSets = new ArrayList();

        for (String configFilePath : configFilePaths)
        {
            File configFile = new File(configFilePath);
            dataSets.add(new FileStoreDataSet(cacheRoot.getPath(),
                cacheRoot.getPath() + File.separator + configFile.getParent(),
                cacheRoot.getPath() + File.separator + configFilePath));
        }

        return dataSets;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy