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

src.gov.nasa.worldwind.util.gdal.GDALAbstractFileFilter 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) 2012 United States Government as represented by the Administrator of the
 * National Aeronautics and Space Administration.
 * All Rights Reserved.
 */

package gov.nasa.worldwind.util.gdal;

import gov.nasa.worldwind.util.*;

import java.io.File;
import java.util.HashSet;
import java.util.regex.Pattern;

/**
 * @author Lado Garakanidze
 * @version $Id: GDALAbstractFileFilter.java 1171 2013-02-11 21:45:02Z dcollins $
 */

abstract class GDALAbstractFileFilter implements java.io.FileFilter
{
    protected HashSet listFolders = new HashSet();
    protected final String searchPattern;

    protected GDALAbstractFileFilter(String searchPattern)
    {
        if (null == searchPattern || searchPattern.length() == 0)
        {
            String message = Logging.getMessage("nullValue.StringIsNull");
            Logging.logger().severe(message);
            throw new IllegalArgumentException(message);
        }

        this.searchPattern = searchPattern;

        listFolders.clear();
    }

    protected boolean isHidden(String path)
    {
        if (!WWUtil.isEmpty(path))
        {
            String[] folders = path.split(Pattern.quote(File.separator));
            if (!WWUtil.isEmpty(folders))
            {
                for (String folder : folders)
                {
                    if (!WWUtil.isEmpty(folder) && folder.startsWith("."))
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public String[] getFolders()
    {
        String[] folders = new String[listFolders.size()];
        return this.listFolders.toArray(folders);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy