org.fest.swing.finder
Class ComponentFinderTemplate<T extends Component>

java.lang.Object
  extended by org.fest.swing.finder.ComponentFinderTemplate<T>
Type Parameters:
T - the type of component this finder can search.
Direct Known Subclasses:
JFileChooserFinder, JOptionPaneFinder, WindowFinderTemplate

public abstract class ComponentFinderTemplate<T extends Component>
extends Object

Understands a template for Component finders.

Author:
Yvonne Wang, Alex Ruiz

Constructor Summary
protected ComponentFinderTemplate(Class<? extends T> componentType)
          Creates a new ComponentFinderTemplate.
protected ComponentFinderTemplate(GenericTypeMatcher<? extends T> matcher)
          Creates a new ComponentFinderTemplate.
protected ComponentFinderTemplate(String componentName, Class<? extends T> componentType)
          Creates a new ComponentFinderTemplate.
 
Method Summary
protected abstract  T cast(Component c)
          Casts the given Component to the type supported by this finder.
protected  T findComponentWith(Robot robot)
          Finds the component using either by name or type.
abstract  ComponentFixture<T> using(Robot robot)
          Finds a component by name or type using the given robot.
protected  ComponentFinderTemplate<T> withTimeout(long newTimeout)
          Sets the timeout for this finder.
protected  ComponentFinderTemplate<T> withTimeout(long newTimeout, TimeUnit unit)
          Sets the timeout for this finder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentFinderTemplate

protected ComponentFinderTemplate(String componentName,
                                  Class<? extends T> componentType)
Creates a new ComponentFinderTemplate.

Parameters:
componentName - the name of the Component to find.
componentType - the type of the Component to find.

ComponentFinderTemplate

protected ComponentFinderTemplate(GenericTypeMatcher<? extends T> matcher)
Creates a new ComponentFinderTemplate.

Parameters:
matcher - specifies the search criteria to use when looking up a Component.

ComponentFinderTemplate

protected ComponentFinderTemplate(Class<? extends T> componentType)
Creates a new ComponentFinderTemplate.

Parameters:
componentType - the type of the Component to find.
Method Detail

withTimeout

protected ComponentFinderTemplate<T> withTimeout(long newTimeout,
                                                 TimeUnit unit)
Sets the timeout for this finder. The Component to find should be found within the given time period.

Parameters:
newTimeout - the period of time the search should be performed.
unit - the time unit for timeout.
Returns:
this finder.
Throws:
NullPointerException - if the time unit is null.
IllegalArgumentException - if the timeout is a negative number.

withTimeout

protected ComponentFinderTemplate<T> withTimeout(long newTimeout)
Sets the timeout for this finder. The Component to find should be found within the given time period.

Parameters:
newTimeout - the number of milliseconds before stopping the search.
Returns:
this finder.
Throws:
IllegalArgumentException - if the timeout is a negative number.

using

public abstract ComponentFixture<T> using(Robot robot)
Finds a component by name or type using the given robot.

Parameters:
robot - contains the underlying finding to delegate the search to.
Returns:
a fixture capable of managing the found component.
Throws:
WaitTimedOutError - if a component with the given name or of the given type could not be found.

findComponentWith

protected final T findComponentWith(Robot robot)
Finds the component using either by name or type.

Parameters:
robot - contains the underlying finding to delegate the search to.
Returns:
the found component.
Throws:
WaitTimedOutError - if a component with the given name or of the given type could not be found.

cast

protected abstract T cast(Component c)
Casts the given Component to the type supported by this finder.

Parameters:
c - the given Component.
Returns:
the given Component casted to the type supported by this finder.


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