1 package com.genimen.djeneric.tools.generator.core.util; 2 3 import java.util.Stack ; 4 5 import com.genimen.djeneric.repository.DjObject; 6 import com.genimen.djeneric.repository.DjPersistenceManager; 7 import com.genimen.djeneric.repository.DjSession; 8 import com.genimen.djeneric.repository.exceptions.DjenericException; 9 10 public class ParseContext 11 { 12 ObjectStack _contextStack = new ObjectStack(); 13 ConstantStack _constStack = new ConstantStack(); 14 DjPersistenceManager _mgr; 15 DjSession _session; 16 17 Stack _cIndexStack = new Stack (); 18 Stack _dIndexStack = new Stack (); 19 20 public ParseContext(DjPersistenceManager mgr) throws DjenericException 21 { 22 _mgr = mgr; 23 _session = mgr.createSession(); 24 } 25 26 public ContextObject pushObject(String name, DjObject obj) 27 { 28 return _contextStack.push(name, obj); 29 } 30 31 public ContextObject pushObject(ContextObject co) 32 { 33 return (ContextObject) _contextStack.push(co); 34 } 35 36 public Constant pushConst(String name, Object value) 37 { 38 return _constStack.push(name, value); 39 } 40 41 public void mark() 42 { 43 _cIndexStack.push(new Integer (_contextStack.size())); 44 _dIndexStack.push(new Integer (_constStack.size())); 45 } 46 47 public void releaseToMark() 48 { 49 int c = ((Integer ) _cIndexStack.pop()).intValue(); 50 int d = ((Integer ) _dIndexStack.pop()).intValue(); 51 52 _contextStack.setSize(c); 53 _constStack.setSize(d); 54 } 55 56 public ObjectStack getObjectStack() 57 { 58 return _contextStack; 59 } 60 61 public ConstantStack getConstStack() 62 { 63 return _constStack; 64 } 65 66 public DjPersistenceManager getManager() 67 { 68 return _mgr; 69 } 70 71 public DjSession getSession() 72 { 73 return _session; 74 } 75 76 public Convention getConvention() 77 { 78 return new DefaultConvention(); 79 } 80 } | Popular Tags |