org.fest.swing.util
Class PatternTextMatcher

java.lang.Object
  extended by org.fest.swing.util.PatternTextMatcher
All Implemented Interfaces:
TextMatcher

public class PatternTextMatcher
extends Object
implements TextMatcher

Understands matching text to a group of String values. Matching is perform by equality or by regular expression matching.

Author:
Alex Ruiz

Constructor Summary
PatternTextMatcher(Pattern... patterns)
          Creates a new PatternTextMatcher.
 
Method Summary
 String description()
          Returns "pattern" if this matcher contains only one pattern, or "patterns" if this matcher contains more than one pattern.
 String formattedValues()
          Returns the regular expression patterns in this matcher, formatted as a single String.
 boolean isMatching(String text)
          Indicates whether the given text matches the regular expression patterns in this matcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatternTextMatcher

public PatternTextMatcher(Pattern... patterns)
Creates a new PatternTextMatcher.

Parameters:
patterns - the regular expression patterns to match.
Throws:
NullPointerException - if the array of patterns is null.
IllegalArgumentException - if the array of patterns is empty.
Method Detail

isMatching

public boolean isMatching(String text)
Indicates whether the given text matches the regular expression patterns in this matcher.

Specified by:
isMatching in interface TextMatcher
Parameters:
text - the text to verify.
Returns:
true if the given text matches the Pattern values in this matcher, false otherwise.
Throws:
NullPointerException - if any of the regular expressions is null.

description

public String description()
Returns "pattern" if this matcher contains only one pattern, or "patterns" if this matcher contains more than one pattern.

Specified by:
description in interface TextMatcher
Returns:
"pattern" if this matcher contains only one pattern, or "patterns" if this matcher contains more than one pattern.

formattedValues

public String formattedValues()
Returns the regular expression patterns in this matcher, formatted as a single String.

Specified by:
formattedValues in interface TextMatcher
Returns:
the regular expression patterns in this matcher, formatted as a single String.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.