001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.api.debugger.jpda.event;
043:
044: import com.sun.jdi.ReferenceType;
045: import java.util.EventObject;
046: import org.netbeans.api.debugger.jpda.*;
047:
048: /**
049: * JPDABreakpoint event notification.
050: *
051: * @author Jan Jancura
052: */
053: public final class JPDABreakpointEvent extends EventObject {
054:
055: /** Condition result constant. */
056: public static final int CONDITION_NONE = 0;
057: /** Condition result constant. */
058: public static final int CONDITION_TRUE = 1;
059: /** Condition result constant. */
060: public static final int CONDITION_FALSE = 2;
061: /** Condition result constant. */
062: public static final int CONDITION_FAILED = 3;
063:
064: private int conditionResult = CONDITION_FAILED;
065: private Throwable conditionException = null;
066: private JPDADebugger debugger;
067: private JPDAThread thread;
068: private ReferenceType referenceType;
069: private Variable variable;
070: private boolean resume = false;
071:
072: /**
073: * Creates a new instance of JPDABreakpointEvent. This method should be
074: * called from debuggerjpda module only. Do not create a new instances
075: * of this class!
076: *
077: * @param sourceBreakpoint a breakpoint
078: * @param debugger a debugger this
079: * @param conditionResult a result of condition
080: * @param thread a context thread
081: * @param referenceType a context class
082: * @param variable a context variable
083: */
084: public JPDABreakpointEvent(JPDABreakpoint sourceBreakpoint,
085: JPDADebugger debugger, int conditionResult,
086: JPDAThread thread, ReferenceType referenceType,
087: Variable variable) {
088: super (sourceBreakpoint);
089: this .conditionResult = conditionResult;
090: this .thread = thread;
091: this .debugger = debugger;
092: this .referenceType = referenceType;
093: this .variable = variable;
094: }
095:
096: /**
097: * Creates a new instance of JPDABreakpointEvent.
098: *
099: * @param sourceBreakpoint a breakpoint
100: * @param conditionException result of condition
101: * @param thread a context thread
102: * @param debugger a debugger this
103: * @param referenceType a context class
104: * @param variable a context variable
105: */
106: public JPDABreakpointEvent(JPDABreakpoint sourceBreakpoint,
107: JPDADebugger debugger, Throwable conditionException,
108: JPDAThread thread, ReferenceType referenceType,
109: Variable variable) {
110: super (sourceBreakpoint);
111: this .conditionResult = CONDITION_FAILED;
112: this .conditionException = conditionException;
113: this .thread = thread;
114: this .debugger = debugger;
115: this .referenceType = referenceType;
116: this .variable = variable;
117: }
118:
119: /**
120: * Returns result of condition evaluation.
121: *
122: * @return result of condition evaluation
123: */
124: public int getConditionResult() {
125: return conditionResult;
126: }
127:
128: /**
129: * Returns result of condition evaluation.
130: *
131: * @return result of condition evaluation
132: */
133: public Throwable getConditionException() {
134: return conditionException;
135: }
136:
137: /**
138: * Returns context thread - thread stopped on breakpoint. This parameter
139: * is defined by class prepared breakpoint, exception breakpoint,
140: * field breakpoint, line breakpoint, method breakpoint and
141: * thread breakpoint.
142: *
143: * @return thread context
144: */
145: public JPDAThread getThread() {
146: return thread;
147: }
148:
149: /**
150: * Returns context class. It means loaded class for class load breakpoint
151: * and exception class for exception breakpoint.
152: *
153: * @return context class
154: */
155: public ReferenceType getReferenceType() {
156: return referenceType;
157: }
158:
159: /**
160: * Returns JPDADebugger instance this breakpoint has been reached in.
161: *
162: * @return JPDADebugger instance this breakpoint has been reached in
163: */
164: public JPDADebugger getDebugger() {
165: return debugger;
166: }
167:
168: /**
169: * Returns context variable. It contains new value for field modification
170: * breakpoint and instance of exception for exception breakpoint.
171: *
172: * @return context variable
173: */
174: public Variable getVariable() {
175: return variable;
176: }
177:
178: /**
179: * Call this method to resume debugger after all events will be notified.
180: * You should not call JPDADebugger.resume () during breakpoint event
181: * evaluation!
182: */
183: public void resume() {
184: resume = true;
185: }
186:
187: /**
188: * Returns resume value.
189: */
190: public boolean getResume() {
191: return resume;
192: }
193: }
|