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 RepetitiveProductionRulesWithHashMap extends ProductionRulesWithHashMap{ 8 9 RepetitiveProductionRulesWithHashMap(ClassLoader classLoader0){ 10 super(classLoader0); 11 } 12 13 public String toString(){ 14 return nameOfRule; 15 } 16 17 Object parsePart(ParseElements pe)throws com.daffodilwoods.database.resource.DException{ 18 ProductionRules pr = (ProductionRules)rules[0]; 19 Object object = pr.parse(pe); 20 if(object instanceof ParseException){ 21 return pe.parseException; 22 } 23 ArrayList arr = new ArrayList (); 24 do{ 25 int position = pe.position; 26 arr.add(object); 27 if(pe.position >= pe.query.length() ) 28 break; 29 object = pr.parse(pe); 30 }while(!(object instanceof ParseException)); 31 try{ 32 Class tempClass = classLoader.loadClass(pr.className); 33 Object array = Array.newInstance(tempClass,arr.size()); 34 int size = arr.size(); 35 if(size == 0) 36 return null; 37 for (int i = 0; i < size; i++) { 38 Array.set(array,i,arr.get(i)); 39 } 40 return array; 41 }catch(Exception E){E.printStackTrace();} 42 return pe.parseException; 43 } 44 } 45 46 | Popular Tags |