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

org.sonar.api.batch.fs.FilePredicates Maven / Gradle / Ivy

/*
 * SonarQube, open source software quality management tool.
 * Copyright (C) 2008-2014 SonarSource
 * mailto:contact AT sonarsource DOT com
 *
 * SonarQube is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * SonarQube is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package org.sonar.api.batch.fs;

import java.io.File;
import java.util.Collection;

/**
 * Factory of {@link org.sonar.api.batch.fs.FilePredicate}
 *
 * @since 4.2
 */
public interface FilePredicates {
  /**
   * Predicate that always evaluates to true
   */
  FilePredicate all();

  /**
   * Predicate that always evaluates to false
   */
  FilePredicate none();

  /**
   * Predicate that gets a file by its absolute path. The parameter
   * accepts forward/back slashes as separator and non-normalized values
   * (/path/to/../foo.txt is same as /path/foo.txt).
   * 

* Warning - not efficient because absolute path is not indexed yet. */ FilePredicate hasAbsolutePath(String s); /** * Predicate that gets a file by its relative path. The parameter * accepts forward/back slashes as separator and non-normalized values * (foo/../bar.txt is same as bar.txt). It must * not be null. */ FilePredicate hasRelativePath(String s); /** * Predicate that gets the files which relative or absolute path matches a wildcard pattern. *

* If the parameter starts with file:, then absolute path is used, else relative path. Pattern * is case-sensitive, except for file extension. *

* Supported wildcards are * and **, but not ?. *

* Examples: *

    *
  • **/*Foo.java matches Foo.java, src/Foo.java and src/java/SuperFoo.java
  • *
  • **/*Foo*.java matches src/Foo.java, src/BarFoo.java, src/FooBar.java * and src/BarFooBaz.java
  • *
  • **/*FOO.JAVA matches FOO.java and FOO.JAVA but not Foo.java
  • *
  • file:**/src/*Foo.java matches /path/to/src/Foo.java on unix and c:\path\to\Foo.java on MSWindows
  • *
*/ FilePredicate matchesPathPattern(String inclusionPattern); /** * Predicate that gets the files matching at least one wildcard pattern. No filter is applied when * zero wildcard patterns (similar to {@link #all()}. * @see #matchesPathPattern(String) */ FilePredicate matchesPathPatterns(String[] inclusionPatterns); /** * Predicate that gets the files that do not match the given wildcard pattern. * @see #matchesPathPattern(String) */ FilePredicate doesNotMatchPathPattern(String exclusionPattern); /** * Predicate that gets the files that do not match any of the given wildcard patterns. No filter is applied when * zero wildcard patterns (similar to {@link #all()}. * @see #matchesPathPattern(String) */ FilePredicate doesNotMatchPathPatterns(String[] exclusionPatterns); /** * if the parameter represents an absolute path for the running environment, then * returns {@link #hasAbsolutePath(String)}, else {@link #hasRelativePath(String)} */ FilePredicate hasPath(String s); FilePredicate is(File ioFile); FilePredicate hasLanguage(String language); FilePredicate hasLanguages(Collection languages); FilePredicate hasLanguages(String... languages); FilePredicate hasStatus(InputFile.Status status); FilePredicate hasType(InputFile.Type type); FilePredicate not(FilePredicate p); FilePredicate or(Collection or); FilePredicate or(FilePredicate... or); FilePredicate or(FilePredicate first, FilePredicate second); FilePredicate and(Collection and); FilePredicate and(FilePredicate... and); FilePredicate and(FilePredicate first, FilePredicate second); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy