KickJava   Java API By Example, From Geeks To Geeks.

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


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 import com.sun.jdi.AbsentInformationException;
23 import com.sun.jdi.ThreadReference;
24 import java.beans.PropertyChangeListener JavaDoc;
25 import java.util.List JavaDoc;
26 import org.netbeans.spi.debugger.jpda.EditorContext;
27 import org.netbeans.spi.debugger.jpda.EditorContext.Operation;
28
29
30 /**
31  * Represents one Java thread in debugged process.
32  *
33  * <pre style="background-color: rgb(255, 255, 102);">
34  * Since JDI interfaces evolve from one version to another, it's strongly recommended
35  * not to implement this interface in client code. New methods can be added to
36  * this interface at any time to keep up with the JDI functionality.</pre>
37  *
38  * @author Jan Jancura
39  */

40 public interface JPDAThread {
41
42     /** Thread state constant. */
43     public static final int STATE_UNKNOWN = ThreadReference.THREAD_STATUS_UNKNOWN;
44     /** Thread state constant. */
45     public static final int STATE_MONITOR = ThreadReference.THREAD_STATUS_MONITOR;
46     /** Thread state constant. */
47     public static final int STATE_NOT_STARTED = ThreadReference.THREAD_STATUS_NOT_STARTED;
48     /** Thread state constant. */
49     public static final int STATE_RUNNING = ThreadReference.THREAD_STATUS_RUNNING;
50     /** Thread state constant. */
51     public static final int STATE_SLEEPING = ThreadReference.THREAD_STATUS_SLEEPING;
52     /** Thread state constant. */
53     public static final int STATE_WAIT = ThreadReference.THREAD_STATUS_WAIT;
54     /** Thread state constant. */
55     public static final int STATE_ZOMBIE = ThreadReference.THREAD_STATUS_ZOMBIE;
56
57     /** Property name constant. */
58     public static final String JavaDoc PROP_CALLSTACK = "callStack";
59     /** Property name constant. */
60     public static final String JavaDoc PROP_VARIABLES = "variables";
61
62     
63     
64     /**
65      * Getter for the name of thread property.
66      *
67      * @return name of thread
68      */

69     public abstract String JavaDoc getName ();
70     
71     /**
72      * Returns parent thread group.
73      *
74      * @return parent thread group
75      */

76     public abstract JPDAThreadGroup getParentThreadGroup ();
77
78     /**
79      * Returns line number of the location this thread stopped at.
80      * The thread should be suspended at the moment this method is called.
81      *
82      * @return line number of the current location if the thread is suspended,
83      * contains at least one frame and the topmost frame does not
84      * represent a native method invocation; <CODE>-1</CODE> otherwise
85      * @see CallStackFrame
86      */

87     public abstract int getLineNumber (String JavaDoc stratum);
88
89     /**
90      * Returns the operation that is being currently executed on this thread.
91      * @return The current operation, or <CODE>null</CODE>.
92      * @see {@link CallStackFrame#getCurrentOperation}
93      */

94     public abstract Operation getCurrentOperation();
95     
96     /**
97      * Returns the list of the last operations, that were performed on this thread.
98      * Typically just operations from the current expression are stored.
99      * The thread should be suspended at the moment this method is called.
100      *
101      * @return The list of last operations if available, the thread is suspended,
102      * contains at least one frame and the topmost frame does not
103      * represent a native method invocation; <CODE>null</CODE> otherwise
104      * @see CallStackFrame
105      */

106     public abstract List JavaDoc<Operation> getLastOperations();
107
108     /**
109      * Returns current state of this thread.
110      *
111      * @return current state of this thread
112      */

113     public abstract int getState ();
114     
115     /**
116      * Returns true if this thread is suspended by debugger.
117      *
118      * @return true if this thread is suspended by debugger
119      */

120     public abstract boolean isSuspended ();
121
122     /**
123      * If this thread is suspended returns class name this thread is
124      * stopped in.
125      *
126      * @return class name this thread is stopped in
127      */

128     public abstract String JavaDoc getClassName ();
129
130     /**
131      * If this thread is suspended returns method name this thread is
132      * stopped in.
133      *
134      * @return method name this thread is stopped in
135      */

136     public abstract String JavaDoc getMethodName ();
137     
138     /**
139      * Suspends thread.
140      */

141     public abstract void suspend ();
142     
143     /**
144      * Unsuspends thread.
145      */

146     public abstract void resume ();
147     
148     /**
149      * Interrupts this thread unless the thread has been suspended.
150      * @since 2.1
151      */

152     public abstract void interrupt();
153     
154     /**
155      * Returns file name this frame is stopped in or null.
156      *
157      * @return file name this frame is stopped in
158      */

159     public abstract String JavaDoc getSourceName (String JavaDoc stratum)
160     throws AbsentInformationException;
161     
162     /**
163      * Returns source path of file this frame is stopped in or null.
164      *
165      * @return source path of file this frame is stopped in or null
166      */

167     public abstract String JavaDoc getSourcePath (String JavaDoc stratum)
168     throws AbsentInformationException;
169     
170     /**
171      * Returns call stack for this thread.
172      *
173      * @throws AbsentInformationException if the thread is running or not able
174      * to return callstack. If the thread is in an incompatible state
175      * (e.g. running), the AbsentInformationException has
176      * IncompatibleThreadStateException as a cause.
177      * @return call stack
178      */

179     public abstract CallStackFrame[] getCallStack ()
180     throws AbsentInformationException;
181     
182     /**
183      * Returns call stack for this thread on the given indexes.
184      *
185      * @param from a from index, inclusive
186      * @param to a to index, exclusive
187      * @throws AbsentInformationException if the thread is running or not able
188      * to return callstack. If the thread is in an incompatible state
189      * (e.g. running), the AbsentInformationException has
190      * IncompatibleThreadStateException as a cause.
191      * @return call stack
192      */

193     public abstract CallStackFrame[] getCallStack (int from, int to)
194     throws AbsentInformationException;
195     
196     /**
197      * Returns length of current call stack.
198      *
199      * @return length of current call stack
200      */

201     public abstract int getStackDepth ();
202     
203     /**
204      * Sets this thread current.
205      *
206      * @see JPDADebugger#getCurrentThread
207      */

208     public abstract void makeCurrent ();
209     
210     /**
211      * Returns monitor this thread is waiting on.
212      *
213      * @return monitor this thread is waiting on
214      */

215     public abstract ObjectVariable getContendedMonitor ();
216     
217     /**
218      * Returns monitors owned by this thread.
219      *
220      * @return monitors owned by this thread
221      */

222     public abstract ObjectVariable[] getOwnedMonitors ();
223 }
224
Popular Tags