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

com/ohrasys/cad/bnf/BNFTestResult.java

Go to the documentation of this file.
00001 /* Copyright (C) 2004 Thomas N. Valine
00002  * tvaline@users.sourceforge.net
00003  *
00004  * This program is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU General Public License as published by the
00006  * Free Software Foundation; either version 2 of the License, or (at your
00007  * option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License along
00015  * with this program; if not, write to the Free Software Foundation, Inc.,
00016  * 59 Temple Place - Suite 330, Boston, MA
00017  * 02111-1307, USA. */
00018 
00019 package com.ohrasys.cad.bnf;
00020 import java.util.*;
00021 
00031 public class BNFTestResult {
00033   public static final int FINISHED = 0x1;
00034 
00036   public static final int UNFINISHED = 0x2;
00037 
00039   public static final int FAILED = 0x4;
00040 
00042   protected List<BNFTestableObject> committable;
00043 
00045   protected List<BNFTestableObject> replayable;
00046 
00048   protected int status;
00049 
00053   public BNFTestResult() {
00054     committable = new Stack<BNFTestableObject>();
00055     replayable  = new Stack<BNFTestableObject>();
00056     setResult(UNFINISHED);
00057   }
00058 
00066   public boolean addCommittableToken(BNFTestableObject token) {
00067     return committable.add(token);
00068   }
00069 
00077   public boolean addCommittableTokens(List<BNFTestableObject> list) {
00078     return committable.addAll(list);
00079   }
00080 
00088   public boolean addReplayableToken(BNFTestableObject token) {
00089     return replayable.add(token);
00090   }
00091 
00099   public boolean addReplayableTokens(List<BNFTestableObject> list) {
00100     return replayable.addAll(list);
00101   }
00102 
00109   public List<BNFTestableObject> getCommittableTokens() {
00110     List<BNFTestableObject> result = committable;
00111     committable = new Vector<BNFTestableObject>();
00112 
00113     return result;
00114   }
00115 
00122   public List<BNFTestableObject> getReplayableTokens() {
00123     List<BNFTestableObject> result = replayable;
00124     replayable = new Vector<BNFTestableObject>();
00125 
00126     return result;
00127   }
00128 
00134   public boolean isFailed() {
00135     return ((status != FINISHED) && (status != UNFINISHED));
00136   }
00137 
00143   public boolean isFinished(){return status == FINISHED;}
00144 
00150   public boolean isUnfinished(){return status == UNFINISHED;}
00151 
00160   public void setResult(int result) {
00161     if((result != FINISHED) && (result != FAILED) &&
00162         (result != UNFINISHED)){throw new IllegalArgumentException();}
00163     else{status = result;}
00164   }
00165 
00171   public String toString(){return super.toString();}
00172 } // end class BNFTestResult
00173 
00174 
00175 /* This material is distributed under the GNU General Public License.
00176  * For more information please go to http://www.gnu.org/copyleft/gpl.html
00177  */

Generated on Sun Nov 13 10:13:03 2005 for JavaBackus-NaurTestAPI(JBNT) by  doxygen 1.4.2