1 22 23 package org.xquark.mapper.util; 24 25 26 import java.util.*; 27 28 public class BaseTypedList implements Cloneable 29 { 30 private static final String RCSRevision = "$Revision: 1.1 $"; 31 private static final String RCSName = "$Name: $"; 32 public List list; 33 34 public BaseTypedList() 35 { 36 this.list = new ArrayList(); 37 } 38 39 public BaseTypedList(int size) 40 { 41 this.list = new ArrayList(size); 42 } 43 44 public BaseTypedList(List list) 45 { 46 this.list = list; 47 } 48 49 public int size() 50 { 51 if(list==null) 52 return 0; 53 return list.size(); 54 } 55 56 public void add(Object obj) 57 { 58 list.add(obj); 59 } 60 61 public void add(int i, Object obj) 62 { 63 list.add(i, obj); 64 } 65 66 public void clear() 67 { 68 list.clear(); 69 } 70 71 public void remove(int index) 72 { 73 list.remove(index); 74 } 75 76 public void remove(Object element) 77 { 78 list.remove(element); 79 } 80 81 public void removeLast() 82 { 83 list.remove(list.size() - 1); 84 } 85 86 public List getList() 87 { 88 return list; 89 } 90 91 public void set(int index, Object element) 92 { 93 list.set(index, element); 94 } 95 96 97 public BaseTypedList subList(int begin, int end) 98 { 99 return new BaseTypedList(list.subList(begin, end)); 100 } 101 102 public ListIterator listIterator() 103 { 104 return list.listIterator(); 105 } 106 107 public Iterator iterator() 108 { 109 return list.iterator(); 110 } 111 112 public int hashCode() 113 { 114 return list.hashCode(); 115 } 116 117 public boolean equals(Object o) 118 { 119 if (( o != null) && (o instanceof BaseTypedList)) 120 return this.list.equals(((BaseTypedList)o).list); 121 else 122 return false; 123 } 124 125 public String toString() 126 { 127 return list.toString(); 128 } 129 130 public Object clone() 131 { 132 BaseTypedList o = null; 133 try { 134 o = (BaseTypedList)super.clone(); 135 o.list = (List)((ArrayList)o.list).clone(); 136 } 137 catch (CloneNotSupportedException e) { 138 throw new RuntimeException ("The List supplied to build the typed list is not clonable"); 139 } 140 return o; 141 } 142 } 143 | Popular Tags |