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

com/ohrasys/cad/bnf/validator/FactorsValidator.java

Go to the documentation of this file.
00001 package com.ohrasys.cad.bnf.validator;
00002 import com.ohrasys.cad.bnf.*;
00003 import java.util.*;
00004 
00005 public class FactorsValidator
00006   extends BNFRequiredTest {
00007   public FactorsValidator()
00008     throws BNFTestException {super(createTests());}
00009 
00010   private static BNFTestImplementor[] createTests()
00011     throws BNFTestException {
00012     BNFTestImplementor result[] = new BNFTestImplementor[] {
00013         new FactorValidator(),
00014         new BNFOptionalTest(
00015           new BNFTestImplementor[] {new SubFactorsValidator()}
00016           )
00017       };
00018     return result;
00019   }
00020   public Object collect(){
00021     if(formatting){
00022       return format(ValidatorUtils.flattenList((List)super.collect()));
00023     } else { 
00024       return ValidatorUtils.flattenList((List)super.collect());
00025     }
00026   }
00027   
00028   private Object format(Object tokens){
00029     if(!(tokens instanceof List)) return tokens;    
00030     ValidatorFormattingRules rules = null;
00031     StringBuffer result = new StringBuffer(((List)tokens).size());
00032     List tokenList = (List)tokens;
00033     for(int i = 0; i < tokenList.size(); i++){
00034       if((!rules.orSymbolWhitespace)&&(tokenList.get(i).toString().equals("|"))) {
00035         result.deleteCharAt(result.length()-1);
00036         result.append(tokenList.get(i));
00037       } else {
00038         result.append(tokenList.get(i));
00039         result.append(" ");
00040       }
00041     }
00042     return result.toString().trim();
00043   }}

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