KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > debugger > jpda > ThreadBreakpoint


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.api.debugger.jpda;
21
22
23 /**
24  * Notifies about thread started and dead events.
25  *
26  * <br><br>
27  * <b>How to use it:</b>
28  * <pre style="background-color: rgb(255, 255, 153);">
29  * DebuggerManager.addBreakpoint (ThreadBreakpoint.create (
30  * ));</pre>
31  * This breakpoint stops when some thread is created or killed.
32  *
33  * @author Jan Jancura
34  */

35 public final class ThreadBreakpoint extends JPDABreakpoint {
36
37     /** Property name constant. */
38     public static final String JavaDoc PROP_BREAKPOINT_TYPE = "breakpointtType"; // NOI18N
39

40     /** Catch type property value constant. */
41     public static final int TYPE_THREAD_STARTED = 1;
42     /** Catch type property value constant. */
43     public static final int TYPE_THREAD_DEATH = 2;
44     /** Catch type property value constant. */
45     public static final int TYPE_THREAD_STARTED_OR_DEATH = 3;
46     
47     /** Property variable. */
48     private int breakpointType = TYPE_THREAD_STARTED;
49
50     
51     private ThreadBreakpoint () {
52     }
53     
54     /**
55      * Creates a new breakpoint for given parameters.
56      *
57      * @return a new breakpoint for given parameters
58      */

59     public static ThreadBreakpoint create () {
60         return new ThreadBreakpoint ();
61     }
62
63     /**
64      * Returns type of this breakpoint.
65      *
66      * @return type of this breakpoint
67      */

68     public int getBreakpointType () {
69         return breakpointType;
70     }
71
72     /**
73      * Sets type of this breakpoint (TYPE_THREAD_STARTED or TYPE_THREAD_DEATH).
74      *
75      * @param breakpointType a new value of breakpoint type property
76      */

77     public void setBreakpointType (int breakpointType) {
78         if (breakpointType == this.breakpointType) return;
79         if ((breakpointType & (TYPE_THREAD_STARTED | TYPE_THREAD_DEATH)) == 0)
80             throw new IllegalArgumentException JavaDoc ();
81         int old = this.breakpointType;
82         this.breakpointType = breakpointType;
83         firePropertyChange (PROP_BREAKPOINT_TYPE, new Integer JavaDoc (old), new Integer JavaDoc (breakpointType));
84     }
85
86     /**
87      * Returns a string representation of this object.
88      *
89      * @return a string representation of the object
90      */

91     public String JavaDoc toString () {
92         return "ThreadBreakpoint " + breakpointType;
93     }
94 }
95
Popular Tags