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

BNFOptionalTest Class Reference

Inheritance diagram for BNFOptionalTest:

Inheritance graph
[legend]
Collaboration diagram for BNFOptionalTest:

Collaboration graph
[legend]
List of all members.

Detailed Description

A test in which all sub-tests must occur zero or one time.

Author:
Author
tvaline
Version:
Revision
1.27
,
Date
2005/03/31 22:13:17

Definition at line 28 of file BNFOptionalTest.java.

Public Member Functions

 BNFOptionalTest (BNFTestImplementor tests[]) throws BNFTestException
 Creates a new BNFOptionalTest object.
BNFTestResult test (BNFTestableObject obj)
 A method to evaluate this test using the supplied testable object.
String toString ()
 Returns a text representation of this test.


Constructor & Destructor Documentation

BNFOptionalTest BNFTestImplementor  tests[]  )  throws BNFTestException
 

Creates a new BNFOptionalTest object.

Parameters:
tests The sub-tests that comprise the test
Exceptions:
BNFTestException If the sub-test list is null, zero length or one of the sub-tests is null

Definition at line 38 of file BNFOptionalTest.java.

References BNFAbstractTest.tests.

00039                            {super(tests);}


Member Function Documentation

BNFTestResult test BNFTestableObject  obj  )  [virtual]
 

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

Parameters:
obj The BNFTestableObject from which to extract the token used to evaluate this test
Returns:
A BNFTestResult object representing the result of this test. If more tokens are required to resolve the test, then UNFINISHED is returned and the results committable tokens list and replayable tokens list are empty. If the test completed successfully then FINISHED is returned and the committable tokens list contains a list of all tokens successfully processed by this test and the replayable tokens list contains a list of tokens required to be replayed. Otherwise FAILED is returned and all tokens processed by this test are returned in the replayable list.

Implements BNFAbstractTest.

Definition at line 58 of file BNFOptionalTest.java.

References BNFTestResult.addCommittableTokens(), BNFTestResult.addReplayableTokens(), BNFAbstractTest.collect(), BNFAbstractTest.collectedData, BNFAbstractTest.collecting, BNFAbstractTest.committed, BNFTestResult.FINISHED, BNFTestResult.getCommittableTokens(), BNFTestResult.getReplayableTokens(), BNFTestResult.isFinished(), BNFAbstractTest.isLastTest(), BNFTestResult.isUnfinished(), BNFAbstractTest.nextTest, BNFAbstractTest.playable, BNFAbstractTest.reset(), BNFAbstractTest.result, BNFTestResult.setResult(), BNFTestImplementor.test(), BNFAbstractTest.tests, and BNFTestResult.UNFINISHED.

00058                                                    {
00059     playable.add(0, obj);
00060     while(playable.size() > 0) {
00061       BNFTestableObject crntToken   = playable.remove(0);
00062       BNFTestResult     childResult = tests[nextTest].test(crntToken);
00063       if(childResult.isUnfinished()){result.setResult(result.UNFINISHED);}
00064       else if(childResult.isFinished()) {
00065         committed.addAll(childResult.getCommittableTokens());
00066         playable.addAll(0, childResult.getReplayableTokens());
00067         if(collecting){collectedData.add(tests[nextTest].collect());}
00068         if(isLastTest()) {
00069           result.addCommittableTokens(committed);
00070           result.addReplayableTokens(playable);
00071           result.setResult(result.FINISHED);
00072           reset();
00073           playable.clear();
00074           committed.clear();
00075         } else {
00076           result.setResult(result.UNFINISHED);
00077           nextTest++;
00078 
00079           continue;
00080         }
00081       } else {
00082         committed.addAll(childResult.getCommittableTokens());
00083         playable.addAll(0, childResult.getReplayableTokens());
00084         result.addReplayableTokens(committed);
00085         result.addReplayableTokens(playable);
00086         result.setResult(result.FINISHED);
00087         collectedData.clear();
00088         reset();
00089         playable.clear();
00090         committed.clear();
00091       }
00092     } // end while
00093     BNFTestResult testResult = result;
00094     result = new BNFTestResult();
00095 
00096     return testResult;
00097   } // end method test

String toString  ) 
 

Returns a text representation of this test.

Returns:
A text representation of this test

Reimplemented from BNFAbstractTest.

Definition at line 104 of file BNFOptionalTest.java.

00104 {return super.toString();}


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