History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/tools/example/debug/event/AbstractEventSet.java (1 of 18352 files). Show all

Unified · Split

java/pkg/com/sun/tools/example/debug/event/AbstractEventSet.java+263−0
@@ -0,0 +1,263 @@
1+/*
2+ * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.example.debug.event;
27+
28+import com.sun.jdi.*;
29+import com.sun.jdi.event.*;
30+import com.sun.jdi.request.*;
31+
32+import java.util.*;
33+
34+public abstract class AbstractEventSet extends EventObject implements EventSet {
35+
36+ private static final long serialVersionUID = 2772717574222076977L;
37+ private final EventSet jdiEventSet;
38+ final Event oneEvent;
39+
40+ /**
41+ */
42+ AbstractEventSet(EventSet jdiEventSet) {
43+ super(jdiEventSet.virtualMachine());
44+ this.jdiEventSet = jdiEventSet;
45+ this.oneEvent = eventIterator().nextEvent();
46+ }
47+
48+ public static AbstractEventSet toSpecificEventSet(EventSet jdiEventSet) {
49+ Event evt = jdiEventSet.eventIterator().nextEvent();
50+ if (evt instanceof LocatableEvent) {
51+ if (evt instanceof ExceptionEvent) {
52+ return new ExceptionEventSet(jdiEventSet);
53+ } else if (evt instanceof WatchpointEvent) {
54+ if (evt instanceof AccessWatchpointEvent) {
55+ return new AccessWatchpointEventSet(jdiEventSet);
56+ } else {
57+ return new ModificationWatchpointEventSet(jdiEventSet);
58+ }
59+ } else {
60+ return new LocationTriggerEventSet(jdiEventSet);
61+ }
62+ } else if (evt instanceof ClassPrepareEvent) {
63+ return new ClassPrepareEventSet(jdiEventSet);
64+ } else if (evt instanceof ClassUnloadEvent) {
65+ return new ClassUnloadEventSet(jdiEventSet);
66+ } else if (evt instanceof ThreadDeathEvent) {
67+ return new ThreadDeathEventSet(jdiEventSet);
68+ } else if (evt instanceof ThreadStartEvent) {
69+ return new ThreadStartEventSet(jdiEventSet);
70+ } else if (evt instanceof VMDeathEvent) {
71+ return new VMDeathEventSet(jdiEventSet);
72+ } else if (evt instanceof VMDisconnectEvent) {
73+ return new VMDisconnectEventSet(jdiEventSet);
74+ } else if (evt instanceof VMStartEvent) {
75+ return new VMStartEventSet(jdiEventSet);
76+ } else {
77+ throw new IllegalArgumentException("Unknown event " + evt);
78+ }
79+ }
80+
81+ public abstract void notify(JDIListener listener);
82+
83+ // Implement Mirror
84+
85+ @Override
86+ public VirtualMachine virtualMachine() {
87+ return jdiEventSet.virtualMachine();
88+ }
89+
90+ public VirtualMachine getVirtualMachine() {
91+ return jdiEventSet.virtualMachine();
92+ }
93+
94+ // Implement EventSet
95+
96+ /**
97+ * Returns the policy used to suspend threads in the target VM
98+ * for this event set. This policy is selected from the suspend
99+ * policies for each event's request. The one that suspends the
100+ * most threads is chosen when the event occurs in the target VM
101+ * and that policy is returned here. See
102+ * com.sun.jdi.request.EventRequest for the possible policy values.
103+ *
104+ * @return the integer suspendPolicy
105+ */
106+ public int getSuspendPolicy() {
107+ return jdiEventSet.suspendPolicy();
108+ }
109+
110+ @Override
111+ public void resume() {
112+ jdiEventSet.resume();
113+ }
114+
115+ @Override
116+ public int suspendPolicy() {
117+ return jdiEventSet.suspendPolicy();
118+ }
119+
120+ public boolean suspendedAll() {
121+ return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_ALL;
122+ }
123+
124+ public boolean suspendedEventThread() {
125+ return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD;
126+ }
127+
128+ public boolean suspendedNone() {
129+ return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_NONE;
130+ }
131+
132+ /**
133+ * Return an iterator specific to {@link Event} objects.
134+ */
135+ @Override
136+ public EventIterator eventIterator() {
137+ return jdiEventSet.eventIterator();
138+ }
139+
140+
141+ // Implement java.util.Set (by pass through)
142+
143+ /**
144+ * Returns the number of elements in this set (its cardinality). If this
145+ * set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
146+ * <tt>Integer.MAX_VALUE</tt>.
147+ *
148+ * @return the number of elements in this set (its cardinality).
149+ */
150+ @Override
151+ public int size() {
152+ return jdiEventSet.size();
153+ }
154+
155+ /**
156+ * Returns <tt>true</tt> if this set contains no elements.
157+ *
158+ * @return <tt>true</tt> if this set contains no elements.
159+ */
160+ @Override
161+ public boolean isEmpty() {
162+ return jdiEventSet.isEmpty();
163+ }
164+
165+ /**
166+ * Returns <tt>true</tt> if this set contains the specified element. More
167+ * formally, returns <tt>true</tt> if and only if this set contains an
168+ * element <code>e</code> such that <code>(o==null ? e==null :
169+ * o.equals(e))</code>.
170+ *
171+ * @return <tt>true</tt> if this set contains the specified element.
172+ */
173+ @Override
174+ public boolean contains(Object o) {
175+ return jdiEventSet.contains(o);
176+ }
177+
178+ /**
179+ * Returns an iterator over the elements in this set. The elements are
180+ * returned in no particular order (unless this set is an instance of some
181+ * class that provides a guarantee).
182+ *
183+ * @return an iterator over the elements in this set.
184+ */
185+ @Override
186+ public Iterator<Event> iterator() {
187+ return jdiEventSet.iterator();
188+ }
189+
190+ /**
191+ * Returns an array containing all of the elements in this set.
192+ * Obeys the general contract of the <tt>Collection.toArray</tt> method.
193+ *
194+ * @return an array containing all of the elements in this set.
195+ */
196+ @Override
197+ public Object[] toArray() {
198+ return jdiEventSet.toArray();
199+ }
200+
201+ /**
202+ * Returns an array containing all of the elements in this set whose
203+ * runtime type is that of the specified array. Obeys the general
204+ * contract of the <tt>Collection.toArray(Object[])</tt> method.
205+ *
206+ * @param a the array into which the elements of this set are to
207+ * be stored, if it is big enough {
208+ return jdiEventSet.XXX();
209+ } otherwise, a new array of the
210+ * same runtime type is allocated for this purpose.
211+ * @return an array containing the elements of this set.
212+ * @throws ArrayStoreException the runtime type of a is not a supertype
213+ * of the runtime type of every element in this set.
214+ */
215+ @Override
216+ public <T> T[] toArray(T a[]) {
217+ return jdiEventSet.toArray(a);
218+ }
219+
220+ // Bulk Operations
221+
222+ /**
223+ * Returns <tt>true</tt> if this set contains all of the elements of the
224+ * specified collection. If the specified collection is also a set, this
225+ * method returns <tt>true</tt> if it is a <i>subset</i> of this set.
226+ *
227+ * @param c collection to be checked for containment in this set.
228+ * @return <tt>true</tt> if this set contains all of the elements of the
229+ * specified collection.
230+ */
231+ @Override
232+ public boolean containsAll(Collection<?> c) {
233+ return jdiEventSet.containsAll(c);
234+ }
235+
236+
237+ // Make the rest of Set unmodifiable
238+
239+ @Override
240+ public boolean add(Event e){
241+ throw new UnsupportedOperationException();
242+ }
243+ @Override
244+ public boolean remove(Object o) {
245+ throw new UnsupportedOperationException();
246+ }
247+ @Override
248+ public boolean addAll(Collection<? extends Event> coll) {
249+ throw new UnsupportedOperationException();
250+ }
251+ @Override
252+ public boolean removeAll(Collection<?> coll) {
253+ throw new UnsupportedOperationException();
254+ }
255+ @Override
256+ public boolean retainAll(Collection<?> coll) {
257+ throw new UnsupportedOperationException();
258+ }
259+ @Override
260+ public void clear() {
261+ throw new UnsupportedOperationException();
262+ }
263+}