1 7 34 35 package com.sun.tools.example.debug.event; 36 37 import com.sun.jdi.*; 38 import com.sun.jdi.event.*; 39 import com.sun.jdi.request.*; 40 41 import java.util.*; 42 43 public abstract class AbstractEventSet extends EventObject implements EventSet { 44 45 private final EventSet jdiEventSet; 46 final Event oneEvent; 47 48 50 AbstractEventSet(EventSet jdiEventSet) { 51 super(jdiEventSet.virtualMachine()); 52 this.jdiEventSet = jdiEventSet; 53 this.oneEvent = eventIterator().nextEvent(); 54 } 55 56 public static AbstractEventSet toSpecificEventSet(EventSet jdiEventSet) { 57 Event evt = jdiEventSet.eventIterator().nextEvent(); 58 if (evt instanceof LocatableEvent) { 59 if (evt instanceof ExceptionEvent) { 60 return new ExceptionEventSet(jdiEventSet); 61 } else if (evt instanceof WatchpointEvent) { 62 if (evt instanceof AccessWatchpointEvent) { 63 return new AccessWatchpointEventSet(jdiEventSet); 64 } else { 65 return new ModificationWatchpointEventSet(jdiEventSet); 66 } 67 } else { 68 return new LocationTriggerEventSet(jdiEventSet); 69 } 70 } else if (evt instanceof ClassPrepareEvent) { 71 return new ClassPrepareEventSet(jdiEventSet); 72 } else if (evt instanceof ClassUnloadEvent) { 73 return new ClassUnloadEventSet(jdiEventSet); 74 } else if (evt instanceof ThreadDeathEvent) { 75 return new ThreadDeathEventSet(jdiEventSet); 76 } else if (evt instanceof ThreadStartEvent) { 77 return new ThreadStartEventSet(jdiEventSet); 78 } else if (evt instanceof VMDeathEvent) { 79 return new VMDeathEventSet(jdiEventSet); 80 } else if (evt instanceof VMDisconnectEvent) { 81 return new VMDisconnectEventSet(jdiEventSet); 82 } else if (evt instanceof VMStartEvent) { 83 return new VMStartEventSet(jdiEventSet); 84 } else { 85 throw new IllegalArgumentException ("Unknown event " + evt); 86 } 87 } 88 89 public abstract void notify(JDIListener listener); 90 91 93 public VirtualMachine virtualMachine() { 94 return jdiEventSet.virtualMachine(); 95 } 96 97 public VirtualMachine getVirtualMachine() { 98 return jdiEventSet.virtualMachine(); 99 } 100 101 103 113 public int getSuspendPolicy() { 114 return jdiEventSet.suspendPolicy(); 115 } 116 117 public void resume() { 118 jdiEventSet.resume(); 119 } 120 121 public int suspendPolicy() { 122 return jdiEventSet.suspendPolicy(); 123 } 124 125 public boolean suspendedAll() { 126 return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_ALL; 127 } 128 129 public boolean suspendedEventThread() { 130 return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD; 131 } 132 133 public boolean suspendedNone() { 134 return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_NONE; 135 } 136 137 140 public EventIterator eventIterator() { 141 return jdiEventSet.eventIterator(); 142 } 143 144 145 147 154 public int size() { 155 return jdiEventSet.size(); 156 } 157 158 163 public boolean isEmpty() { 164 return jdiEventSet.isEmpty(); 165 } 166 167 175 public boolean contains(Object o) { 176 return jdiEventSet.contains(o); 177 } 178 179 186 public Iterator<Event> iterator() { 187 return jdiEventSet.iterator(); 188 } 189 190 196 public Object [] toArray() { 197 return jdiEventSet.toArray(); 198 } 199 200 214 public <T> T[] toArray(T a[]) { 215 return jdiEventSet.toArray(a); 216 } 217 218 220 229 public boolean containsAll(Collection<?> c) { 230 return jdiEventSet.containsAll(c); 231 } 232 233 234 236 public boolean add(Event e){ 237 throw new UnsupportedOperationException (); 238 } 239 public boolean remove(Object o) { 240 throw new UnsupportedOperationException (); 241 } 242 public boolean addAll(Collection<? extends Event> coll) { 243 throw new UnsupportedOperationException (); 244 } 245 public boolean removeAll(Collection<?> coll) { 246 throw new UnsupportedOperationException (); 247 } 248 public boolean retainAll(Collection<?> coll) { 249 throw new UnsupportedOperationException (); 250 } 251 public void clear() { 252 throw new UnsupportedOperationException (); 253 } 254 } 255 256 | Popular Tags |