KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > commons > utils > ListenerStack


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.commons.utils;
6
7 import java.util.ArrayList JavaDoc ;
8 /**
9  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
10  * @since Nov 10, 2004
11  * @version $Id$
12  */

13 public class ListenerStack extends ArrayList JavaDoc {
14   public ListenerStack() {
15     super() ;
16   }
17   
18   public ListenerStack(int size) {
19     super(size) ;
20   }
21   
22   public void add(int index, Object JavaDoc element) {
23     throw new UnsupportedOperationException JavaDoc("use add(java.lang.Object)") ;
24   }
25   
26   public boolean add(java.lang.Object JavaDoc obj) {
27     String JavaDoc name = obj.getClass().getName();
28     for(int i = 0; i < size(); i++) {
29       Object JavaDoc found = get(i) ;
30       if(name.equals(found.getClass().getName())) {
31         remove(i) ;
32         break ;
33       }
34     }
35     return super.add(obj) ;
36   }
37 }
38
Popular Tags