edu.rice.cs.cunit.threadCheck.predicates
Class ThreadCheckPredicates

java.lang.Object
  extended by edu.rice.cs.cunit.threadCheck.predicates.ThreadCheckPredicates

public class ThreadCheckPredicates
extends java.lang.Object

Class containing several common predicates.

Author:
Mathias Ricken

Constructor Summary
ThreadCheckPredicates()
           
 
Method Summary
static boolean checkDistinctArguments(java.lang.Object thisObject, java.lang.Object[] args, int[] value)
          Return true if the object with the specified indices are all distinct.
static boolean checkEventThread(java.lang.Object thisObject)
          Return true if the current thread is the event thread.
static boolean checkEventThreadAfterRealized(java.lang.Object thisObject)
          Return true if the current thread is the event thread, or if thisObject is an instance of a subclass of java.awt.Component and that component has not been realized yet.
static boolean checkGroup(java.lang.Object thisObject, java.lang.String value, boolean regex)
          Return true if the current thread's group equals the specified string
static boolean checkMonitorNotOwned(java.lang.Object o)
          Return true if the current thread does not own the monitor of the object.
static boolean checkMonitorNotOwnedArgument(java.lang.Object thisObject, java.lang.Object[] args, int value)
          Return true if the current thread does not own the monitor of the object with index value in the array of method arguments
static boolean checkMonitorNotOwnedArgumentByAnyThread(java.lang.Object thisObject, java.lang.Object[] args, int value)
          Return true if the current thread does not own the monitor of the object with index value in the array of method arguments
static boolean checkMonitorNotOwnedByAnyThread(java.lang.Object o)
          Return true if the no thread owns the monitor of the object.
static boolean checkMonitorOwned(java.lang.Object o)
          Return true if the current thread owns the monitor of the object.
static boolean checkMonitorOwnedArgument(java.lang.Object thisObject, java.lang.Object[] args, int value)
          Return true if the current thread owns the monitor of the object with index value in the array of method arguments
static boolean checkMonitorOwnedArgumentByAnyThread(java.lang.Object thisObject, java.lang.Object[] args, int value)
          Return true if the any thread owns the monitor of the object with index value in the array of method arguments
static boolean checkMonitorOwnedByAnyThread(java.lang.Object o)
          Return true if the any thread owns the monitor of the object.
static boolean checkName(java.lang.Object thisObject, java.lang.String value, boolean regex)
          Return true if the current thread's name equals the specified string
static boolean checkNotNullArgument(java.lang.Object thisObject, java.lang.Object[] args, int value)
          Return true if the object with index value in the array of method arguments is not null.
static boolean checkNullArgument(java.lang.Object thisObject, java.lang.Object[] args, int value)
          Return true if the object with index value in the array of method arguments is null.
static boolean checkNumberBoundedArgument(java.lang.Object thisObject, java.lang.Object[] args, NumberBoundedArgument.Mode mode, int index, double bound, double upperBound)
          Return true if the object with the specified index is a Number and meeds the bounds.
static boolean checkSameArguments(java.lang.Object thisObject, java.lang.Object[] args, int[] value)
          Return true if the object with the specified indices are all the same.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadCheckPredicates

public ThreadCheckPredicates()
Method Detail

checkEventThread

public static boolean checkEventThread(java.lang.Object thisObject)
Return true if the current thread is the event thread.

Parameters:
thisObject - "this" at the time of the check, or null if not available; ignored by this method
Returns:
true if the current thread is the event thread

checkEventThreadAfterRealized

public static boolean checkEventThreadAfterRealized(java.lang.Object thisObject)
Return true if the current thread is the event thread, or if thisObject is an instance of a subclass of java.awt.Component and that component has not been realized yet.

Parameters:
thisObject - "this" at the time of the check, or null if not available; ignored by this method
Returns:
true if the current thread is the event thread, or thisObject is a component that has not been realized

checkName

public static boolean checkName(java.lang.Object thisObject,
                                java.lang.String value,
                                boolean regex)
Return true if the current thread's name equals the specified string

Parameters:
thisObject - "this" at the time of the check, or null if not available; ignored by this method
value - string to compare the current thread's name to
regex - true if value should be treated as a regular expression
Returns:
true if the current thread's name equals the specified string

checkGroup

public static boolean checkGroup(java.lang.Object thisObject,
                                 java.lang.String value,
                                 boolean regex)
Return true if the current thread's group equals the specified string

Parameters:
thisObject - "this" at the time of the check, or null if not available; ignored by this method
value - string to compare the current thread's group to
regex - true if value should be treated as a regular expression
Returns:
true if the current thread's group equals the specified string

checkMonitorOwned

public static boolean checkMonitorOwned(java.lang.Object o)
Return true if the current thread owns the monitor of the object. If this method is directly used in a predicate annotation, then the object passed is "this".

Parameters:
o - object whose monitor should be checked; must be non-null
Returns:
true if the current thread owns the monitor (false if o is null)

checkMonitorNotOwned

