edu.neu.ccs.jpf
Class JPFBase

java.lang.Object
  |
  +--edu.neu.ccs.jpf.JPFBase
All Implemented Interfaces:
JPTConstants, SwingConstants
Direct Known Subclasses:
JPF

public class JPFBase
extends Object
implements JPTConstants

Provides the base utility methods for use in the Java Power Framework. These methods may be used to test if a class contains a required set of constructors and/or methods and may be used to provide interactive feedback to a user via a dialog box if desired.

In the following examples, Foo will represent the name of some class being tested. In all examples, a dialog will be shown if some required constructor or method is missing.

Example 1: To test if Foo declares certain constructors, use:


     return declaresConstructors(Foo.class,
         new String[] {
             "public Foo()",
             "public Foo(int x)",
             "public Foo(int x, int y)" } );
 

Example 2: To test if Foo declares certain methods, use:


     return declaresMethods(Foo.class,
         new String[] {
             "public void setX(int x)",
             "public int xValue()",
             "public void setY(int y)",
             "public int yValue()" } );
 

Example 3: To test if Foo declares certain constructors and methods, use:


     return declaresConstructorsAndMethods(Foo.class,
         new String[] {
             "public Foo()",
             "public Foo(int x)",
             "public Foo(int x, int y)" },
         new String[] {
             "public void setX(int x)",
             "public int xValue()",
             "public void setY(int y)",
             "public int yValue()" } );
 

Example 4: To test if Foo or a super class provides certain constructors and methods, replaces "declares..." with "provides..." in Example 3.

Since:
2.2

Field Summary
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
JPFBase()
           
 
Method Summary
protected  boolean declaresConstructor(Class c, String constructor)
          Returns true if the given class declares the constructor with the given signature, and, otherwise, shows a nonmodal dialog box containing the given constructor signature and an indication that the constructor is missing, and then returns false.
protected  boolean declaresConstructorNoDialog(Class c, String constructor)
          Returns true if the given class declares the constructor with the given signature, and returns false otherwise.
protected  boolean declaresConstructors(Class c, String[] constructors)
          Returns true if the given class declares all of the constructors with the given signatures, and, otherwise, shows a nonmodal dialog box containing a list of all of the given constructor signatures, and an indication of which constructors are missing, and then returns false.
protected  boolean declaresConstructorsAndMethods(Class c, String[] constructors, String[] methods)
          Returns true if the given class declares all of the constructors and methods with the given signatures, and, otherwise, shows a nonmodal dialog box containing a list of all of the given signatures and an indication of which signatures are missing, and then returns false.
protected  boolean declaresConstructorsAndMethodsNoDialog(Class c, String[] constructors, String[] methods)
          Returns true if the given class declares all of the constructors and methods with the given signatures, and otherwise returns false.
protected  boolean declaresConstructorsNoDialog(Class c, String[] constructors)
          Returns true if the given class declares all of the constructors with the given signatures, and returns false otherwise.
protected  boolean declaresMethod(Class c, String method)
          Returns true if the given class declares the method with the given signature, and, otherwise, shows a nonmodal dialog box containing the given method signature and an indication that the method is missing, and then returns false.
protected  boolean declaresMethodNoDialog(Class c, String method)
          Returns true if the given class declares the method with the given signature, and returns false otherwise.
protected  boolean declaresMethods(Class c, String[] methods)
          Returns true if the given class declares all of the methods with the given signatures, and, otherwise, shows a nonmodal dialog box containing a list of all of the given method signatures and an indication of which methods are missing, and then returns false.
protected  boolean declaresMethodsNoDialog(Class c, String[] methods)
          Returns true if the given class declares all of the methods with the given signatures, and returns false otherwise.
protected  boolean providesConstructorsAndMethods(Class c, String[] constructors, String[] methods)
          Returns true if the given class or any of its superclass ancestors declares all of the constructors and methods with the given signatures, and, otherwise, shows a nonmodal dialog box containing a list of all of the given signatures and an indication of which signatures are missing, and then returns false.
