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

com/ohrasys/cad/bnf/validator/QuotedValidator.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 QuotedValidator
00006   extends BNFRequiredTest {
00007   public QuotedValidator()
00008     throws BNFTestException {super(createTests());}
00009 
00010   private static BNFTestImplementor[] createTests()
00011     throws BNFTestException {
00012     BNFTestImplementor result[] = new BNFTestImplementor[] {
00013         new WhitespaceValidator(), new BNFNoFallthruTest('"'),
00014         new BNFOneOrMoreRequiredTest(
00015           new BNFTestImplementor[] {new SymbolValidator()}
00016           ), new BNFNoFallthruTest('"'), new WhitespaceValidator()
00017       };
00018     return result;
00019   }
00020   
00021   public Object collect(){
00022     if(formatting){
00023       return format(ValidatorUtils.flattenList((List)super.collect()));
00024     } else { 
00025       return ValidatorUtils.flattenList((List)super.collect());
00026     }
00027   }
00028   
00029   private Object format(Object tokens){
00030     if(!(tokens instanceof List)) return tokens;    
00031     StringBuffer result = new StringBuffer(((List)tokens).size());
00032     List tokenList = (List)tokens;
00033     for(int i = 0; i < tokenList.size(); i++){
00034       result.append(tokenList.get(i));
00035     }
00036     return result.toString().trim();
00037   }
00038   
00039 }

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