public static boolean checkMonitorNotOwned(java.lang.Object o)
Return true if the current thread does not own the monitor of the object. If this method is directly used in a predicate annotation, then the object passed is "this".

Parameters:
o - object whose monitor should be checked; must be non-null
Returns:
true if the current thread does not own the monitor (false if o is null)

checkMonitorOwnedArgument

public static boolean checkMonitorOwnedArgument(java.lang.Object thisObject,
                                                java.lang.Object[] args,
                                                int value)
Return true if the current thread owns the monitor of the object with index value in the array of method arguments

Parameters:
thisObject - object that represents "this", or null if static
args - array of method arguments
value - index of the method argument that should be checked
Returns:
true if the current thread owns the monitor of the argument (false if value is out of range)

checkMonitorNotOwnedArgument

public static boolean checkMonitorNotOwnedArgument(java.lang.Object thisObject,
                                                   java.lang.Object[] args,
                                                   int value)
Return true if the current thread does not own the monitor of the object with index value in the array of method arguments

Parameters:
thisObject - object that represents "this", or null if static
args - array of method arguments
value - index of the method argument that should be checked
Returns:
true if the current thread does not own the monitor of the argument (false if value is out of range)

checkMonitorOwnedByAnyThread

public static boolean checkMonitorOwnedByAnyThread(java.lang.Object o)
Return true if the any thread owns the monitor of the object. If this method is directly used in a predicate annotation, then the object passed is "this".

Parameters:
o - object whose monitor should be checked; must be non-null
Returns:
true if the any thread owns the monitor (false if o is null)

checkMonitorNotOwnedByAnyThread

public static boolean checkMonitorNotOwnedByAnyThread(java.lang.Object o)
Return true if the no thread owns the monitor of the object. If this method is directly used in a predicate annotation, then the object passed is "this".

Parameters:
o - object whose monitor should be checked; must be non-null
Returns:
true if the no thread owns the monitor (false if o is null)

checkMonitorOwnedArgumentByAnyThread

public static boolean checkMonitorOwnedArgumentByAnyThread(java.lang.Object thisObject,
                                                           java.lang.Object[] args,
                                                           int value)
Return true if the any thread owns the monitor of the object with index value in the array of method arguments

Parameters:
thisObject - object that represents "this", or null if static
args - array of method arguments
value - index of the method argument that should be checked
Returns:
true if the any thread owns the monitor of the argument (false if value is out of range)

checkMonitorNotOwnedArgumentByAnyThread

public static boolean checkMonitorNotOwnedArgumentByAnyThread(java.lang.Object thisObject,
                                                              java.lang.Object[] args,
                                                              int value)
Return true if the current thread does not own the monitor of the object with index value in the array of method arguments

Parameters:
thisObject - object that represents "this", or null if static
args - array of method arguments
value - index of the method argument that should be checked
Returns:
true if the current thread does not own the monitor of the argument (false if value is out of range)

checkNullArgument

public static boolean checkNullArgument(java.lang.Object thisObject,
                                        java.lang.Object[] args,
                                        int value)
Return true if the object with index value in the array of method arguments is null.

Parameters:
thisObject - object that represents "this", or null if static
args - array of method arguments
value - index of the method argument that should be checked
Returns:
true if the argument is null (false if value is out of range)

checkNotNullArgument

public static boolean checkNotNullArgument(java.lang.Object thisObject,
                                           java.lang.Object[] args,
                                           int value)
Return true if the object with index value in the array of method arguments is not null.

Parameters:
thisObject - object that represents "this", or null if static
args - array of method arguments
value - index of the method argument that should be checked
Returns:
true if the argument is not null (false if value is out of range)

checkNumberBoundedArgument

public static boolean checkNumberBoundedArgument(java.lang.Object thisObject,
                                                 java.lang.Object[] args,
                                                 NumberBoundedArgument.Mode mode,
                                                 int index,
                                                 double bound,
                                                 double upperBound)
Return true if the object with the specified index is a Number and meeds the bounds.

Parameters:
thisObject - object that represents "this", or null if static
args - array of method arguments
mode - bounding mode
index - index of the method argument that should be checked
bound - bound
upperBound - upper bound
Returns:
true if the number meets the bound, false otherwise, if index is out of range, or if the argument is not a Number

checkDistinctArguments

public static boolean checkDistinctArguments(java.lang.Object thisObject,
                                             java.lang.Object[] args,
                                             int[] value)
Return true if the object with the specified indices are all distinct.

Parameters:
thisObject - object that represents "this", or null if static
args - array of method arguments
value - array of indices of the method argument that should be checked
Returns:
true if the arguments are all distinct, false otherwise, if value is out of range, or if fewer than two indices are specified

checkSameArguments

public static boolean checkSameArguments(java.lang.Object thisObject,
                                         java.lang.Object[] args,
                                         int[] value)
Return true if the object with the specified indices are all the same.

Parameters:
thisObject - object that represents "this", or null if static
args - array of method arguments
value - array of indices of the method argument that should be checked
Returns:
true if the arguments are all the same, false otherwise, if value is out of range, or if fewer than two indices are specified