|
Java example source code file (AbstractEventSet.java)
The AbstractEventSet.java Java example source code
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
package com.sun.tools.example.debug.event;
import com.sun.jdi.*;
import com.sun.jdi.event.*;
import com.sun.jdi.request.*;
import java.util.*;
public abstract class AbstractEventSet extends EventObject implements EventSet {
private static final long serialVersionUID = 2772717574222076977L;
private final EventSet jdiEventSet;
final Event oneEvent;
/**
*/
AbstractEventSet(EventSet jdiEventSet) {
super(jdiEventSet.virtualMachine());
this.jdiEventSet = jdiEventSet;
this.oneEvent = eventIterator().nextEvent();
}
public static AbstractEventSet toSpecificEventSet(EventSet jdiEventSet) {
Event evt = jdiEventSet.eventIterator().nextEvent();
if (evt instanceof LocatableEvent) {
if (evt instanceof ExceptionEvent) {
return new ExceptionEventSet(jdiEventSet);
} else if (evt instanceof WatchpointEvent) {
if (evt instanceof AccessWatchpointEvent) {
return new AccessWatchpointEventSet(jdiEventSet);
} else {
return new ModificationWatchpointEventSet(jdiEventSet);
}
} else {
return new LocationTriggerEventSet(jdiEventSet);
}
} else if (evt instanceof ClassPrepareEvent) {
return new ClassPrepareEventSet(jdiEventSet);
} else if (evt instanceof ClassUnloadEvent) {
return new ClassUnloadEventSet(jdiEventSet);
} else if (evt instanceof ThreadDeathEvent) {
return new ThreadDeathEventSet(jdiEventSet);
} else if (evt instanceof ThreadStartEvent) {
return new ThreadStartEventSet(jdiEventSet);
} else if (evt instanceof VMDeathEvent) {
return new VMDeathEventSet(jdiEventSet);
} else if (evt instanceof VMDisconnectEvent) {
return new VMDisconnectEventSet(jdiEventSet);
} else if (evt instanceof VMStartEvent) {
return new VMStartEventSet(jdiEventSet);
} else {
throw new IllegalArgumentException("Unknown event " + evt);
}
}
public abstract void notify(JDIListener listener);
// Implement Mirror
@Override
public VirtualMachine virtualMachine() {
return jdiEventSet.virtualMachine();
}
public VirtualMachine getVirtualMachine() {
return jdiEventSet.virtualMachine();
}
// Implement EventSet
/**
* Returns the policy used to suspend threads in the target VM
* for this event set. This policy is selected from the suspend
* policies for each event's request. The one that suspends the
* most threads is chosen when the event occurs in the target VM
* and that policy is returned here. See
* com.sun.jdi.request.EventRequest for the possible policy values.
*
* @return the integer suspendPolicy
*/
public int getSuspendPolicy() {
return jdiEventSet.suspendPolicy();
}
@Override
public void resume() {
jdiEventSet.resume();
}
@Override
public int suspendPolicy() {
return jdiEventSet.suspendPolicy();
}
public boolean suspendedAll() {
return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_ALL;
}
public boolean suspendedEventThread() {
return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD;
}
public boolean suspendedNone() {
return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_NONE;
}
/**
* Return an iterator specific to {@link Event} objects.
*/
@Override
public EventIterator eventIterator() {
return jdiEventSet.eventIterator();
}
// Implement java.util.Set (by pass through)
/**
* Returns the number of elements in this set (its cardinality). If this
* set contains more than <tt>Integer.MAX_VALUE elements, returns
* <tt>Integer.MAX_VALUE.
*
* @return the number of elements in this set (its cardinality).
*/
@Override
public int size() {
return jdiEventSet.size();
}
/**
* Returns <tt>true if this set contains no elements.
*
* @return <tt>true if this set contains no elements.
*/
@Override
public boolean isEmpty() {
return jdiEventSet.isEmpty();
}
/**
* Returns <tt>true if this set contains the specified element. More
* formally, returns <tt>true if and only if this set contains an
* element <code>e such that
Other Java examples (source code examples)Here is a short list of links related to this Java AbstractEventSet.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.