org.rhq.augeas.util
Class Glob

java.lang.Object
  extended by org.rhq.augeas.util.Glob

public class Glob
extends Object

A helper class for easy work with glob patterns.

Author:
Lukas Krejci

Field Summary
static Comparator<File> ALPHABETICAL_COMPARATOR
           
 
Method Summary
static void exclude(List<File> matches, String globPattern)
           
static void excludeAll(List<File> matches, List<String> globPatterns)
           
static void excludeAll(List<File> matches, String... globPattern)
           
static boolean isWildcard(String globPattern)
          Checks whether the provided string is a wildcard glob pattern.
static List<File> match(File parentPath, String globPattern)
          This is an overloaded version of the match(File, String, Comparator) method that passes null as the comparator to use.
static List<File> match(File parentPath, String globPattern, Comparator<? super File> resultComparator)
          Returns a fixed size list of matches.
static List<File> matchAll(File parentPath, List<String> globPatterns)
          This is an overloaded version of the matchAll(File, List, Comparator) method that passes null as the comparator to use.
static List<File> matchAll(File parentPath, List<String> globPatterns, Comparator<? super File> resultComparator)
           
static boolean matches(File rootPath, String globPattern, File file)
          Checks if the file matches the glob pattern with given path as a root of the filesystem.
static String rootPortion(String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALPHABETICAL_COMPARATOR

public static final Comparator<File> ALPHABETICAL_COMPARATOR
Method Detail

isWildcard

public static boolean isWildcard(String globPattern)
Checks whether the provided string is a wildcard glob pattern.

Parameters:
globPattern -
Returns:

matches

public static boolean matches(File rootPath,
                              String globPattern,
                              File file)
Checks if the file matches the glob pattern with given path as a root of the filesystem. If the glob pattern denotes an absolute path, it is understood to be under the supplied fs root.

Parameters:
rootPath -
globPattern -
file -
Returns:

match

public static List<File> match(File parentPath,
                               String globPattern)
This is an overloaded version of the match(File, String, Comparator) method that passes null as the comparator to use.

See Also:
match(File, String, Comparator)

match

public static List<File> match(File parentPath,
                               String globPattern,
                               Comparator<? super File> resultComparator)
Returns a fixed size list of matches. The parent path specifies the "root" from which the glob pattern applies. The glob pattern can span several directories with wildcards present only on the lowest level. The glob pattern is always relative to the specified parent path, even if it denotes an absolute path. In that case, the leading root path is chopped off and the rest is appended to the parent path.

Parameters:
parentPath - the parent path to start the pattern search
globPattern - the glob pattern to match against
resultComparator - the comparator using which to sort the results or null if no sorting is necessary
Returns:
the list of matches

matchAll

public static List<File> matchAll(File parentPath,
                                  List<String> globPatterns)
This is an overloaded version of the matchAll(File, List, Comparator) method that passes null as the comparator to use.

See Also:
matchAll(File, List, Comparator)

matchAll

public static List<File> matchAll(File parentPath,
                                  List<String> globPatterns,
                                  Comparator<? super File> resultComparator)

exclude

public static void exclude(List<File> matches,
                           String globPattern)

excludeAll

public static void excludeAll(List<File> matches,
                              String... globPattern)

excludeAll

public static void excludeAll(List<File> matches,
                              List<String> globPatterns)

rootPortion

public static String rootPortion(String path)


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.