|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ComponentFinder.java | - | 100% | 100% | 100% |
|
1 |
package junit.extensions.jfcunit.finder;
|
|
2 |
|
|
3 |
import java.awt.Component;
|
|
4 |
|
|
5 |
|
|
6 |
/**
|
|
7 |
* A generic {@link java.awt.Component} finder which uses just the type (class) for filtering.
|
|
8 |
*
|
|
9 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
10 |
*/
|
|
11 |
public class ComponentFinder extends Finder { |
|
12 |
/**
|
|
13 |
* The type of the {@link java.awt.Component}.
|
|
14 |
*/
|
|
15 |
private Class m_compCls = null; |
|
16 |
|
|
17 |
/**
|
|
18 |
* Constructor accepting all arguments needed to filter the {@link java.awt.Component}.
|
|
19 |
*
|
|
20 |
* @param cls The desired type of the component.
|
|
21 |
*/
|
|
22 | 252 |
public ComponentFinder(final Class cls) {
|
23 | 252 |
setComponentClass(cls); |
24 |
} |
|
25 |
|
|
26 |
/**
|
|
27 |
* Set the class of the object to be found.
|
|
28 |
* @param cls Class of the objects to be found.
|
|
29 |
*/
|
|
30 | 253 |
public final void setComponentClass(final Class cls) { |
31 | 253 |
m_compCls = cls; |
32 |
} |
|
33 |
|
|
34 |
/**
|
|
35 |
* Get the class associated with the finder.
|
|
36 |
* @return Component class to be found by the finder.
|
|
37 |
*/
|
|
38 | 2 |
public final Class getComponentClass() {
|
39 | 2 |
return m_compCls;
|
40 |
} |
|
41 |
|
|
42 |
/**
|
|
43 |
* Method that returns true if the given {@link java.awt.Component} matches the search
|
|
44 |
* criteria.
|
|
45 |
*
|
|
46 |
* @param comp The component to test
|
|
47 |
* @return true if this component is a match
|
|
48 |
*/
|
|
49 | 24846 |
public boolean testComponent(final Component comp) { |
50 | 24846 |
return ((comp != null) && isValidForProcessing(comp, m_compCls)); |
51 |
} |
|
52 |
} |
|
53 |
|
|