|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| NameMatcher.java | 50% | 66.7% | 66.7% | 63.6% |
|
||||||||||||||
| 1 |
package abbot.finder.matchers;
|
|
| 2 |
|
|
| 3 |
import java.awt.Component;
|
|
| 4 |
import abbot.finder.Matcher;
|
|
| 5 |
import abbot.util.AWT;
|
|
| 6 |
import abbot.util.ExtendedComparator;
|
|
| 7 |
|
|
| 8 |
/** Provides matching of Components by component name. */
|
|
| 9 |
public class NameMatcher extends AbstractMatcher { |
|
| 10 |
private String name;
|
|
| 11 |
|
|
| 12 |
/** Construct a matcher that will match any component that has
|
|
| 13 |
explicitly been assigned the given <code>name</code>. Auto-generated
|
|
| 14 |
names (e.g. <code>win0</code>, <code>frame3</code>, etc. for AWT
|
|
| 15 |
(native) based components will not match.
|
|
| 16 |
*/
|
|
| 17 | 30 |
public NameMatcher(String name) {
|
| 18 | 30 |
this.name = name;
|
| 19 |
} |
|
| 20 |
|
|
| 21 |
/** @return whether the given component has been explicitly assigned the
|
|
| 22 |
name given in the constructor.
|
|
| 23 |
*/
|
|
| 24 | 584 |
public boolean matches(Component c) { |
| 25 | 584 |
String cname = c.getName(); |
| 26 | 584 |
if (name == null) |
| 27 | 0 |
return cname == null || AWT.hasDefaultName(c); |
| 28 | 584 |
return stringsMatch(name, cname);
|
| 29 |
} |
|
| 30 | 0 |
public String toString() {
|
| 31 | 0 |
return "Name matcher (" + name + ")"; |
| 32 |
} |
|
| 33 |
} |
|
| 34 |
|
|
||||||||||