com.ohrasys.cad.bnf
Class BNFAbstractTest

java.lang.Object
  extended by com.ohrasys.cad.bnf.BNFAbstractTest
All Implemented Interfaces:
BNFTestImplementor
Direct Known Subclasses:
BNFNoFallthruTest, BNFOneOfManyRequiredTest, BNFOneOrMoreOptionalTest, BNFOneOrMoreRequiredTest, BNFOptionalTest, BNFRequiredTest

public abstract class BNFAbstractTest
extends java.lang.Object
implements BNFTestImplementor

Abstract Backus-Naur test. This is the base for all the concrete test implementations in this package.


Field Summary
protected  java.util.List<java.lang.Object> collectedData
          The list containing data collected by this test
protected  boolean collecting
          A flag indicating whether data collection is turned on
protected  java.util.List<BNFTestableObject> committed
          A list of all subtokens successfully processed by the sub-tests
protected  boolean formatting
           
protected static com.ohrasys.cad.bnf.BNFI18NFactory i18n
          The internationalized string factory
protected  int nextTest
          A pointer to the sub-test being evaluated
protected  java.util.List<BNFTestableObject> playable
          A list of tokens to be evaluated by this test
protected  BNFTestResult result
          The result object for this test
protected  BNFTestImplementor[] tests
          The list of sub-tests that comprise this test
 
Constructor Summary
BNFAbstractTest(BNFTestImplementor[] tests)
          Creates a new BNFAbstractTest object.
 
Method Summary
protected  void checkTests()
          A method to check the sub-tests that comprise this test
 java.lang.Object collect()
          A method to retrieve data collected during the evaluation of this test
protected  boolean isFirstTest()
          A method to determine if the test is evaluating the first sub-test
protected  boolean isLastTest()
          A method to determine if the test is evaluating the last sub-test
protected  boolean isNotLastTest()
          A method to determine if the test is evaluating a sub-test other than the last sub-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.
 java.lang.String toString()
          Returns a text representation of the test
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

i18n

protected static com.ohrasys.cad.bnf.BNFI18NFactory i18n
The internationalized string factory


collectedData

protected java.util.List<java.lang.Object> collectedData
The list containing data collected by this test


collecting

protected boolean collecting
A flag indicating whether data collection is turned on


formatting

protected boolean formatting

committed

protected java.util.List<BNFTestableObject> committed
A list of all subtokens successfully processed by the sub-tests


nextTest

protected int nextTest
A pointer to the sub-test being evaluated


playable

protected java.util.List<BNFTestableObject> playable
A list of tokens to be evaluated by this test


result

protected BNFTestResult result
The result object for this test


tests

protected BNFTestImplementor[] tests
The list of sub-tests that comprise this test

Constructor Detail

BNFAbstractTest

public BNFAbstractTest(BNFTestImplementor[] tests)
                throws BNFTestException
Creates a new BNFAbstractTest object.

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

test

public abstract BNFTestResult test(BNFTestableObject obj)
A method to evaluate this test using the supplied testable object.

Specified by:
test in interface BNFTestImplementor
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.

collect

public java.lang.Object collect()
A method to retrieve data collected during the evaluation of this test

Specified by:
collect in interface BNFTestImplementor
Returns:
A list containing the data collected by this test during evaluation

reset

public void reset()
Resets the test state

Specified by:
reset in interface BNFTestImplementor

setCollecting

public void setCollecting(boolean isCollecting)
A method to turn on data collection

Specified by:
setCollecting in interface BNFTestImplementor
Parameters:
isCollecting - true if data should be collecting during test evaluation

setFormatting

public void setFormatting(boolean isFormatting)
Specified by:
setFormatting in interface BNFTestImplementor

toString

public java.lang.String toString()
Returns a text representation of the test

Overrides:
toString in class java.lang.Object
Returns:
A text representation of the test

checkTests

protected void checkTests()
                   throws BNFTestException
A method to check the sub-tests that comprise this test

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

isFirstTest

protected boolean isFirstTest()
A method to determine if the test is evaluating the first sub-test

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

isLastTest

protected boolean isLastTest()
A method to determine if the test is evaluating the last sub-test

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

isNotLastTest

protected boolean isNotLastTest()
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