1 30 package com.genimen.djeneric.tools.scriptengine.core.nodes; 31 32 import com.genimen.djeneric.repository.DjExtent; 33 import com.genimen.djeneric.repository.exceptions.DjenericException; 34 import com.genimen.djeneric.repository.exceptions.ObjectNotDefinedException; 35 import com.genimen.djeneric.tools.scriptengine.core.DjScriptParserEngine; 36 import com.genimen.djeneric.tools.scriptengine.core.SimpleNode; 37 import com.genimen.djeneric.tools.scriptengine.core.util.DjScriptCompileTimeScope; 38 import com.genimen.djeneric.tools.scriptengine.core.util.DjScriptExecutionException; 39 import com.genimen.djeneric.tools.scriptengine.core.util.DjScriptExecutionTimeScope; 40 41 public class NewNode extends SimpleNode implements ValueExpression 42 { 43 String _className; 44 45 public NewNode(int i) 46 { 47 super(i); 48 } 49 50 public NewNode(DjScriptParserEngine p, int i) 51 { 52 super(p, i); 53 } 54 55 public String getName() 56 { 57 return toString(); 58 } 59 60 public String toString() 61 { 62 return _className; 63 } 64 65 public Object getValue(DjScriptExecutionTimeScope context) throws DjScriptExecutionException 66 { 67 try 68 { 69 DjExtent extent = context.getPersistenceManager().getExtent(getClassName()); 70 return context.getSession().createObject(extent); 71 } 72 catch (DjenericException e) 73 { 74 throw new DjScriptExecutionException(e, this); 75 } 76 } 77 78 public String getClassName() 79 { 80 return _className; 81 } 82 83 public void setClassName(String string) 84 { 85 _className = string; 86 } 87 88 public String getValidatedTypeName(DjScriptCompileTimeScope context) throws DjScriptExecutionException 89 { 90 try 91 { 92 return context.getPersistenceManager().getExtentByObjectType(_className).getQualifiedObjectType(); 93 } 94 catch (ObjectNotDefinedException e) 95 { 96 throw new DjScriptExecutionException(e, this); 97 } 98 } 99 100 public void validateScript(DjScriptCompileTimeScope ctxt) throws DjScriptExecutionException 101 { 102 getValidatedTypeName(ctxt); 103 } 104 105 } | Popular Tags |