|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.jpf.JPFBase
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.
| Nested Class Summary | |
private static class |
JPFBase.ConstructorSignature
Encapsulates constructor signature attributes. |
private static class |
JPFBase.MemberSignature
Encapsulates signature attributes for a class member. |
private static class |
JPFBase.MethodSignature
Encapsulates a method signature. |
private static class |
JPFBase.ParametrizedSignature
Encapsulates a parametrized member signature. |
| Field Summary | |
private static PaintAction |
CHECK_ACTION
GUI component representing a green check mark. |
private static PaintAction |
X_ACTION
GUI component representing a red X mark. |
| 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. |
private boolean |
hasConstructorImpl(Class c,
String constructor)
Returns true if the given class
declares the constructor with the given signature,
or false otherwise. |
private boolean |
hasConstructorsAndMethods(Class c,
String[] constructors,
String[] methods,
boolean recurse,
boolean showDialog)
Returns true if all of the given signatures
represent methods and constructors declared in the given class,
or if the recurse option is set,
if all of the given signatures represent methods and constructors
declared in the class and its superclasses,
and returns false otherwise. |
private boolean |
hasMethodImpl(Class c,
String method,
boolean recurse)
Returns true if the given class
declares the method with the given signature,
or 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 |
| Field Detail |
private static final PaintAction CHECK_ACTION
private static final PaintAction X_ACTION
| Constructor Detail |
public JPFBase()
| Method Detail |
protected boolean declaresMethod(Class c,
String method)
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.
c - class to testmethod - text signature of method
JPTError - if the method signature is malformed
protected boolean declaresMethodNoDialog(Class c,
String method)
true if the given class
declares the method with the given signature,
and returns false otherwise.
c - class to testmethod - text signature of method
JPTError - if the method signature is malformed
protected boolean providesMethod(Class c,
String method)
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.
c - class to testmethod - text signature of method
JPTError - if the method signature is malformed
protected boolean providesMethodNoDialog(Class c,
String method)
true if the given class
or any of its superclass ancestors
declares the method with the given signature,
and returns false otherwise.
c - class to testmethod - text signature of method
JPTError - if the method signature is malformed
protected boolean declaresMethods(Class c,
String[] methods)
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.
c - class to testmethods - text signatures of methods
JPTError - if one of the method signatures is malformed
protected boolean declaresMethodsNoDialog(Class c,
String[] methods)
true if the given class
declares all of the methods with the given signatures,
and returns false otherwise.
c - class to testmethods - text signatures of methods
JPTError - if one of the method signatures is malformed
protected boolean providesMethods(Class c,
String[] methods)
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.
c - class to testmethods - text signatures of methods
JPTError - if one of the method signatures is malformed
protected boolean providesMethodsNoDialog(Class c,
String[] methods)
true if all of the given signatures
represent methods declared in the given class
or any of its superclass ancestors,
and returns false otherwise.
c - class to testmethods - text signatures of methods
JPTError - if one of the method signatures is malformed
protected boolean declaresConstructor(Class c,
String constructor)
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.
c - class to testconstructor - text signature of constructor
JPTError - if the constructor signature is malformed
protected boolean declaresConstructorNoDialog(Class c,
String constructor)
true if the given class
declares the constructor with the given signature,
and returns false otherwise.
c - class to testconstructor - text signature of constructor
JPTError - if the constructor signature is malformed
protected boolean declaresConstructors(Class c,
String[] constructors)
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.
c - class to testconstructors - text signatures of constructors
JPTError - if one of the constructor signatures is malformed
protected boolean declaresConstructorsNoDialog(Class c,
String[] constructors)
true if the given class
declares all of the constructors with the given signatures,
and returns false otherwise.
c - class to testconstructors - text signatures of constructors
JPTError - if one of the constructor signatures is malformed
protected boolean declaresConstructorsAndMethods(Class c,
String[] constructors,
String[] methods)
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.
c - class to testconstructors - text signatures of constructorsmethods - text signatures of methods
JPTError - if one of the signatures is malformed
protected boolean declaresConstructorsAndMethodsNoDialog(Class c,
String[] constructors,
String[] methods)
true if the given class
declares all of the constructors and methods
with the given signatures,
and otherwise returns false.
c - class to testconstructors - text signatures of constructorsmethods - text signatures of methods
JPTError - if one of the signatures is malformed
protected boolean providesConstructorsAndMethods(Class c,
String[] constructors,
String[] methods)
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.
c - class to testconstructors - text signatures of constructorsmethods - text signatures of methods
JPTError - if one of the signatures is malformed
protected boolean providesConstructorsAndMethodsNoDialog(Class c,
String[] constructors,
String[] methods)
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.
c - class to testconstructors - text signatures of constructorsmethods - text signatures of methods
JPTError - if one of the signatures is malformed
protected void report(Class c,
String[] constructors,
boolean[] isConstructorDeclared,
String[] methods,
boolean[] isMethodDeclared)
c - the class to contain required methodsconstructors - text signatures of the required constructorsisConstructorDeclared - whether or not
each required constructor is declaredmethods - text signatures of the required methodsisMethodDeclared - whether or not
each required method is declared
private boolean hasConstructorsAndMethods(Class c,
String[] constructors,
String[] methods,
boolean recurse,
boolean showDialog)
true if all of the given signatures
represent methods and constructors declared in the given class,
or if the recurse option is set,
if all of the given signatures represent methods and constructors
declared in the class and its superclasses,
and returns false otherwise.
If the dialog option is set, as a side effect
this method shows a nonmodal dialog box containing
a list of all of the given method signatures,
and an indication of which methods are missing.
c - class to testmethods - text signatures of methodsrecurse - whether or not to search superclasses
JPTError - if one of the method signatures is malformed
private boolean hasMethodImpl(Class c,
String method,
boolean recurse)
true if the given class
declares the method with the given signature,
or false otherwise.
c - class to testmethod - text signature of method
JPTError - if the method signature is malformed
private boolean hasConstructorImpl(Class c,
String constructor)
true if the given class
declares the constructor with the given signature,
or false otherwise.
c - class to testconstructor - text signature of constructor
JPTError - if the method signature is malformed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||