Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

BNFAbstractTest Class Reference

Inheritance diagram for BNFAbstractTest:

Inheritance graph
[legend]
Collaboration diagram for BNFAbstractTest:

Collaboration graph
[legend]
List of all members.

Detailed Description

Abstract Backus-Naur test.

This is the base for all the concrete test implementations in this package.

Author:
Author
tvaline
Version:
Revision
1.33
,
Date
2005/07/26 23:19:55

Definition at line 29 of file BNFAbstractTest.java.

Public Member Functions

 BNFAbstractTest (BNFTestImplementor tests[]) throws BNFTestException
 Creates a new BNFAbstractTest object.
Object collect ()
 A method to retrieve data collected during the evaluation of this test.
void reset ()
 Resets the test state.
void setCollecting (boolean isCollecting)
 A method to turn on data collection.
void setFormatting (boolean isFormatting)
abstract BNFTestResult test (BNFTestableObject obj)
 A method to evaluate this test using the supplied testable object.
String toString ()
 Returns a text representation of the test.

Protected Member Functions

void checkTests () throws BNFTestException
 A method to check the sub-tests that comprise this test.
boolean isFirstTest ()
 A method to determine if the test is evaluating the first sub-test.
boolean isLastTest ()
 A method to determine if the test is evaluating the last sub-test.
boolean isNotLastTest ()
 A method to determine if the test is evaluating a sub-test other than the last sub-test.

Protected Attributes

List< Object > collectedData
 The list containing data collected by this test.
boolean collecting
 A flag indicating whether data collection is turned on.
List< BNFTestableObjectcommitted
 A list of all subtokens successfully processed by the sub-tests.
boolean formatting
int nextTest
 A pointer to the sub-test being evaluated.
List< BNFTestableObjectplayable
 A list of tokens to be evaluated by this test.
BNFTestResult result
 The result object for this test.
BNFTestImplementor tests []
 The list of sub-tests that comprise this test.

Static Protected Attributes

static BNFI18NFactory i18n
 The internationalized string factory.


Constructor & Destructor Documentation

BNFAbstractTest BNFTestImplementor  tests[]  )  throws BNFTestException
 

Creates a new BNFAbstractTest object.

Parameters:
tests The list of sub-tests that comprise this test.
Exceptions:
BNFTestException If the list of sub-tests is null, empty or contains null sub-tests.

Definition at line 64 of file BNFAbstractTest.java.

References BNFAbstractTest.checkTests(), BNFAbstractTest.reset(), and BNFAbstractTest.tests.

00065                             {
00066     this.collecting    = false;
00067     this.tests         = tests;
00068     this.result        = new BNFTestResult();
00069     this.playable      = new Vector<BNFTestableObject>();
00070     this.committed     = new Vector<BNFTestableObject>();
00071     this.collectedData = new Vector<Object>();
00072     checkTests();
00073     reset();
00074   }


Member Function Documentation

void checkTests  )  throws BNFTestException [protected]
 

A method to check the sub-tests that comprise this test.

Exceptions:
BNFTestException If the sub-test list is null, zero length or contains a null sub-test

Reimplemented in BNFNoFallthruTest.

Definition at line 156 of file BNFAbstractTest.java.

References BNFI18NFactory.getString(), BNFAbstractTest.i18n, BNFI18NFactory.i18n_TST_REQD, and BNFAbstractTest.tests.

Referenced by BNFAbstractTest.BNFAbstractTest().

00157                             {
00158     if((tests == null) || (tests.length == 0)) {
00159       throw new BNFTestException(
00160         i18n.getString(i18n.i18n_TST_REQD));
00161     }
00162     for(int i = 0;i < tests.length;i++) {
00163       if(tests[i] == null) {
00164         throw new BNFTestException(
00165           i18n.getString(i18n.i18n_TST_REQD));
00166       }
00167     }
00168   }

Object collect  ) 
 

A method to retrieve data collected during the evaluation of this test.

Returns:
A list containing the data collected by this test during evaluation

Implements BNFTestImplementor.

Reimplemented in AssignmentValidator, BNFValidator, BracedTermValidator, BracketedTermValidator, FactorsValidator, IdentifierValidator, QuotedValidator, RuleValidator, and TermValidator.

Definition at line 94 of file BNFAbstractTest.java.

References BNFAbstractTest.collectedData, BNFAbstractTest.collecting, and BNFAbstractTest.result.

Referenced by BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreRequiredTest.test(), BNFOneOrMoreOptionalTest.test(), and BNFOneOfManyRequiredTest.test().

