1 package com.daffodilwoods.daffodildb.utils.parser; 2 3 import com.daffodilwoods.database.utility.P; 4 import java.lang.reflect.Field ; 5 import com.daffodilwoods.daffodildb.utils.DBStack; 6 import com.daffodilwoods.database.resource.*; 7 8 public class SimpleProductionRulesWithHashMap extends ProductionRulesWithHashMap{ 9 10 SimpleProductionRulesWithHashMap(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 object = (ProductionRules)rules[0]; 20 String ruleName = object.getProductionRuleName(); 21 if (ruleName.equalsIgnoreCase(pe.recursionState) && object.recursiveflag ){ 22 if(pe.recursiveObject != null){ 23 Object [] parsedObject = new Object []{pe.recursiveObject}; 24 pe.recursiveObject = null; 25 pe.recursionState = null; 26 return parsedObject; 27 } 28 else 29 return pe.parseException; 30 } 31 else if(pe.recursiveObject != null && !ruleName.equalsIgnoreCase(pe.recursionState)) 32 return pe.parseException; 33 Object value = object.parse(pe); 34 if(!(value instanceof ParseException)){ 35 return ruleKey.startsWith("Rep")? value : getObjectOfClass(value); 36 } 37 return pe.parseException; 38 } 39 40 public Object getComparableObject(){ 41 if ( rules == null ) 42 return null; 43 ProductionRules object = (ProductionRules)rules[0]; 44 result = object.result; 45 return object.getComparableObject(); 46 } 47 48 public Object getComparableObjectArray(){ 49 if ( rules == null ) 50 return null; 51 ProductionRules object = (ProductionRules)rules[0]; 52 Object o[] = (Object [])object.getComparableObjectArray(); 53 if ( o != null ) 54 result = object.result; 55 return o; 56 } 57 58 public Object getRecursiveObject(String nameOfRule,DBStack occuredRules){ 59 if ( rules == null ) 60 return null; 61 ProductionRules rule = (ProductionRules)rules[0]; 62 if ( rule.nameOfRule.equalsIgnoreCase(nameOfRule) ) 63 return new Object []{this}; 64 return null; 65 } 66 67 public Object getNonRecursiveObject(String nameOfRule,DBStack occuredRules){ 68 if ( rules == null ) 69 return null; 70 ProductionRules rule = (ProductionRules)rules[0]; 71 if ( !(rule.nameOfRule.equalsIgnoreCase(nameOfRule)) ) 72 return new Object []{this}; 73 return null; 74 } 75 76 Object getObjectOfClass(Object parsedObject) throws DException{ 77 Object tempObject = null; 78 int i = 0; 79 try{ 80 if ( classMaker == null ){ 81 try{ 82 Class cls = classLoader.loadClass(className); 83 loadFields(i,cls); 84 classMaker = cls; 85 86 }catch(NoClassDefFoundError ne){ 87 throw ne; 88 } 89 } 90 91 tempObject = classMaker.newInstance(); 92 ((Field )fields[0]).set(tempObject,parsedObject); 93 }catch(Exception E){ 94 throw new DException("DSE0",new Object []{E.getMessage() }); 95 96 } 97 return tempObject; 98 } 99 } 100 101 | Popular Tags |