KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > tools > generator > core > util > ConstantStack


1 package com.genimen.djeneric.tools.generator.core.util;
2
3 import java.util.Stack JavaDoc;
4
5 public class ConstantStack extends Stack JavaDoc
6 {
7   private static final long serialVersionUID = 1L;
8
9   public ConstantStack()
10   {
11   }
12
13   public Constant push(String JavaDoc name, Object JavaDoc 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 JavaDoc lookup(String JavaDoc 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