Source Code Cross Referenced for EventSetImpl.java in  » IDE-Eclipse » jdt » org » eclipse » jdi » internal » event » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdi.internal.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         * 
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdi.internal.event;
011:
012:        import java.io.DataInputStream;
013:        import java.io.IOException;
014:        import java.util.ArrayList;
015:        import java.util.Collection;
016:        import java.util.Iterator;
017:        import java.util.List;
018:
019:        import org.eclipse.jdi.internal.MirrorImpl;
020:        import org.eclipse.jdi.internal.VirtualMachineImpl;
021:        import org.eclipse.jdi.internal.request.EventRequestImpl;
022:
023:        import com.sun.jdi.InternalException;
024:        import com.sun.jdi.ThreadReference;
025:        import com.sun.jdi.event.EventIterator;
026:        import com.sun.jdi.event.EventSet;
027:        import com.sun.jdi.request.EventRequest;
028:
029:        /**
030:         * this class implements the corresponding interfaces
031:         * declared by the JDI specification. See the com.sun.jdi package
032:         * for more information.
033:         *
034:         */
035:        public class EventSetImpl extends MirrorImpl implements  EventSet {
036:            /** Set that is used to store events. */
037:            private List fEvents;
038:            /** Which threads were suspended by this composite event. */
039:            private byte fSuspendPolicy;
040:
041:            /**
042:             * Creates new EventSetImpl.
043:             */
044:            private EventSetImpl(VirtualMachineImpl vmImpl) {
045:                super ("EventSet", vmImpl); //$NON-NLS-1$
046:            }
047:
048:            /**
049:             * Creates new EventSetImpl with events in a given array.
050:             */
051:            public EventSetImpl(VirtualMachineImpl vmImpl, EventImpl[] events) {
052:                this (vmImpl);
053:                fEvents = new ArrayList(events.length);
054:                for (int i = 0; i < events.length; i++)
055:                    fEvents.add(events[i]);
056:            }
057:
058:            /**
059:             * Creates new EventSetImpl with given event.
060:             */
061:            public EventSetImpl(VirtualMachineImpl vmImpl, EventImpl event) {
062:                this (vmImpl);
063:                fEvents = new ArrayList(1);
064:                fEvents.add(event);
065:            }
066:
067:            /**
068:             * @return Returns iterator over events.
069:             */
070:            public EventIterator eventIterator() {
071:                return new EventIteratorImpl(fEvents.listIterator());
072:            }
073:
074:            /**
075:             * @return Returns which threads were suspended by this composite event.
076:             */
077:            public int suspendPolicy() {
078:                switch (fSuspendPolicy) {
079:                case EventRequestImpl.SUSPENDPOL_NONE_JDWP:
080:                    return EventRequest.SUSPEND_NONE;
081:                case EventRequestImpl.SUSPENDPOL_EVENT_THREAD_JDWP:
082:                    return EventRequest.SUSPEND_EVENT_THREAD;
083:                case EventRequestImpl.SUSPENDPOL_ALL_JDWP:
084:                    return EventRequest.SUSPEND_ALL;
085:                default:
086:                    throw new InternalException(
087:                            EventMessages.EventSetImpl_Invalid_suspend_policy_encountered___1
088:                                    + fSuspendPolicy);
089:                }
090:            }
091:
092:            /**
093:             * Resumes threads that were suspended by this event set.
094:             */
095:            public void resume() {
096:                switch (fSuspendPolicy) {
097:                case EventRequestImpl.SUSPENDPOL_NONE_JDWP:
098:                    break;
099:                case EventRequestImpl.SUSPENDPOL_EVENT_THREAD_JDWP:
100:                    resumeThreads();
101:                    break;
102:                case EventRequestImpl.SUSPENDPOL_ALL_JDWP:
103:                    virtualMachineImpl().resume();
104:                    break;
105:                default:
106:                    throw new InternalException(
107:                            EventMessages.EventSetImpl_Invalid_suspend_policy_encountered___1
108:                                    + fSuspendPolicy);
109:                }
110:            }
111:
112:            /**
113:             * Resumes threads that were suspended by this event set.
114:             */
115:            private void resumeThreads() {
116:                if (fEvents.size() == 1) {
117:                    // Most event sets have only one event.
118:                    // Avoid expensive object creation.
119:                    ThreadReference ref = ((EventImpl) fEvents.get(0)).thread();
120:                    if (ref != null) {
121:                        ref.resume();
122:                    } else {
123:                        ((EventImpl) fEvents.get(0)).virtualMachine().resume();
124:                    }
125:                    return;
126:                }
127:                Iterator iter = fEvents.iterator();
128:                List resumedThreads = new ArrayList(fEvents.size());
129:                while (iter.hasNext()) {
130:                    EventImpl event = (EventImpl) iter.next();
131:                    ThreadReference thread = event.thread();
132:                    if (thread == null) {
133:                        event.virtualMachine().resume();
134:                        return;
135:                    }
136:                    if (!resumedThreads.contains(thread)) {
137:                        resumedThreads.add(thread);
138:                    }
139:                }
140:                Iterator resumeIter = resumedThreads.iterator();
141:                while (resumeIter.hasNext()) {
142:                    ((ThreadReference) resumeIter.next()).resume();
143:                }
144:            }
145:
146:            /**
147:             * @return Returns EventSetImpl that was read from InputStream.
148:             */
149:            public static EventSetImpl read(MirrorImpl target,
150:                    DataInputStream in) throws IOException {
151:                VirtualMachineImpl vmImpl = target.virtualMachineImpl();
152:                EventSetImpl eventSet = new EventSetImpl(vmImpl);
153:
154:                // Read suspend policy.
155:                eventSet.fSuspendPolicy = target
156:                        .readByte(
157:                                "suspendPolicy", EventRequestImpl.suspendPolicyMap(), in); //$NON-NLS-1$
158:                // Read size.
159:                int size = target.readInt("size", in); //$NON-NLS-1$
160:                // Create event list.
161:                eventSet.fEvents = new ArrayList(size);
162:
163:                while (size-- > 0) {
164:                    EventImpl event = EventImpl.read(target, in);
165:
166:                    // If event == null than it is an event that must not be given to the application.
167:                    // See ClassPrepareEvent.
168:                    if (event == null)
169:                        continue;
170:
171:                    EventRequestImpl request = (EventRequestImpl) event
172:                            .request();
173:
174:                    // Check if the request corresponding to the event was not generated from inside this JDI implementation.
175:                    if (request == null || !request.isGeneratedInside())
176:                        eventSet.fEvents.add(event);
177:
178:                }
179:                return eventSet;
180:            }
181:
182:            /**
183:             * @see java.util.Collection
184:             */
185:            public boolean contains(Object event) {
186:                return fEvents.contains(event);
187:            }
188:
189:            /**
190:             * @see java.util.Collection
191:             */
192:            public boolean containsAll(Collection events) {
193:                return fEvents.containsAll(events);
194:            }
195:
196:            /**
197:             * @see java.util.Collection
198:             */
199:            public boolean equals(Object object) {
200:                return object != null
201:                        && object.getClass().equals(this .getClass())
202:                        && fEvents.equals(((EventSetImpl) object).fEvents);
203:            }
204:
205:            /**
206:             * @see java.util.Collection
207:             */
208:            public int hashCode() {
209:                return fEvents.hashCode();
210:            }
211:
212:            /**
213:             * @see java.util.Collection
214:             */
215:            public boolean isEmpty() {
216:                return fEvents.isEmpty();
217:            }
218:
219:            /**
220:             * @see java.util.Collection#iterator()
221:             */
222:            public Iterator iterator() {
223:                return fEvents.iterator();
224:            }
225:
226:            /**
227:             * @see java.util.Collection#size()
228:             */
229:            public int size() {
230:                return fEvents.size();
231:            }
232:
233:            /**
234:             * @see java.util.Collection#toArray()
235:             */
236:            public Object[] toArray() {
237:                return fEvents.toArray();
238:            }
239:
240:            /**
241:             * @see java.util.Collection#toArray(Object[])
242:             */
243:            public Object[] toArray(Object[] events) {
244:                return fEvents.toArray(events);
245:            }
246:
247:            /**
248:             * @see java.util.Collection#add(Object).
249:             * @exception UnsupportedOperationException always thrown since EventSets are unmodifiable.
250:             */
251:            public boolean add(Object arg1) {
252:                throw new UnsupportedOperationException(
253:                        EventMessages.EventSetImpl_EventSets_are_unmodifiable_3);
254:            }
255:
256:            /**
257:             * @see java.util.Collection#addAll(Collection)
258:             * @exception UnsupportedOperationException always thrown since EventSets are unmodifiable.
259:             */
260:            public boolean addAll(Collection arg1) {
261:                throw new UnsupportedOperationException(
262:                        EventMessages.EventSetImpl_EventSets_are_unmodifiable_3);
263:            }
264:
265:            /**
266:             * @see java.util.Collection#clear()
267:             * @exception UnsupportedOperationException always thrown since EventSets are unmodifiable.
268:             */
269:            public void clear() {
270:                throw new UnsupportedOperationException(
271:                        EventMessages.EventSetImpl_EventSets_are_unmodifiable_3);
272:            }
273:
274:            /**
275:             * @see java.util.Collection#remove(Object)
276:             * @exception UnsupportedOperationException always thrown since EventSets are unmodifiable.
277:             */
278:            public boolean remove(Object arg1) {
279:                throw new UnsupportedOperationException(
280:                        EventMessages.EventSetImpl_EventSets_are_unmodifiable_3);
281:            }
282:
283:            /**
284:             * @see java.util.Collection#removeAll(Collection)
285:             * @exception UnsupportedOperationException always thrown since EventSets are unmodifiable.
286:             */
287:            public boolean removeAll(Collection arg1) {
288:                throw new UnsupportedOperationException(
289:                        EventMessages.EventSetImpl_EventSets_are_unmodifiable_3);
290:            }
291:
292:            /**
293:             * @see java.util.Collection#retainAll(Collection)
294:             * @exception UnsupportedOperationException always thrown since EventSets are unmodifiable.
295:             */
296:            public boolean retainAll(Collection arg1) {
297:                throw new UnsupportedOperationException(
298:                        EventMessages.EventSetImpl_EventSets_are_unmodifiable_3);
299:            }
300:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.