org.entityfs.support.util.regexp
Class Glob

java.lang.Object
  extended by org.entityfs.support.util.regexp.Glob
All Implemented Interfaces:
Serializable

public class Glob
extends Object
implements Serializable

This class corresponds to Java's Pattern class for glob patterns.

A glob pattern is a pattern for matching strings that can use wildcards such as * and ?. Most programmers have encountered glob patterns when working with files and directories in an operating system shell. Read more about glob patterns in the Wikipedia article on Glob.

Glob objects are immutable.

Internally, the glob pattern is translated to a Pattern object.

Since:
1.1
Author:
Karl Gustafsson
See Also:
Serialized Form

Constructor Summary
Glob(String glob)
          Create a new glob pattern object.
Glob(String glob, int flags)
          Create a new glob pattern object using custom pattern compilation flags.
 
Method Summary
static Glob compile(String glob)
          This is an alternative way of creating Glob objects that uses the same approach as the Pattern object.
static Glob compile(String glob, int flags)
          This is an alternative way of creating Glob objects using custom pattern compilation flags.
 int flags()
          Get the pattern compilation flags that were used when compiling this glob pattern.
 Pattern getPattern()
          Get the Pattern object that corresponds to this glob pattern.
 Matcher matcher(CharSequence input)
          Get a Matcher for matching text in the supplied input.
static boolean matches(String glob, String input)
          Convenience method for matching a glob pattern against the supplied input.
 String pattern()
          Get the glob pattern that was used to create this object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Glob

public Glob(String glob)
     throws PatternSyntaxException
Create a new glob pattern object.

Parameters:
glob - The glob pattern.
Throws:
PatternSyntaxException - On syntax errors in the supplied glob pattern.
See Also:
Glob(String, int), compile(String)

Glob

public Glob(String glob,
            int flags)
     throws PatternSyntaxException
Create a new glob pattern object using custom pattern compilation flags. The compilation flags are the same as those used by the Pattern object.

Parameters:
glob - The glob pattern.
flags - Custom pattern compilation flags.
Throws:
PatternSyntaxException - On syntax errors in the supplied glob pattern.
See Also:
Glob(String), compile(String,int)
Method Detail

compile

public static Glob compile(String glob)
                    throws PatternSyntaxException
This is an alternative way of creating Glob objects that uses the same approach as the Pattern object.

Parameters:
glob - The glob pattern.
Returns:
A new Glob object.
Throws:
PatternSyntaxException - On syntax errors in the supplied glob pattern.
See Also:
Glob(String), compile(String, int), Pattern.compile(String)

compile

public static Glob compile(String glob,
                           int flags)
                    throws PatternSyntaxException
This is an alternative way of creating Glob objects using custom pattern compilation flags. This method uses the same approach as the Pattern object.

The compilation flags are the same as those used by the Pattern object.

Parameters:
glob - The glob pattern.
flags - Custom pattern compilation flags.
Returns:
A new Glob object.
Throws:
PatternSyntaxException - On syntax errors in the supplied glob pattern.
See Also:
Glob(String, int), compile(String), Pattern.compile(String, int)

flags

public int flags()
Get the pattern compilation flags that were used when compiling this glob pattern.

Returns:
The pattern compilation flags.
See Also:
Glob(String, int), Pattern.flags()

matcher

public Matcher matcher(CharSequence input)
Get a Matcher for matching text in the supplied input.

Parameters:
input - The text to match glob expressions in.
Returns:
A new Matcher object.
See Also:
Pattern.matcher(CharSequence)

matches

public static boolean matches(String glob,
                              String input)
                       throws PatternSyntaxException
Convenience method for matching a glob pattern against the supplied input.

Parameters:
glob - The glob pattern.
input - The string to match.
Returns:
true if the input string matches the glob pattern.
Throws:
PatternSyntaxException - On syntax errors in the supplied glob pattern.
See Also:
Pattern.matches(String, CharSequence)

pattern

public String pattern()
Get the glob pattern that was used to create this object.

Returns:
The glob pattern that was used to create this object.

getPattern

public Pattern getPattern()
Get the Pattern object that corresponds to this glob pattern.

Returns:
A Pattern object.

toString

public String toString()
Overrides:
toString in class Object