org.fest.swing.core.matcher
Class JTextComponentMatcher

java.lang.Object
  extended by org.fest.swing.core.AbstractComponentMatcher
      extended by org.fest.swing.core.GenericTypeMatcher<T>
          extended by org.fest.swing.core.matcher.NamedComponentMatcherTemplate<JTextComponent>
              extended by org.fest.swing.core.matcher.JTextComponentMatcher
All Implemented Interfaces:
ComponentMatcher, ResettableComponentMatcher

public final class JTextComponentMatcher
extends NamedComponentMatcherTemplate<JTextComponent>

Understands matching a JTextComponent by type, name or text.

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.core.matcher.NamedComponentMatcherTemplate
ANY, name
 
Method Summary
 JTextComponentMatcher andShowing()
          Indicates that the JTextComponent to match should be showing on the screen.
 JTextComponentMatcher andText(Pattern textPattern)
          Specifies the text to match.
 JTextComponentMatcher andText(String newText)
          Specifies the text to match.
static JTextComponentMatcher any()
          Creates a new JTextComponentMatcher that matches any JTextComponent.
protected  boolean isMatching(JTextComponent button)
          Indicates whether the text of the given JTextComponent is equal to the text in this matcher.
 String toString()
           
static JTextComponentMatcher withName(String name)
          Creates a new JTextComponentMatcher that matches a JTextComponent that: has a matching name (optionally) has matching text (optionally) is showing on the screen The following code listing shows how to match a JTextComponent by name and text: JTextComponentMatcher m = withName("lastName").
static JTextComponentMatcher withText(Pattern textPattern)
          Creates a new JTextComponentMatcher that matches a JTextComponent by its text.
static JTextComponentMatcher withText(String text)
          Creates a new JTextComponentMatcher that matches a JTextComponent by its text.
 
Methods inherited from class org.fest.swing.core.matcher.NamedComponentMatcherTemplate
arePropertyValuesMatching, isNameMatching, quoted, quotedName
 
Methods inherited from class org.fest.swing.core.GenericTypeMatcher
matches, supportedType
 
Methods inherited from class org.fest.swing.core.AbstractComponentMatcher
requireShowing, requireShowing, requireShowingMatches, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

withName

public static JTextComponentMatcher withName(String name)
Creates a new JTextComponentMatcher that matches a JTextComponent that:
  1. has a matching name
  2. (optionally) has matching text
  3. (optionally) is showing on the screen
  4. The following code listing shows how to match a JTextComponent by name and text:

     JTextComponentMatcher m = withName("lastName").andText("Wang");
     

    The following code listing shows how to match a JTextComponent, that should be showing on the screen, by name and text:

     JTextComponentMatcher m = withName("lastName").andText("Wang").andShowing();
     

    Parameters:
    name - the id to match.
    Returns:
    the created matcher.

withText

public static JTextComponentMatcher withText(String text)
Creates a new JTextComponentMatcher that matches a JTextComponent by its text.

The following code listing shows how to match a JTextComponent by text:

 JTextComponentMatcher m = withText("Wang");
 

The following code listing shows how to match a JTextComponent, that should be showing on the screen, by text:

 JTextComponentMatcher m = withText("Wang").andShowing();
 

Parameters:
text - the text to match. It can be a regular expression.
Returns:
the created matcher.

withText

public static JTextComponentMatcher withText(Pattern textPattern)
Creates a new JTextComponentMatcher that matches a JTextComponent by its text.

The following code listing shows how to match a JTextComponent by text, using a regular expression pattern:

 JTextComponentMatcher m = withText(Pattern.compile("W.*"));
 

The following code listing shows how to match a JTextComponent, that should be showing on the screen, by text, using a regular expression pattern:

 JTextComponentMatcher m = withText(Pattern.compile("W.*")).andShowing();
 

Parameters:
textPattern - the text to match. It can be a regular expression.
Returns:
the created matcher.

any

public static JTextComponentMatcher any()
Creates a new JTextComponentMatcher that matches any JTextComponent.

Returns:
the created matcher.

andText

public JTextComponentMatcher andText(String newText)
Specifies the text to match. If this matcher was created using withText(String) or withText(Pattern), this method will simply update the text to match.

Parameters:
newText - the new text to match. It can be a regular expression.
Returns:
this matcher.

andText

public JTextComponentMatcher andText(Pattern textPattern)
Specifies the text to match. If this matcher was created using withText(String) or withText(Pattern), this method will simply update the text to match.

Parameters:
textPattern - the regular expression pattern to match.
Returns:
this matcher.
Since:
1.2

andShowing

public JTextComponentMatcher andShowing()
Indicates that the JTextComponent to match should be showing on the screen.

Returns:
this matcher.

isMatching

@RunsInCurrentThread
protected boolean isMatching(JTextComponent button)
Indicates whether the text of the given JTextComponent is equal to the text in this matcher.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Specified by:
isMatching in class GenericTypeMatcher<JTextComponent>
Parameters:
button - the JTextComponent to match.
Returns:
true if the text in the JTextComponent is equal to the text in this matcher, false otherwise.

toString

public String toString()
Overrides:
toString in class Object


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