00094                           {
00095     List<Object> result;
00096     if(collecting) {
00097       result        = collectedData;
00098       collectedData = new Vector<Object>();
00099     } else{result = new Vector<Object>(0);}
00100 
00101     return result;
00102   }

boolean isFirstTest  )  [protected]
 

A method to determine if the test is evaluating the first sub-test.

Returns:
true if the first sub-test is being evaluated

Definition at line 175 of file BNFAbstractTest.java.

References BNFAbstractTest.nextTest, and BNFAbstractTest.tests.

00175                                   {
00176     if((tests == null) || (tests.length == 0)){return true;}
00177     else{return nextTest == 0;}
00178   }

boolean isLastTest  )  [protected]
 

A method to determine if the test is evaluating the last sub-test.

Returns:
true if the last sub-test is being evaluated

Definition at line 185 of file BNFAbstractTest.java.

References BNFAbstractTest.nextTest, and BNFAbstractTest.tests.

Referenced by BNFAbstractTest.isNotLastTest(), BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreRequiredTest.test(), BNFOneOrMoreOptionalTest.test(), and BNFOneOfManyRequiredTest.test().

00185                                  {
00186     if((tests == null) || (tests.length == 0)){return true;}
00187     else{return nextTest == (tests.length - 1);}
00188   }

boolean isNotLastTest  )  [protected]
 

A method to determine if the test is evaluating a sub-test other than the last sub-test.

Returns:
true if the last sub-test is not being evaluated

Definition at line 196 of file BNFAbstractTest.java.

References BNFAbstractTest.isLastTest().

00196 {return !isLastTest();}

void reset  ) 
 

Resets the test state.

Implements BNFTestImplementor.

Reimplemented in BNFOneOrMoreRequiredTest.

Definition at line 105 of file BNFAbstractTest.java.

References BNFAbstractTest.nextTest, BNFTestImplementor.reset(), and BNFAbstractTest.tests.

Referenced by BNFAbstractTest.BNFAbstractTest(), BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreOptionalTest.test(), and BNFOneOfManyRequiredTest.test().

00105                       {
00106     nextTest = 0;
00107     if(tests != null) {
00108       for(int i = 0;i < tests.length;i++) {
00109         if(tests[i] != null){tests[i].reset();}
00110       }
00111     }
00112   }

void setCollecting boolean  isCollecting  ) 
 

A method to turn on data collection.

Parameters:
isCollecting true if data should be collecting during test evaluation

Implements BNFTestImplementor.

Definition at line 120 of file BNFAbstractTest.java.

References BNFAbstractTest.collecting, BNFTestImplementor.setCollecting(), and BNFAbstractTest.tests.

00120                                                   {
00121     collecting = isCollecting;
00122     if(tests != null) {
00123       for(int i = 0;i < tests.length;i++) {
00124         tests[i].setCollecting(isCollecting);
00125       }
00126     }
00127   }

void setFormatting boolean  isFormatting  ) 
 

Implements BNFTestImplementor.

Definition at line 128 of file BNFAbstractTest.java.

References BNFAbstractTest.formatting, BNFTestImplementor.setFormatting(), and BNFAbstractTest.tests.

00128                                                   {
00129     formatting = isFormatting;
00130     if(tests != null) {
00131       for(int i = 0;i < tests.length;i++) {
00132         tests[i].setFormatting(isFormatting);
00133       }
00134     }
00135   }

abstract BNFTestResult test BNFTestableObject  obj  )  [pure virtual]
 

A method to evaluate this test using the supplied testable object.

Parameters:
obj The testable object from which to extract the token
Returns:
A BNFTestResult object containing a list of tokens that may be committed by the calling test, a list of tokens that must be replayed by the calling test and the completion status of the test.

Implements BNFTestImplementor.

Implemented in BNFNoFallthruTest, BNFOneOfManyRequiredTest, BNFOneOrMoreOptionalTest, BNFOneOrMoreRequiredTest, BNFOptionalTest, and BNFRequiredTest.

String toString  ) 
 

Returns a text representation of the test.

Returns:
A text representation of the test

Reimplemented in BNFNoFallthruTest, BNFOneOfManyRequiredTest, BNFOneOrMoreOptionalTest, BNFOneOrMoreRequiredTest, BNFOptionalTest, and BNFRequiredTest.

Definition at line 142 of file BNFAbstractTest.java.

