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

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

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