GlobHelper Class

DEPRECATED Use GlobHelper

com.beasys.commerce.util
GlobHelper Class

public class GlobHelper

    extends Object
    implements FilenameFilter

A utility class for doing DOS-style pattern matching (GLOBing).

This supports only '?' and '*' pattern characters. No bounded (e.g. "[abcd] file") patterns are supported.

To do a simple pattern match, you can use the matches class method. Additionally, GlobHelper is a FilenameFilter.

This requires the OROMatcher regular expression libraries, which are bundled with WebLogic Server.


Hierarchy
Object
  GlobHelper
All Implemented Interfaces

FilenameFilter

Field Summary

protected List
patterns
Our list of file patterns to match.
 

Constructor Summary

GlobHelper()

Constructor.
GlobHelper(String pattern)

Constructor with pattern.
GlobHelper(String patterns)

Constructor with patterns.
GlobHelper(Collection c)

Constructor with patterns.
GlobHelper(Iterator i)

Constructor with patterns.
 

Method Summary

public synchronized boolean
accept(File dir, String name)
Tell if the specified directory and filename matches our current list patterns.
public synchronized void
addPattern(String pat)
Add a pattern.
public static synchronized Pattern
getPattern(String patStr)
Get a pattern from the pattern cache, which is a soft reference map of pattern string to Pattern.
public List
getPatterns()
Get the patterns.
public static boolean
matches(String patStr, String str)
Determine if the given input string matches the specified input pattern.
public synchronized boolean
removePattern(String pat)
Remove a pattern.
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   
Methods from interface java.io.FilenameFilter
accept
 

Field Detail

patterns

protected List patterns
Our list of file patterns to match.

 

Constructor Detail

GlobHelper

public GlobHelper()
Constructor.

GlobHelper

public GlobHelper(String pattern)
Constructor with pattern.

GlobHelper

public GlobHelper(String[] patterns)
Constructor with patterns.

GlobHelper

public GlobHelper(Collection c)
Constructor with patterns.

GlobHelper

public GlobHelper(Iterator i)
Constructor with patterns.
 

Method Detail

accept(File, String) Method

public synchronized boolean accept(File dir, 
                                   String name)
Tell if the specified directory and filename matches our current list patterns.


addPattern(String) Method

public synchronized void addPattern(String pat)
Add a pattern.


getPattern(String) Method

public static synchronized Pattern getPattern(String patStr)
throws MalformedPatternException
Get a pattern from the pattern cache, which is a soft reference map of pattern string to Pattern.

By using a sort reference map, the garbage collector can clean it out as needed because we can always recreate the Pattern objects from the strings.

Exceptions

MalformedPatternException

getPatterns() Method

public List getPatterns()
Get the patterns.


matches(String, String) Method

public static boolean matches(String patStr, 
                              String str)
throws IllegalArgumentException
Determine if the given input string matches the specified input pattern.

Parameters

patStr
the pattern (e.g. "Some*Cl?.java").
str
the input string.

Returns

true if the input string matches the pattern, false if not

Exceptions

IllegalArgumentException
thrown on a bad pattern string.

removePattern(String) Method

public synchronized boolean removePattern(String pat)
Remove a pattern.