2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.api.debugger.jpda;
46
* Notifies about exceptions throw in debugged JVM.
49
* <b>How to use it:</b>
50
* <pre style="background-color: rgb(255, 255, 153);">
51
* DebuggerManager.addBreakpoint (ExceptionBreakpoint.create (
52
* "java.lang.NullPointerException",
53
* ExceptionBreakpoint.TYPE_EXCEPTION_UNCATCHED
55
* This breakpoint stops when NullPointerException is throw and uncatched.
59
public final class ExceptionBreakpoint extends JPDABreakpoint {
61
/** Property name constant */
62
public static final String PROP_EXCEPTION_CLASS_NAME = "exceptionClassName"; // NOI18N
63
/** Property name constant */
64
public static final String PROP_CLASS_FILTERS = "classFilters"; // NOI18N
65
/** Property name constant */
66
public static final String PROP_CLASS_EXCLUSION_FILTERS = "classExclusionFilters"; // NOI18N
67
/** Property name constant. */
68
public static final String PROP_CATCH_TYPE = "catchType"; // NOI18N
69
/** Property name constant. */
70
public static final String PROP_CONDITION = "condition"; // NOI18N
72
/** Catch type constant. */
73
public static final int TYPE_EXCEPTION_CATCHED = 1;
74
/** Catch type constant. */
75
public static final int TYPE_EXCEPTION_UNCATCHED = 2;
76
/** Catch type constant. */
77
public static final int TYPE_EXCEPTION_CATCHED_UNCATCHED = 3;
79
private String exceptionClassName = "";
80
private String[] classFilters = new String [0];
81
private String[] classExclusionFilters = new String [0];
82
private int catchType = TYPE_EXCEPTION_UNCATCHED;
83
private String condition = ""; // NOI18N
86
private ExceptionBreakpoint () {
90
* Creates a new breakpoint for given parameters.
92
* @param exceptionClassName class name filter
93
* @param catchType one of constants: TYPE_EXCEPTION_CATCHED,
94
* TYPE_EXCEPTION_UNCATCHED, TYPE_EXCEPTION_CATCHED_UNCATCHED
95
* @return a new breakpoint for given parameters
97
public static ExceptionBreakpoint create (
98
String exceptionClassName,
101
ExceptionBreakpoint b = new ExceptionBreakpoint ();
102
b.setExceptionClassName (exceptionClassName);
103
b.setCatchType (catchType);
108
* Get name of exception class to stop on.
110
* @return name of exception class to stop on
112
public String getExceptionClassName () {
113
return exceptionClassName;
117
* Set name of exception class to stop on.
119
* @param cn a new name of exception class to stop on.
121
public void setExceptionClassName (String cn) {
125
if ( (cn == exceptionClassName) ||
126
((cn != null) && (exceptionClassName != null) && exceptionClassName.equals (cn))
128
Object old = exceptionClassName;
129
exceptionClassName = cn;
130
firePropertyChange (PROP_EXCEPTION_CLASS_NAME, old, exceptionClassName);
134
* Get list of class filters to stop on.
136
* @return list of class filters to stop on
138
public String[] getClassFilters () {
143
* Set list of class filters to stop on.
145
* @param classFilters a new value of class filters property
147
public void setClassFilters (String[] classFilters) {
148
if (classFilters == this.classFilters) return;
149
Object old = this.classFilters;
150
this.classFilters = classFilters;
151
firePropertyChange (PROP_CLASS_FILTERS, old, classFilters);
155
* Get list of class exclusion filters to stop on.
157
* @return list of class exclusion filters to stop on
159
public String[] getClassExclusionFilters () {
160
return classExclusionFilters;
164
* Set list of class exclusion filters to stop on.
166
* @param classExclusionFilters a new value of class exclusion filters property
168
public void setClassExclusionFilters (String[] classExclusionFilters) {
169
if (classExclusionFilters == this.classExclusionFilters) return;
170
Object old = this.classExclusionFilters;
171
this.classExclusionFilters = classExclusionFilters;
172
firePropertyChange (PROP_CLASS_EXCLUSION_FILTERS, old, classExclusionFilters);
178
* @return cond a condition
180
public String getCondition () {
187
* @param cond a c new condition
189
public void setCondition (String cond) {
193
String old = condition;
195
firePropertyChange (PROP_CONDITION, old, cond);
199
* Returns breakpoint type property value.
201
* @return breakpoint type property value.
203
public int getCatchType () {
208
* Sets breakpoint type property value.
210
* @param catchType a new value of breakpoint type property value
212
public void setCatchType (int catchType) {
213
if (catchType == this.catchType) return;
214
if ( (catchType & (TYPE_EXCEPTION_CATCHED | TYPE_EXCEPTION_UNCATCHED)) == 0
215
) throw new IllegalArgumentException ();
216
int old = this.catchType;
217
this.catchType = catchType;
221
new Integer (catchType)
226
* Returns a string representation of this object.
228
* @return a string representation of the object
230
public String toString () {
231
return "ExceptionBreakpoint" + exceptionClassName;