1 package com.genimen.djeneric.tools.generator.core.util; 2 3 import java.util.Stack ; 4 5 public class ConstantStack extends Stack 6 { 7 private static final long serialVersionUID = 1L; 8 9 public ConstantStack() 10 { 11 } 12 13 public Constant push(String name, Object value) 14 { 15 Constant sp = new Constant(name, value); 16 push(sp); 17 return sp; 18 } 19 20 public Constant getConstant(int i) 21 { 22 return (Constant) get(i); 23 } 24 25 public Object lookup(String name) 26 { 27 for (int i = size() - 1; i >= 0; i--) 28 { 29 Constant obj = getConstant(i); 30 if (obj.getName().equals(name)) return obj.getValue(); 31 } 32 return null; 33 } 34 35 } | Popular Tags |