1 package com.daffodilwoods.daffodildb.utils.parser; 2 3 import java.util.ArrayList ; 4 import java.lang.reflect.Array ; 5 import com.daffodilwoods.database.utility.P; 6 7 public class RepetitiveProductionRules extends ProductionRules{ 8 9 10 RepetitiveProductionRules(ClassLoader classLoader0){ 11 super(classLoader0); 12 } 13 14 public String toString(){ 15 return nameOfRule; 16 } 17 18 Object parsePart(ParseElements pe)throws com.daffodilwoods.database.resource.DException{ 19 ProductionRules pr = (ProductionRules)rules[0]; 20 Object object = pr.parse(pe); 21 if(object instanceof ParseException){ 22 return pe.parseException; 23 } 24 ArrayList arr = new ArrayList (); 25 do{ 26 int position = pe.position; 27 arr.add(object); 28 if(pe.position >= pe.query.length() ) 29 break; 30 object = pr.parse(pe); 31 }while(!(object instanceof ParseException)); 32 int i = 0; 33 Class tempClass = null; 34 try{ 35 tempClass = classLoader.loadClass(pr.className); 36 Object array = Array.newInstance(tempClass,arr.size()); 37 int size = arr.size(); 38 if(size == 0) 39 return null; 40 for (i = 0; i < size; i++) { 41 Array.set(array,i,arr.get(i)); 42 } 43 return array; 44 }catch(Exception E){ 45 } 46 return pe.parseException; 47 } 48 } 49 50 51 | Popular Tags |