protected  boolean providesConstructorsAndMethodsNoDialog(Class c, String[] constructors, String[] methods)
          Returns true if the given class or any of its superclass ancestors declares all of the constructors and methods with the given signatures, and otherwise returns false.
protected  boolean providesMethod(Class c, String method)
          Returns true if the given class or any of its superclass ancestors declares the method with the given signature, and, otherwise, shows a nonmodal dialog box containing the given method signature and an indication that the method is missing, and then returns false.
protected  boolean providesMethodNoDialog(Class c, String method)
          Returns true if the given class or any of its superclass ancestors declares the method with the given signature, and returns false otherwise.
protected  boolean providesMethods(Class c, String[] methods)
          Returns true if all of the given signatures represent methods declared in the given class or any of its superclass ancestors, and, otherwise, shows a nonmodal dialog box containing a list of all of the given method signatures, and an indication of which methods are missing, and then returns false.
protected  boolean providesMethodsNoDialog(Class c, String[] methods)
          Returns true if all of the given signatures represent methods declared in the given class or any of its superclass ancestors, and returns false otherwise.
protected  void report(Class c, String[] constructors, boolean[] isConstructorDeclared, String[] methods, boolean[] isMethodDeclared)
          Reports using a dialog whether or not the given class declares constructors and methods with each of the given signatures, where the each array of booleans represents whether or not each constructor or method is declared.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPFBase

public JPFBase()
Method Detail

declaresMethod

protected boolean declaresMethod(Class c,
                                 String method)
Returns true if the given class declares the method with the given signature, and, otherwise, shows a nonmodal dialog box containing the given method signature and an indication that the method is missing, and then returns false.

Parameters:
c - class to test
method - text signature of method
Throws:
JPTError - if the method signature is malformed

declaresMethodNoDialog

protected boolean declaresMethodNoDialog(Class c,
                                         String method)
Returns true if the given class declares the method with the given signature, and returns false otherwise.

Parameters:
c - class to test
method - text signature of method
Throws:
JPTError - if the method signature is malformed

providesMethod

protected boolean providesMethod(Class c,
                                 String method)
Returns true if the given class or any of its superclass ancestors declares the method with the given signature, and, otherwise, shows a nonmodal dialog box containing the given method signature and an indication that the method is missing, and then returns false.

Parameters:
c - class to test
method - text signature of method
Throws:
JPTError - if the method signature is malformed

providesMethodNoDialog

protected boolean providesMethodNoDialog(Class c,
                                         String method)
Returns true if the given class or any of its superclass ancestors declares the method with the given signature, and returns false otherwise.

Parameters:
c - class to test
method - text signature of method
Throws:
JPTError - if the method signature is malformed

declaresMethods

protected boolean declaresMethods(Class c,
                                  String[] methods)
Returns true if the given class declares all of the methods with the given signatures, and, otherwise, shows a nonmodal dialog box containing a list of all of the given method signatures and an indication of which methods are missing, and then returns false.

Parameters:
c - class to test
methods - text signatures of methods
Throws:
JPTError - if one of the method signatures is malformed

declaresMethodsNoDialog

protected boolean declaresMethodsNoDialog(Class c,
                                          String[] methods)
Returns true if the given class declares all of the methods with the given signatures, and returns false otherwise.

Parameters:
c - class to test
methods - text signatures of methods
Throws:
JPTError - if one of the method signatures is malformed

providesMethods

protected boolean providesMethods(Class c,
                                  String[] methods)
Returns true if all of the given signatures represent methods declared in the given class or any of its superclass ancestors, and, otherwise, shows a nonmodal dialog box containing a list of all of the given method signatures, and an indication of which methods are missing, and then returns false.

Parameters:
c - class to test
methods - text signatures of methods
Throws:
JPTError - if one of the method signatures is malformed

providesMethodsNoDialog

protected boolean providesMethodsNoDialog(Class c,
                                          String[] methods)
