KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > debugger > Watch


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;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.beans.PropertyChangeSupport JavaDoc;
24
25
26 /**
27  * Abstract definition of watch. Each watch is created for
28  * one String which contains the name of variable or some expression.
29  *
30  * @author Jan Jancura
31  */

32 public final class Watch {
33
34     /** Name of the property for the watched expression. */
35     public static final String JavaDoc PROP_EXPRESSION = "expression"; // NOI18N
36
/** Name of the property for the value of the watched expression. This constant is not used at all. */
37     public static final String JavaDoc PROP_VALUE = "value"; // NOI18N
38

39     private String JavaDoc expression;
40     private PropertyChangeSupport JavaDoc pcs;
41     
42     
43     Watch (String JavaDoc expr) {
44         this.expression = expr;
45         pcs = new PropertyChangeSupport JavaDoc (this);
46     }
47     
48     /**
49      * Return expression this watch is created for.
50      *
51      * @return expression this watch is created for
52      */

53     public String JavaDoc getExpression () {
54         return expression;
55     }
56
57     /**
58      * Set the expression to watch.
59      *
60      * @param expression expression to watch
61      */

62     public void setExpression (String JavaDoc expression) {
63         String JavaDoc old = this.expression;
64         this.expression = expression;
65         pcs.firePropertyChange (PROP_EXPRESSION, old, expression);
66     }
67     
68     /**
69      * Remove the watch from the list of all watches in the system.
70      */

71     public void remove () {
72         DebuggerManager dm = DebuggerManager.getDebuggerManager ();
73         dm.removeWatch (this);
74     }
75
76     /**
77      * Add a property change listener.
78      *
79      * @param l the listener to add
80      */

81     public void addPropertyChangeListener (PropertyChangeListener JavaDoc l) {
82         pcs.addPropertyChangeListener (l);
83     }
84
85     /**
86      * Remove a property change listener.
87      *
88      * @param l the listener to remove
89      */

90     public void removePropertyChangeListener (PropertyChangeListener JavaDoc l) {
91         pcs.removePropertyChangeListener (l);
92     }
93 }
94
95
Popular Tags