Menu

Regex Matcher

Mike

Created a Matcher implementation that uses regular expressions to match tuples.

        //make a matcher
        final RegexMatcher matcher = new RegexMatcher();
        matcher.addRegexEntry("cName", "^Fa.*");

        //make a space and set the matcher 
        final Space space = new TupleSpace();
        space.setMatcher(matcher);

The above will create a matcher that will attempt to match the string representation of the value any field named 'cName' in any tuple against the regular expression '^Fa.*'.

Other field name, regex pairs can be added to the matcher using the addRegexEntry method. If this is the case each is evaluated and they're all ANDed together.

In fact I think this should be changed slightly so that the tuple class is supplied to the RegexMatcher at construction to save matching against tuples that were not originally intended to be matched.