org.gmetrics.util
Class WildcardPattern

java.lang.Object
  extended by org.gmetrics.util.WildcardPattern
All Implemented Interfaces:
groovy.lang.GroovyObject

public class WildcardPattern
extends java.lang.Object
implements groovy.lang.GroovyObject

Represents a string pattern that may optionally include wildcards ('*', '**' or '?'), and provides an API to determine whether that pattern matches a specified input string.

The wildcard character '*' within the pattern matches a sequence of zero or more characters within a single file or directory name in the input string. It does not match a sequence of two or more dir/file names. For instance, 'a*b' matches 'a12345b' and 'ab', but does NOT match 'a/b' or 'a123/b'.

The '**' wildcard matches any sequence of zero or more characters in the input string, including directory names and separators . It matches any part of the directory tree. For instance, 'a**b' matches 'a12345b', 'ab', 'a/b' and 'a1/a2/a3b'.

The wildcard character '?' within the pattern matches exactly one character in the input string, excluding the normalized file separator character ('/').

This is an internal class and its API is subject to change.

Version:
$Revision: 101 $ - $Date: 2010-03-10 19:17:23 -0500 (Wed, 10 Mar 2010) $
Author:
Chris Mair

Constructor Summary
WildcardPattern(java.lang.String patternString, boolean defaultMatches)
          Construct a new WildcardPattern instance on a single pattern or a comma-separated list of patterns.
 
Method Summary
 groovy.lang.MetaClass getMetaClass()
           
 java.lang.Object getProperty(java.lang.String name)
           
 java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
           
 boolean matches(java.lang.String string)
          Return true if the specified String matches the pattern or if the original patternString (specified in the constructor) was null or empty and the value for defaultMatches (also specified in the constructor) was true.
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WildcardPattern

public WildcardPattern(java.lang.String patternString,
                       boolean defaultMatches)
Construct a new WildcardPattern instance on a single pattern or a comma-separated list of patterns.

Parameters:
patternString - - the pattern string, optionally including wildcard characters ('*' or '?'); may optionally contain more than one pattern, separated by commas; may be null or empty to always match
defaultMatches - - a boolean indicating whether matches() should return true if the pattern string is either empty or null. This parameter is optional and defaults to true.
Method Detail

matches

public boolean matches(java.lang.String string)
Return true if the specified String matches the pattern or if the original patternString (specified in the constructor) was null or empty and the value for defaultMatches (also specified in the constructor) was true.

Parameters:
string - - the String to check
Returns:
true if the String matches the pattern

getMetaClass

public groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject

setMetaClass

public void setMetaClass(groovy.lang.MetaClass metaClass)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject

invokeMethod

public java.lang.Object invokeMethod(java.lang.String name,
                                     java.lang.Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject

getProperty

public java.lang.Object getProperty(java.lang.String name)
Specified by:
getProperty in interface groovy.lang.GroovyObject

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Specified by:
setProperty in interface groovy.lang.GroovyObject


Copyright © 2010. All Rights Reserved.