1 22 23 package org.xquark.mapper.util; 24 25 26 import java.util.ArrayList ; 27 28 34 35 public class Stack extends ArrayList 36 { 37 private static final String RCSRevision = "$Revision: 1.1 $"; 38 private static final String RCSName = "$Name: $"; 39 40 public Object push(Object item) 41 { 42 add(item); 43 return item; 44 } 45 46 public Object pop() 47 { 48 if (size() > 0) 49 return remove(size()-1); 50 else 51 return null; 52 } 53 54 public Object top() 55 { 56 if (size() > 0) 57 return get(size()-1); 58 else 59 return null; 60 } 61 62 public boolean empty() 63 { 64 return (size() == 0); 65 } 66 67 68 public String toString() 69 { 70 StringBuffer dummy = new StringBuffer (); 71 for(int i=0; i<size(); i++) 72 dummy.append("\n"+get(i)); 73 return dummy.toString(); 74 } 75 } 76 | Popular Tags |