junit.extensions.jfcunit.tools
Class Operator

java.lang.Object
  extended byjunit.extensions.jfcunit.tools.Operator

public final class Operator
extends java.lang.Object

Abstract class for defining call back classes to test whether a Component that is being searched for has been found.

Author:
kevin Wilson

Nested Class Summary
static class Operator.Operation
          Operations for comparing strings.
 
Field Summary
private static java.lang.String s_cachePattern
          Pattern which was cached.
private static org.apache.regexp.RE s_cacheRE
          Cached regular expression.
private static java.lang.Object s_lock
          This is the lock for synchronizing checks of the cache.
 
Constructor Summary
private Operator()
          Constructor should be private.
 
Method Summary
static boolean evaluate(java.lang.String leftside, java.lang.String rightside, int operation, boolean ignoreCase)
          Evaluate the current operation.
private static org.apache.regexp.RE getPattern(java.lang.String pattern)
          Get the regular expression implementing the pattern.
private static boolean matchPattern(java.lang.String componentAttribute, java.lang.String patternString)
          This method is used to filter components' attributes based on a pattern specified by the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_lock

private static java.lang.Object s_lock
This is the lock for synchronizing checks of the cache.


s_cachePattern

private static java.lang.String s_cachePattern
Pattern which was cached.


s_cacheRE

private static org.apache.regexp.RE s_cacheRE
Cached regular expression.

Constructor Detail

Operator

private Operator()
Constructor should be private.

Method Detail

evaluate

public static boolean evaluate(java.lang.String leftside,
                               java.lang.String rightside,
                               int operation,
                               boolean ignoreCase)
Evaluate the current operation.

Parameters:
leftside - String to be compared.
rightside - String or Regular expression.
operation - See the Operation subclass for values.
ignoreCase - Ignore the case of the values.
Returns:
result of operation

getPattern

private static org.apache.regexp.RE getPattern(java.lang.String pattern)
Get the regular expression implementing the pattern.

Parameters:
pattern - String representation of RE.
Returns:
RE Class representation of RE.

matchPattern

private static boolean matchPattern(java.lang.String componentAttribute,
                                    java.lang.String patternString)
This method is used to filter components' attributes based on a pattern specified by the user. For example, to search for all windows with title matching 'testWindow*'. Note: If the patternString is null, we need to avoid the PatternCompiler.compile() throwing a NullPointerException and in this case, return true if the componentAttribute is also null. The pattern syntax can be found at the Jakarta RegExp API Documentation in RE.

Parameters:
componentAttribute - The attribute text of the component to match against
patternString - The pattern to match with
Returns:
boolean whether the pattern is contained within the components' attribute text


Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999