KickJava   Java API By Example, From Geeks To Geeks.

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


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