References BNFI18NFactory.getString(), BNFAbstractTest.i18n, BNFI18NFactory.i18n_CHLD_TSTS, and BNFAbstractTest.tests.

00142                            {
00143     String name     = getClass().getName();
00144     int    numtests = tests.length;
00145 
00146     return String.format(i18n.getString(i18n.i18n_CHLD_TSTS), name,
00147         numtests);
00148   }


Member Data Documentation

List<Object> collectedData [protected]
 

The list containing data collected by this test.

Definition at line 35 of file BNFAbstractTest.java.

Referenced by BNFAbstractTest.collect(), BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreRequiredTest.test(), BNFOneOrMoreOptionalTest.test(), BNFOneOfManyRequiredTest.test(), and BNFNoFallthruTest.test().

boolean collecting [protected]
 

A flag indicating whether data collection is turned on.

Definition at line 38 of file BNFAbstractTest.java.

Referenced by BNFAbstractTest.collect(), BNFAbstractTest.setCollecting(), BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreRequiredTest.test(), BNFOneOrMoreOptionalTest.test(), BNFOneOfManyRequiredTest.test(), and BNFNoFallthruTest.test().

List<BNFTestableObject> committed [protected]
 

A list of all subtokens successfully processed by the sub-tests.

Definition at line 42 of file BNFAbstractTest.java.

Referenced by BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreRequiredTest.test(), BNFOneOrMoreOptionalTest.test(), and BNFOneOfManyRequiredTest.test().

boolean formatting [protected]
 

Definition at line 39 of file BNFAbstractTest.java.

Referenced by TermValidator.collect(), RuleValidator.collect(), QuotedValidator.collect(), IdentifierValidator.collect(), FactorsValidator.collect(), BracketedTermValidator.collect(), BracedTermValidator.collect(), BNFValidator.collect(), AssignmentValidator.collect(), and BNFAbstractTest.setFormatting().

BNFI18NFactory i18n [static, protected]
 

The internationalized string factory.

Definition at line 32 of file BNFAbstractTest.java.

Referenced by BNFAbstractTest.checkTests(), BNFNoFallthruTest.toString(), and BNFAbstractTest.toString().

int nextTest [protected]
 

A pointer to the sub-test being evaluated.

Definition at line 45 of file BNFAbstractTest.java.

Referenced by BNFAbstractTest.isFirstTest(), BNFAbstractTest.isLastTest(), BNFAbstractTest.reset(), BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreRequiredTest.test(), BNFOneOrMoreOptionalTest.test(), and BNFOneOfManyRequiredTest.test().

List<BNFTestableObject> playable [protected]
 

A list of tokens to be evaluated by this test.

Definition at line 48 of file BNFAbstractTest.java.

Referenced by BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreRequiredTest.test(), BNFOneOrMoreOptionalTest.test(), and BNFOneOfManyRequiredTest.test().

BNFTestResult result [protected]
 

The result object for this test.

Definition at line 51 of file BNFAbstractTest.java.

Referenced by BNFAbstractTest.collect(), BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreRequiredTest.test(), BNFOneOrMoreOptionalTest.test(), BNFOneOfManyRequiredTest.test(), and BNFNoFallthruTest.test().

BNFTestImplementor tests[] [protected]
 

The list of sub-tests that comprise this test.

Definition at line 54 of file BNFAbstractTest.java.

Referenced by BNFAbstractTest.BNFAbstractTest(), BNFOneOfManyRequiredTest.BNFOneOfManyRequiredTest(), BNFOneOrMoreOptionalTest.BNFOneOrMoreOptionalTest(), BNFOneOrMoreRequiredTest.BNFOneOrMoreRequiredTest(), BNFOptionalTest.BNFOptionalTest(), BNFRequiredTest.BNFRequiredTest(), BNFNoFallthruTest.checkTests(), BNFAbstractTest.checkTests(), BNFAbstractTest.isFirstTest(), BNFAbstractTest.isLastTest(), BNFAbstractTest.reset(), BNFAbstractTest.setCollecting(), BNFAbstractTest.setFormatting(), BNFRequiredTest.test(), BNFOptionalTest.test(), BNFOneOrMoreRequiredTest.test(), BNFOneOrMoreOptionalTest.test(), BNFOneOfManyRequiredTest.test(), and BNFAbstractTest.toString().


The documentation for this class was generated from the following file:
Generated on Sun Nov 13 10:13:07 2005 for JavaBackus-NaurTestAPI(JBNT) by  doxygen 1.4.2