1 25 package org.objectweb.jonas_ejb.container.jorm; 26 27 import org.objectweb.jorm.api.PClassMapping; 28 import org.objectweb.jorm.api.PException; 29 30 import javax.ejb.EJBException ; 31 import javax.ejb.NoSuchObjectLocalException ; 32 33 import java.lang.reflect.Array ; 34 import java.util.Iterator ; 35 36 44 public class Set extends GenClassImpl implements java.util.Set { 45 46 49 public Set(PClassMapping gcm) { 50 super(gcm); 51 } 52 53 public Set() { 54 super(); 55 } 56 57 64 public boolean add(Object o) { 65 return add(o, true); 66 } 67 68 public boolean add(Object o, boolean callListener) { 69 try { 70 if (!gcContains((PObject) o, null)) { 71 gcAdd((PObject) o, callListener); 72 return true; 73 } else { 74 return false; 75 } 76 } catch (NoSuchObjectLocalException e) { 77 throw new IllegalArgumentException (e.getMessage()); 78 } catch (PException e) { 79 e.printStackTrace(); 80 return false; 81 } 82 } 83 85 public int size() { 86 return size; 87 } 88 89 public boolean isEmpty() { 90 return size == 0; 91 } 92 93 public boolean contains(Object o) { 94 try { 95 return gcContains((PObject) o, null); 96 } catch (PException e) { 97 e.printStackTrace(); 98 throw new ArrayStoreException (e.getMessage()); 99 } 100 } 101 102 public Iterator iterator() { 103 try { 104 return gcIterator(); 105 } catch (PException e) { 106 e.printStackTrace(); 107 throw new ArrayStoreException (e.getMessage()); 108 } 109 } 110 111 115 public Object [] toArray() { 116 return toArray(new Object [size]); 117 } 118 119 125 public Object [] toArray(Object [] objects) { 126 try { 127 int i = 0; 128 for (Iterator it = gcIterator(); it.hasNext();) { 129 objects[i++] = it.next(); 130 } 131 } catch (PException e) { 132 e.printStackTrace(); 133 throw new ArrayStoreException (e.getMessage()); 134 } 135 return objects; 136 } 137 138 public boolean remove(Object o) { 139 try { 140 return gcRemove(o, true) != null; 141 } catch (PException e) { 142 throw new EJBException (e); 143 } 144 145 } 146 147 public boolean remove(Object o, boolean callListener) { 148 try { 149 return gcRemove(o, callListener) != null; 150 } catch (PException e) { 151 throw new EJBException (e); 152 } 153 154 } 155 156 public boolean containsAll(java.util.Collection collection) { 157 if (collection == null) { 158 return true; 159 } 160 try { 161 boolean res = true; 162 Object conn = gcm.getPMapper().getConnection(); 163 for (Iterator it = collection.iterator(); it.hasNext() && res;) { 164 res = gcContains((PObject) it.next(), conn); 165 } 166 gcm.getPMapper().closeConnection(conn); 167 return res; 168 } catch (PException e) { 169 e.printStackTrace(); 170 throw new ArrayStoreException (e.getMessage()); 171 } 172 } 173 174 179 public boolean addAll(java.util.Collection collection) { 180 if (collection == null) { 181 return true; 182 } 183 boolean res = true; 184 for (Iterator it = collection.iterator(); it.hasNext();) { 185 res &= add((PObject) it.next()); 186 } 187 return res; 188 } 189 190 195 public boolean removeAll(java.util.Collection collection) { 196 if (collection == null) { 197 return true; 198 } 199 try { 200 for (Iterator it = collection.iterator(); it.hasNext();) { 201 gcRemove((PObject) it.next(), true); 202 } 203 } catch (PException e) { 204 throw new EJBException (e); 205 } 206 return true; 207 } 208 209 214 public boolean retainAll(java.util.Collection collection) { 215 if (collection == null) { 216 clear(); 217 return true; 218 } 219 try { 220 for (Iterator it = iterator(); it.hasNext();) { 221 PObject o = (PObject) it.next(); 222 if (!collection.contains(o)) { 223 gcRemove(o, true); 224 } 225 } 226 } catch (PException e) { 227 throw new EJBException (e); 228 } 229 return true; 230 } 231 232 235 public void clear() { 236 gcClear(false); 237 } 238 239 } 240 | Popular Tags |