Returns true if all of the given signatures represent methods declared in the given class or any of its superclass ancestors, and returns false otherwise.

Parameters:
c - class to test
methods - text signatures of methods
Throws:
JPTError - if one of the method signatures is malformed

declaresConstructor

protected boolean declaresConstructor(Class c,
                                      String constructor)
Returns true if the given class declares the constructor with the given signature, and, otherwise, shows a nonmodal dialog box containing the given constructor signature and an indication that the constructor is missing, and then returns false.

Parameters:
c - class to test
constructor - text signature of constructor
Throws:
JPTError - if the constructor signature is malformed

declaresConstructorNoDialog

protected boolean declaresConstructorNoDialog(Class c,
                                              String constructor)
Returns true if the given class declares the constructor with the given signature, and returns false otherwise.

Parameters:
c - class to test
constructor - text signature of constructor
Throws:
JPTError - if the constructor signature is malformed

declaresConstructors

protected boolean declaresConstructors(Class c,
                                       String[] constructors)
Returns true if the given class declares all of the constructors with the given signatures, and, otherwise, shows a nonmodal dialog box containing a list of all of the given constructor signatures, and an indication of which constructors are missing, and then returns false.

Parameters:
c - class to test
constructors - text signatures of constructors
Throws:
JPTError - if one of the constructor signatures is malformed

declaresConstructorsNoDialog

protected boolean declaresConstructorsNoDialog(Class c,
                                               String[] constructors)
Returns true if the given class declares all of the constructors with the given signatures, and returns false otherwise.

Parameters:
c - class to test
constructors - text signatures of constructors
Throws:
JPTError - if one of the constructor signatures is malformed

declaresConstructorsAndMethods

protected boolean declaresConstructorsAndMethods(Class c,
                                                 String[] constructors,
                                                 String[] methods)
Returns true if the given class declares all of the constructors and methods with the given signatures, and, otherwise, shows a nonmodal dialog box containing a list of all of the given signatures and an indication of which signatures are missing, and then returns false.

Parameters:
c - class to test
constructors - text signatures of constructors
Throws:
JPTError - if one of the signatures is malformed

declaresConstructorsAndMethodsNoDialog

protected boolean declaresConstructorsAndMethodsNoDialog(Class c,
                                                         String[] constructors,
                                                         String[] methods)
Returns true if the given class declares all of the constructors and methods with the given signatures, and otherwise returns false.

Parameters:
c - class to test
constructors - text signatures of constructors
Throws:
JPTError - if one of the signatures is malformed

providesConstructorsAndMethods

protected boolean providesConstructorsAndMethods(Class c,
                                                 String[] constructors,
                                                 String[] methods)
Returns true if the given class or any of its superclass ancestors declares all of the constructors and methods with the given signatures, and, otherwise, shows a nonmodal dialog box containing a list of all of the given signatures and an indication of which signatures are missing, and then returns false.

Parameters:
c - class to test
constructors - text signatures of constructors
Throws:
JPTError - if one of the signatures is malformed

providesConstructorsAndMethodsNoDialog

protected boolean providesConstructorsAndMethodsNoDialog(Class c,
                                                         String[] constructors,
                                                         String[] methods)
Returns true if the given class or any of its superclass ancestors declares all of the constructors and methods with the given signatures, and otherwise returns false.

Parameters:
c - class to test
constructors - text signatures of constructors
Throws:
JPTError - if one of the signatures is malformed

report

protected void report(Class c,
                      String[] constructors,
                      boolean[] isConstructorDeclared,
                      String[] methods,
                      boolean[] isMethodDeclared)
Reports using a dialog whether or not the given class declares constructors and methods with each of the given signatures, where the each array of booleans represents whether or not each constructor or method is declared.

Parameters:
c - the class to contain required methods
constructors - text signatures of the required constructors
isConstructorDeclared - whether or not each required constructor is declared
methods - text signatures of the required methods
isMethodDeclared - whether or not each required method is declared