org.fest.swing.core.matcher
Class JLabelMatcher

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<JLabel>
              extended by org.fest.swing.core.matcher.JLabelMatcher
All Implemented Interfaces:
ComponentMatcher, ResettableComponentMatcher

public final class JLabelMatcher
extends NamedComponentMatcherTemplate<JLabel>

Understands matching a JLabel by type, name or text.

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.core.matcher.NamedComponentMatcherTemplate
ANY, name
 
Method Summary
 JLabelMatcher andShowing()
          Indicates that the JLabel to match should be showing on the screen.
 JLabelMatcher andText(Pattern textPattern)
          Specifies the text to match.
 JLabelMatcher andText(String newText)
          Specifies the text to match.
static JLabelMatcher any()
          Creates a new JLabelMatcher that matches any JLabel.
protected  boolean isMatching(JLabel button)
          Indicates whether the text of the given JLabel is equal to the text in this matcher.
 String toString()
           
static JLabelMatcher withName(String name)
          Creates a new JLabelMatcher that matches a JLabel that: has a matching name (optionally) has matching text (optionally) is showing on the screen The following code listing shows how to match a JLabel by name and text: JLabelMatcher m = withName("firstName").
static JLabelMatcher withText(Pattern textPattern)
          Creates a new JLabelMatcher that matches a JLabel by its text.
static JLabelMatcher withText(String text)
          Creates a new JLabelMatcher that matches a JLabel 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 JLabelMatcher withName(String name)
Creates a new JLabelMatcher that matches a JLabel 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 JLabel by name and text:

     JLabelMatcher m = withName("firstName").andText("First Name:");
     

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

     JLabelMatcher m = withName("firstName").andText("First Name:").andShowing();
     

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

withText

public static JLabelMatcher withText(String text)
Creates a new JLabelMatcher that matches a JLabel by its text.

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

 JLabelMatcher m = withText("First Name:");
 

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

 JLabelMatcher m = withText("First Name:").andShowing();
 

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

withText

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

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

 JLabelMatcher m = withText(Pattern.compile("F.*");
 

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

 JLabelMatcher m = withText(Pattern.compile("F.*").andShowing();
 

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

any

public static JLabelMatcher any()
Creates a new JLabelMatcher that matches any JLabel.

Returns:
the created matcher.

andText

public JLabelMatcher 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 JLabelMatcher 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 JLabelMatcher andShowing()
Indicates that the JLabel to match should be showing on the screen.

Returns:
this matcher.

isMatching

@RunsInCurrentThread
protected boolean isMatching(JLabel button)
Indicates whether the text of the given JLabel 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<JLabel>
Parameters:
button - the JLabel to match.
Returns:
true if the text in the JLabel 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.