org.springframework.beandoc.util
Class PatternMatcher

java.lang.Object
  extended by org.springframework.beandoc.util.PatternMatcher

public final class PatternMatcher
extends Object

Utility class that matches bean names/id's or class names against an array of regex Patterns, using a callback interface for each pattern in the array which matched.

Since:
1.0
Author:
Darren Davison

Constructor Summary
protected PatternMatcher()
           
 
Method Summary
static Pattern[] convertStringsToPatterns(Collection strings)
          Convert a collection of String objects to an array of compiled regex Patterns.
static void matchPatterns(Pattern[] patterns, String[] testStrings, MatchedPatternCallback callback)
          Takes an array of Patterns, the id/name and f.q.class name of a bean and a callback interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatternMatcher

protected PatternMatcher()
Method Detail

convertStringsToPatterns

public static Pattern[] convertStringsToPatterns(Collection strings)
Convert a collection of String objects to an array of compiled regex Patterns. Gaps in the collection or objects that aren't Strings will simply be ignored.

Parameters:
strings - a List of Strings
Returns:
an array of compiled Patterns

matchPatterns

public static void matchPatterns(Pattern[] patterns,
                                 String[] testStrings,
                                 MatchedPatternCallback callback)
Takes an array of Patterns, the id/name and f.q.class name of a bean and a callback interface. For each pattern in the array that matches the bean id/name or class, the callback is executed passing in the String representation of the matching pattern and its index in the original array.

Parameters:
patterns - an array of compiled Patterns
testStrings - the array of Strings to test against the patterns. Usually consists of the id/name of the bean and its fully qualified classname
callback - an implementation of MatchedPatternCallback


Copyright © 2004-2011 Spring BeanDoc. All Rights Reserved.