/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.aop.util;

import java.util.ArrayList;

/**
 * Comment
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 * @version $Revision: 1.1.8.2 $
 */
public class ThreadLocalStack
{
   private ThreadLocal local = new ThreadLocal();

   public void push(Object obj)
   {
      ArrayList stack = (ArrayList) local.get();
      if (stack == null)
      {
         stack = new ArrayList();
         local.set(stack);
      }
      stack.add(obj);
   }

   public Object get()
   {
      ArrayList stack = (ArrayList) local.get();
      if (stack == null) return null;
      return stack.get(stack.size() - 1);
   }

   public void pop()
   {
      ArrayList stack = (ArrayList) local.get();
      stack.remove(stack.size() - 1);
   }
}
